Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy_dev_docs_to_cf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Setup Hugo
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3
with:
hugo-version: "0.145.0"
hugo-version: "0.160.0"
extended: true

- name: Setup Node
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_previous_version_docs_to_cf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
- name: Setup Hugo and Node
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3
with:
hugo-version: "0.145.0"
hugo-version: "0.160.0"
extended: true
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy_versioned_docs_to_cf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Setup Hugo
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3
with:
hugo-version: "0.145.0"
hugo-version: "0.160.0"
extended: true

- name: Setup Node
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs_preview_build_cf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Setup Hugo
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3
with:
hugo-version: "0.145.0"
hugo-version: "0.160.0"
extended: true

- name: Setup Node
Expand Down
8 changes: 8 additions & 0 deletions internal/sources/cloudsqlpg/cloud_sql_pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,17 @@ func (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.So

err = pool.Ping(ctx)
if err != nil {
pool.Close()
return nil, fmt.Errorf("unable to connect successfully: %w", err)
}

var res int
err = pool.QueryRow(ctx, "SELECT 1").Scan(&res)
if err != nil {
pool.Close()
return nil, fmt.Errorf("failed to execute 'SELECT 1' after connection: %w", err)
}

s := &Source{
Config: r,
Pool: pool,
Expand Down
110 changes: 0 additions & 110 deletions tests/alloydb/alloydb_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"net/http"
"net/http/httptest"
"net/url"
"os"
"reflect"
"regexp"
"sort"
Expand All @@ -37,115 +36,6 @@ import (
"github.com/googleapis/mcp-toolbox/tests"
)

var (
AlloyDBProject = os.Getenv("ALLOYDB_PROJECT")
AlloyDBLocation = os.Getenv("ALLOYDB_REGION")
AlloyDBCluster = os.Getenv("ALLOYDB_CLUSTER")
AlloyDBInstance = os.Getenv("ALLOYDB_INSTANCE")
AlloyDBUser = os.Getenv("ALLOYDB_POSTGRES_USER")
)

func getAlloyDBVars(t *testing.T) map[string]string {
if AlloyDBProject == "" {
t.Fatal("'ALLOYDB_PROJECT' not set")
}
if AlloyDBLocation == "" {
t.Fatal("'ALLOYDB_REGION' not set")
}
if AlloyDBCluster == "" {
t.Fatal("'ALLOYDB_CLUSTER' not set")
}
if AlloyDBInstance == "" {
t.Fatal("'ALLOYDB_INSTANCE' not set")
}
if AlloyDBUser == "" {
t.Fatal("'ALLOYDB_USER' not set")
}
return map[string]string{
"project": AlloyDBProject,
"location": AlloyDBLocation,
"cluster": AlloyDBCluster,
"instance": AlloyDBInstance,
"user": AlloyDBUser,
}
}

func getAlloyDBToolsConfig() map[string]any {
return map[string]any{
"sources": map[string]any{
"alloydb-admin-source": map[string]any{
"type": "alloydb-admin",
},
},
"tools": map[string]any{
// Tool for RunAlloyDBToolGetTest
"my-simple-tool": map[string]any{
"type": "alloydb-list-clusters",
"source": "alloydb-admin-source",
"description": "Simple tool to test end to end functionality.",
},
// Tool for MCP test
"my-param-tool": map[string]any{
"type": "alloydb-list-clusters",
"source": "alloydb-admin-source",
"description": "Tool to list clusters",
},
// Tool for MCP test that fails
"my-fail-tool": map[string]any{
"type": "alloydb-list-clusters",
"source": "alloydb-admin-source",
"description": "Tool that will fail",
},
// AlloyDB specific tools
"alloydb-list-clusters": map[string]any{
"type": "alloydb-list-clusters",
"source": "alloydb-admin-source",
"description": "Lists all AlloyDB clusters in a given project and location.",
},
"alloydb-list-users": map[string]any{
"type": "alloydb-list-users",
"source": "alloydb-admin-source",
"description": "Lists all AlloyDB users within a specific cluster.",
},
"alloydb-list-instances": map[string]any{
"type": "alloydb-list-instances",
"source": "alloydb-admin-source",
"description": "Lists all AlloyDB instances within a specific cluster.",
},
"alloydb-get-cluster": map[string]any{
"type": "alloydb-get-cluster",
"source": "alloydb-admin-source",
"description": "Retrieves details of a specific AlloyDB cluster.",
},
"alloydb-get-instance": map[string]any{
"type": "alloydb-get-instance",
"source": "alloydb-admin-source",
"description": "Retrieves details of a specific AlloyDB instance.",
},
"alloydb-get-user": map[string]any{
"type": "alloydb-get-user",
"source": "alloydb-admin-source",
"description": "Retrieves details of a specific AlloyDB user.",
},
"alloydb-create-cluster": map[string]any{
"type": "alloydb-create-cluster",
"description": "create cluster",
"source": "alloydb-admin-source",
},
"alloydb-create-instance": map[string]any{
"type": "alloydb-create-instance",
"description": "create instance",
"source": "alloydb-admin-source",
},
"alloydb-create-user": map[string]any{
"type": "alloydb-create-user",
"description": "create user",
"source": "alloydb-admin-source",
},
},
}
}

func TestAlloyDBToolEndpoints(t *testing.T) {
vars := getAlloyDBVars(t)
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
Expand Down
139 changes: 132 additions & 7 deletions tests/alloydb/alloydb_mcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"net/http"
"net/http/httptest"
"net/url"
"os"
"reflect"
"regexp"
"sort"
Expand All @@ -33,11 +34,138 @@ import (
"github.com/googleapis/mcp-toolbox/tests"
)

var (
AlloyDBProject = os.Getenv("ALLOYDB_PROJECT")
AlloyDBLocation = os.Getenv("ALLOYDB_REGION")
AlloyDBCluster = os.Getenv("ALLOYDB_CLUSTER")
AlloyDBInstance = os.Getenv("ALLOYDB_INSTANCE")
AlloyDBUser = os.Getenv("ALLOYDB_POSTGRES_USER")
)

func getAlloyDBVars(t *testing.T) map[string]string {
if AlloyDBProject == "" {
t.Fatal("'ALLOYDB_PROJECT' not set")
}
if AlloyDBLocation == "" {
t.Fatal("'ALLOYDB_REGION' not set")
}
if AlloyDBCluster == "" {
t.Fatal("'ALLOYDB_CLUSTER' not set")
}
if AlloyDBInstance == "" {
t.Fatal("'ALLOYDB_INSTANCE' not set")
}
if AlloyDBUser == "" {
t.Fatal("'ALLOYDB_USER' not set")
}
return map[string]string{
"project": AlloyDBProject,
"location": AlloyDBLocation,
"cluster": AlloyDBCluster,
"instance": AlloyDBInstance,
"user": AlloyDBUser,
}
}

func getAlloyDBToolsConfig() map[string]any {
return map[string]any{
"sources": map[string]any{
"alloydb-admin-source": map[string]any{
"type": "alloydb-admin",
},
},
"tools": map[string]any{
// Tool for RunAlloyDBToolGetTest
"my-simple-tool": map[string]any{
"type": "alloydb-list-clusters",
"source": "alloydb-admin-source",
"description": "Simple tool to test end to end functionality.",
},
// Tool for MCP test
"my-param-tool": map[string]any{
"type": "alloydb-list-clusters",
"source": "alloydb-admin-source",
"description": "Tool to list clusters",
},
// Tool for MCP test that fails
"my-fail-tool": map[string]any{
"type": "alloydb-list-clusters",
"source": "alloydb-admin-source",
"description": "Tool that will fail",
},
// AlloyDB specific tools
"alloydb-list-clusters": map[string]any{
"type": "alloydb-list-clusters",
"source": "alloydb-admin-source",
"description": "Lists all AlloyDB clusters in a given project and location.",
},
"alloydb-list-users": map[string]any{
"type": "alloydb-list-users",
"source": "alloydb-admin-source",
"description": "Lists all AlloyDB users within a specific cluster.",
},
"alloydb-list-instances": map[string]any{
"type": "alloydb-list-instances",
"source": "alloydb-admin-source",
"description": "Lists all AlloyDB instances within a specific cluster.",
},
"alloydb-get-cluster": map[string]any{
"type": "alloydb-get-cluster",
"source": "alloydb-admin-source",
"description": "Retrieves details of a specific AlloyDB cluster.",
},
"alloydb-get-instance": map[string]any{
"type": "alloydb-get-instance",
"source": "alloydb-admin-source",
"description": "Retrieves details of a specific AlloyDB instance.",
},
"alloydb-get-user": map[string]any{
"type": "alloydb-get-user",
"source": "alloydb-admin-source",
"description": "Retrieves details of a specific AlloyDB user.",
},
"alloydb-create-cluster": map[string]any{
"type": "alloydb-create-cluster",
"description": "create cluster",
"source": "alloydb-admin-source",
},
"alloydb-create-instance": map[string]any{
"type": "alloydb-create-instance",
"description": "create instance",
"source": "alloydb-admin-source",
},
"alloydb-create-user": map[string]any{
"type": "alloydb-create-user",
"description": "create user",
"source": "alloydb-admin-source",
},
},
}
}

func TestAlloyDBListTools(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()

toolsFile := getAlloyDBToolsConfig()
toolsFile := map[string]any{
"sources": map[string]any{
"alloydb-admin-source": map[string]any{
"type": "alloydb-admin",
},
},
"tools": map[string]any{
"alloydb-list-clusters": map[string]any{
"type": "alloydb-list-clusters",
"source": "alloydb-admin-source",
"description": "Lists all AlloyDB clusters in a given project and location.",
},
"alloydb-list-users": map[string]any{
"type": "alloydb-list-users",
"source": "alloydb-admin-source",
"description": "Lists all AlloyDB users within a specific cluster.",
},
},
}

// Start the toolbox server
cmd, cleanup, err := tests.StartCmd(ctx, toolsFile)
Expand Down Expand Up @@ -845,9 +973,8 @@ func TestAlloyDBCreateClusterMCP(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

args := []string{"--enable-api"}
toolsFile := getAlloyDBToolsConfig()
cmd, cleanupCmd, err := tests.StartCmd(ctx, toolsFile, args...)
cmd, cleanupCmd, err := tests.StartCmd(ctx, toolsFile)
if err != nil {
t.Fatalf("command initialization returned an error: %v", err)
}
Expand Down Expand Up @@ -942,9 +1069,8 @@ func TestAlloyDBCreateInstanceMCP(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

args := []string{"--enable-api"}
toolsFile := getAlloyDBToolsConfig()
cmd, cleanupCmd, err := tests.StartCmd(ctx, toolsFile, args...)
cmd, cleanupCmd, err := tests.StartCmd(ctx, toolsFile)
if err != nil {
t.Fatalf("command initialization returned an error: %v", err)
}
Expand Down Expand Up @@ -1049,9 +1175,8 @@ func TestAlloyDBCreateUserMCP(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

args := []string{"--enable-api"}
toolsFile := getAlloyDBToolsConfig()
cmd, cleanupCmd, err := tests.StartCmd(ctx, toolsFile, args...)
cmd, cleanupCmd, err := tests.StartCmd(ctx, toolsFile)
if err != nil {
t.Fatalf("command initialization returned an error: %v", err)
}
Expand Down
Loading
Loading