Skip to content

Commit e96838c

Browse files
authored
chore(cloud-sql): migrate mysql, postgres samples to new CI (#4055)
* chore(cloud-sql): migrate mysql, postgres samples to new CI * rename to match postgres version * acquireTimeout warns in mysql2, remove * mysql2 query returns [results, fields], so only return fields * remove unused test scripts * revert bot-suggested rename: would cause excessive region tag change
1 parent fd6ec65 commit e96838c

File tree

7 files changed

+36
-11
lines changed

7 files changed

+36
-11
lines changed

.github/config/nodejs-dev.jsonc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@
101101
"batch",
102102
"cloud-language",
103103
"cloud-sql/mysql/mysql",
104+
"cloud-sql/mysql/mysql2",
105+
"cloud-sql/postgres/knex",
104106
"cloud-tasks/snippets",
105107
"cloud-tasks/tutorial-gcf/app",
106108
"cloud-tasks/tutorial-gcf/function",

.github/config/nodejs-prod.jsonc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@
7777
// TODO: fix these
7878
"ai-platform/snippets", // PERMISSION_DENIED: Permission denied: Consumer 'projects/undefined' has been suspended.
7979
"automl", // (untested) FAILED_PRECONDITION: Google Cloud AutoML Natural Language was retired on March 15, 2024. Please migrate to Vertex AI instead
80-
"cloud-sql/mysql/mysql2", // (untested) Error: Cannot find module './connect-connector-with-iam-authn.js'
81-
"cloud-sql/postgres/knex", // (untested) CloudSQLConnectorError: Malformed instance connection name provided: expected format of "PROJECT:REGION:INSTANCE", got undefined
8280
"cloud-sql/sqlserver/mssql", // (untested) TypeError: The "config.server" property is required and must be of type string.
8381
"cloud-sql/sqlserver/tedious", // (untested) TypeError: The "config.server" property is required and must be of type string.
8482
"compute", // GoogleError: The resource 'projects/long-door-651/zones/us-central1-a/disks/disk-from-pool-name' was not found

cloud-sql/mysql/mysql2/ci-setup.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"env": {
3+
"INSTANCE_HOST": "127.0.0.1",
4+
"INSTANCE_CONNECTION_NAME": "nodejs-docs-samples-tests:us-central1:mysql-ci",
5+
"UNIX_SOCKET_DIR": "tmp/cloudsql",
6+
"CLOUD_SQL_CONNECTION_NAME": "$INSTANCE_CONNECTION_NAME",
7+
"INSTANCE_UNIX_SOCKET": "$UNIX_SOCKET_DIR/$INSTANCE_CONNECTION_NAME",
8+
"DB_NAME": "kokoro_ci",
9+
"DB_USER": "kokoro_ci"
10+
},
11+
"secrets": {
12+
"DB_PASS": "nodejs-docs-samples-tests/nodejs-docs-samples-sql-password"
13+
}
14+
}

cloud-sql/mysql/mysql2/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
'use strict';
1616

1717
const express = require('express');
18-
const createConnectorIAMAuthnPool = require('./connect-connector-with-iam-authn.js');
18+
const createConnectorIAMAuthnPool = require('./connect-connector-auto-iam-authn.js');
1919
const createConnectorPool = require('./connect-connector.js');
2020
const createTcpPool = require('./connect-tcp.js');
2121
const createUnixSocketPool = require('./connect-unix.js');
@@ -65,9 +65,7 @@ const createPool = async () => {
6565
// 'connectTimeout' is the maximum number of milliseconds before a timeout
6666
// occurs during the initial connection to the database.
6767
connectTimeout: 10000, // 10 seconds
68-
// 'acquireTimeout' is the maximum number of milliseconds to wait when
69-
// checking out a connection from the pool before a timeout error occurs.
70-
acquireTimeout: 10000, // 10 seconds
68+
// 'acquireTimeout' is currently unsupported by mysql2
7169
// 'waitForConnections' determines the pool's action when no connections are
7270
// free. If true, the request will queued and a connection will be presented
7371
// when ready. If false, the pool will call back with an error.
@@ -172,7 +170,7 @@ const httpGet = app.get('/', async (req, res) => {
172170

173171
// Run queries concurrently, and wait for them to complete
174172
// This is faster than await-ing each query object as it is created
175-
const recentVotes = await recentVotesQuery;
173+
const [recentVotes] = await recentVotesQuery; // Return only the results, not the field metadata
176174
const [tabsVotes] = await tabsQuery;
177175
const [spacesVotes] = await spacesQuery;
178176

cloud-sql/mysql/mysql2/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
"scripts": {
1515
"start": "node server/server.js",
1616
"system-test": "c8 mocha -p -j 2 test/server.test.js --timeout=60000 --exit",
17-
"system-test-tcp": "c8 mocha -p -j 2 test/server-unix.test.js --timeout=60000 --exit",
18-
"system-test-unix": "c8 mocha -p -j 2 test/server-unix.test.js --timeout=60000 --exit",
19-
"test": "npm run system-test && npm run system-test-tcp && npm run system-test-unix"
17+
"test": "npm run system-test"
2018
},
2119
"dependencies": {
2220
"@google-cloud/cloud-sql-connector": "^1.0.0",

cloud-sql/postgres/knex/ci-setup.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"env": {
3+
"INSTANCE_HOST": "127.0.0.1",
4+
"INSTANCE_CONNECTION_NAME": "nodejs-docs-samples-tests:us-central1:postgres-ci",
5+
"UNIX_SOCKET_DIR": "tmp/cloudsql",
6+
"CLOUD_SQL_CONNECTION_NAME": "$INSTANCE_CONNECTION_NAME",
7+
"INSTANCE_UNIX_SOCKET": "$UNIX_SOCKET_DIR/$INSTANCE_CONNECTION_NAME",
8+
"DB_NAME": "kokoro_ci",
9+
"DB_USER": "kokoro_ci"
10+
},
11+
"secrets": {
12+
"DB_PASS": "nodejs-docs-samples-tests/nodejs-docs-samples-sql-password"
13+
}
14+
}

cloud-sql/postgres/knex/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
},
1515
"scripts": {
1616
"start": "node server/server.js",
17+
"proxy": "$GITHUB_WORKSPACE/.github/workflows/utils/sql-proxy.sh",
1718
"start-proxy": "! pgrep cloud_sql_proxy > /dev/null && cloud_sql_proxy -dir=/cloudsql -instances=$INSTANCE_CONNECTION_NAME &",
18-
"test": "c8 mocha -p -j 2 test/*.test.js --timeout=60000 --exit"
19+
"test": "npm run proxy -- c8 mocha -p -j 2 test/*.test.js --timeout=60000 --exit"
1920
},
2021
"dependencies": {
2122
"@google-cloud/cloud-sql-connector": "^1.0.0",

0 commit comments

Comments
 (0)