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
6 changes: 6 additions & 0 deletions .ci/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ steps:
"POSTGRES_CUSTOMER_CAS_CONNECTION_NAME",
"POSTGRES_CUSTOMER_CAS_PASS",
"POSTGRES_CUSTOMER_CAS_DOMAIN_NAME",
"POSTGRES_MCP_CONNECTION_NAME",
"POSTGRES_MCP_PASS",
"SQLSERVER_CONNECTION_NAME",
"SQLSERVER_USER",
"SQLSERVER_PASS",
Expand Down Expand Up @@ -90,6 +92,10 @@ availableSecrets:
env: "POSTGRES_CUSTOMER_CAS_PASS"
- versionName: "projects/$PROJECT_ID/secrets/POSTGRES_CUSTOMER_CAS_DOMAIN_NAME/versions/latest"
env: "POSTGRES_CUSTOMER_CAS_DOMAIN_NAME"
- versionName: "projects/$PROJECT_ID/secrets/POSTGRES_MCP_CONNECTION_NAME/versions/latest"
env: "POSTGRES_MCP_CONNECTION_NAME"
- versionName: "projects/$PROJECT_ID/secrets/POSTGRES_MCP_PASS/versions/latest"
env: "POSTGRES_MCP_PASS"
- versionName: "projects/$PROJECT_ID/secrets/SQLSERVER_CONNECTION_NAME/versions/latest"
env: "SQLSERVER_CONNECTION_NAME"
- versionName: "projects/$PROJECT_ID/secrets/SQLSERVER_USER/versions/latest"
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ jobs:
POSTGRES_CUSTOMER_CAS_CONNECTION_NAME:${{ vars.GOOGLE_CLOUD_PROJECT }}/POSTGRES_CUSTOMER_CAS_CONNECTION_NAME
POSTGRES_CUSTOMER_CAS_PASS:${{ vars.GOOGLE_CLOUD_PROJECT }}/POSTGRES_CUSTOMER_CAS_PASS
POSTGRES_CUSTOMER_CAS_DOMAIN_NAME:${{ vars.GOOGLE_CLOUD_PROJECT }}/POSTGRES_CUSTOMER_CAS_DOMAIN_NAME
POSTGRES_MCP_CONNECTION_NAME:${{ vars.GOOGLE_CLOUD_PROJECT }}/POSTGRES_MCP_CONNECTION_NAME
POSTGRES_MCP_PASS:${{ vars.GOOGLE_CLOUD_PROJECT }}/POSTGRES_MCP_PASS
SQLSERVER_CONNECTION_NAME:${{ vars.GOOGLE_CLOUD_PROJECT }}/SQLSERVER_CONNECTION_NAME
SQLSERVER_USER:${{ vars.GOOGLE_CLOUD_PROJECT }}/SQLSERVER_USER
SQLSERVER_PASS:${{ vars.GOOGLE_CLOUD_PROJECT }}/SQLSERVER_PASS
Expand Down Expand Up @@ -129,6 +131,8 @@ jobs:
POSTGRES_CUSTOMER_CAS_CONNECTION_NAME: "${{ steps.secrets.outputs.POSTGRES_CUSTOMER_CAS_CONNECTION_NAME }}"
POSTGRES_CUSTOMER_CAS_PASS: "${{ steps.secrets.outputs.POSTGRES_CUSTOMER_CAS_PASS }}"
POSTGRES_CUSTOMER_CAS_DOMAIN_NAME: "${{ steps.secrets.outputs.POSTGRES_CUSTOMER_CAS_DOMAIN_NAME }}"
POSTGRES_MCP_CONNECTION_NAME: "${{ steps.secrets.outputs.POSTGRES_MCP_CONNECTION_NAME }}"
POSTGRES_MCP_PASS: "${{ steps.secrets.outputs.POSTGRES_MCP_PASS }}"
SQLSERVER_CONNECTION_NAME: "${{ steps.secrets.outputs.SQLSERVER_CONNECTION_NAME }}"
SQLSERVER_USER: "${{ steps.secrets.outputs.SQLSERVER_USER }}"
SQLSERVER_PASS: "${{ steps.secrets.outputs.SQLSERVER_PASS }}"
Expand Down
24 changes: 24 additions & 0 deletions tests/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ var (
postgresPass = flag.String("postgres_pass", os.Getenv("POSTGRES_PASS"), "Password for the database user; be careful when entering a password on the command line (it may go into your terminal's history).")
postgresDB = flag.String("postgres_db", os.Getenv("POSTGRES_DB"), "Name of the database to connect to.")
postgresIAMUser = flag.String("postgres_user_iam", os.Getenv("POSTGRES_USER_IAM"), "Name of database user configured with IAM DB Authentication.")
postgresMCPConnName = flag.String("postgres_mcp_conn_name", os.Getenv("POSTGRES_MCP_CONNECTION_NAME"), "Cloud SQL Postgres instance connection name for a managed instance, in the form of 'project:region:instance'.")
postgresMCPPass = flag.String("postgres_mcp_pass", os.Getenv("POSTGRES_MCP_PASS"), "Password for the managed instance database user; be careful when entering a password on the command line (it may go into your terminal's history).")
postgresCustomerCASConnName = flag.String("postgres_customer_cas_conn_name", os.Getenv("POSTGRES_CUSTOMER_CAS_CONNECTION_NAME"), "Cloud SQL Postgres instance connection name for a customer CAS enabled instance, in the form of 'project:region:instance'.")
postgresCustomerCASPass = flag.String("postgres_customer_cas_pass", os.Getenv("POSTGRES_CUSTOMER_CAS_PASS"), "Password for the customer CAS instance database user; be careful when entering a password on the command line (it may go into your terminal's history).")
postgresCustomerCASDomain = flag.String("postgres_customer_cas_domain", os.Getenv("POSTGRES_CUSTOMER_CAS_DOMAIN_NAME"), "Valid DNS domain name for the customer CAS instance.")
Expand Down Expand Up @@ -90,6 +92,28 @@ func TestPostgresUnix(t *testing.T) {
proxyConnTest(t, args, "pgx", dsn)
}

func TestPostgresMCPUnix(t *testing.T) {
if testing.Short() {
t.Skip("skipping Postgres integration tests")
}
requirePostgresVars(t)
tmpDir, cleanup := createTempDir(t)
defer cleanup()

dsn := fmt.Sprintf("host=%s user=%s password=%s database=%s sslmode=disable",
// re-use utility function to determine the Unix address in a
// Windows-friendly way.
proxy.UnixAddress(tmpDir, *postgresMCPConnName),
*postgresUser, *postgresMCPPass, *postgresDB)

// Prepare the initial arguments
args := []string{"--unix-socket", tmpDir, *postgresMCPConnName}
// Add the IP type flag using the helper
args = AddIPTypeFlag(args)
// Run the test
proxyConnTest(t, args, "pgx", dsn)
}

func createTempDir(t *testing.T) (string, func()) {
testDir, err := os.MkdirTemp("", "*")
if err != nil {
Expand Down
Loading