From 36671f7dcd86446f06ca66102fdd58456f38b3c0 Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Wed, 2 Apr 2025 11:57:33 +1100 Subject: [PATCH 01/15] chore(compute): migrate to new CI --- .github/config/nodejs-dev.jsonc | 1 + .github/config/nodejs-prod.jsonc | 1 - compute/ci-setup.json | 0 3 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 compute/ci-setup.json diff --git a/.github/config/nodejs-dev.jsonc b/.github/config/nodejs-dev.jsonc index b2192a0525..df42f22841 100644 --- a/.github/config/nodejs-dev.jsonc +++ b/.github/config/nodejs-dev.jsonc @@ -109,6 +109,7 @@ "cloudbuild", "composer", "composer/functions/composer-storage-trigger", + "compute", "contact-center-insights", "container", "container-analysis/snippets", diff --git a/.github/config/nodejs-prod.jsonc b/.github/config/nodejs-prod.jsonc index da7625698a..1d2a0e755a 100644 --- a/.github/config/nodejs-prod.jsonc +++ b/.github/config/nodejs-prod.jsonc @@ -79,7 +79,6 @@ "automl", // (untested) FAILED_PRECONDITION: Google Cloud AutoML Natural Language was retired on March 15, 2024. Please migrate to Vertex AI instead "cloud-sql/sqlserver/mssql", // (untested) TypeError: The "config.server" property is required and must be of type string. "cloud-sql/sqlserver/tedious", // (untested) TypeError: The "config.server" property is required and must be of type string. - "compute", // GoogleError: The resource 'projects/long-door-651/zones/us-central1-a/disks/disk-from-pool-name' was not found "dataproc", // GoogleError: Error submitting create cluster request: Multiple validation errors "datastore/functions", // [ERR_REQUIRE_ESM]: require() of ES Module "dialogflow-cx", // NOT_FOUND: com.google.apps.framework.request.NotFoundException: Agent 'undefined' does not exist diff --git a/compute/ci-setup.json b/compute/ci-setup.json new file mode 100644 index 0000000000..e69de29bb2 From bdbfa20c6e0f8c915b4a4990e122085a465a4aae Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Wed, 2 Apr 2025 12:00:56 +1100 Subject: [PATCH 02/15] remove old workflow --- .github/workflows/compute.yaml | 52 ---------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 .github/workflows/compute.yaml diff --git a/.github/workflows/compute.yaml b/.github/workflows/compute.yaml deleted file mode 100644 index ceb504fe8e..0000000000 --- a/.github/workflows/compute.yaml +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright 2023 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: compute -on: - push: - branches: - - main - paths: - - 'compute/**' - - '.github/workflows/compute.yaml' - - '.github/workflows/test.yaml' - pull_request: - types: - - opened - - reopened - - synchronize - - labeled - paths: - - 'compute/**' - - '.github/workflows/compute.yaml' - - '.github/workflows/test.yaml' - schedule: - - cron: '0 0 * * 0' -jobs: - test: - permissions: - contents: 'read' - id-token: 'write' - if: github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' - uses: ./.github/workflows/test.yaml - with: - name: 'compute' - path: 'compute' - flakybot: - permissions: - contents: 'read' - id-token: 'write' - if: github.event_name == 'schedule' && always() # always() submits logs even if tests fail - uses: ./.github/workflows/flakybot.yaml - needs: [test] From d09a8de56e18329dcd9ca95e645a5aec10a77a06 Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Wed, 2 Apr 2025 12:50:21 +1100 Subject: [PATCH 03/15] force re-run (revert) --- compute/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compute/package.json b/compute/package.json index 131aac53f3..a2dbc1284b 100644 --- a/compute/package.json +++ b/compute/package.json @@ -11,7 +11,7 @@ "*.js" ], "scripts": { - "test": "c8 mocha -p -j 2 test --timeout 1200000" + "test": "c8 mocha -p -j 2 test --timeout 1100000" }, "dependencies": { "@google-cloud/compute": "^4.0.0", From b732af1416b7a214b3cd20587e05c04969cab75d Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Wed, 2 Apr 2025 13:03:12 +1100 Subject: [PATCH 04/15] debug: affected panic --- .github/workflows/custard-ci.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/custard-ci.yaml b/.github/workflows/custard-ci.yaml index 2e85d1218c..0730f6caba 100644 --- a/.github/workflows/custard-ci.yaml +++ b/.github/workflows/custard-ci.yaml @@ -56,9 +56,13 @@ jobs: - name: Find Node.js affected packages id: nodejs run: | + echo "-> run affected" echo "paths=$(./cloud-samples-tools/bin/custard affected .github/config/nodejs-prod.jsonc diffs.txt paths.txt)" >> $GITHUB_OUTPUT + echo "Status: $?" cat paths.txt + echo "-> run setup-files" echo "setups=$(./cloud-samples-tools/bin/custard setup-files .github/config/nodejs-prod.jsonc paths.txt)" >> $GITHUB_OUTPUT + echo "Status: $?" lint: needs: affected From 1805b8b4fa215282e7ea58b8b01a561a9573688a Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Wed, 2 Apr 2025 13:37:13 +1100 Subject: [PATCH 05/15] empty ci-setup.json != no config https://github.com/GoogleCloudPlatform/cloud-samples-tools/pull/31 --- compute/ci-setup.json | 1 + 1 file changed, 1 insertion(+) diff --git a/compute/ci-setup.json b/compute/ci-setup.json index e69de29bb2..0967ef424b 100644 --- a/compute/ci-setup.json +++ b/compute/ci-setup.json @@ -0,0 +1 @@ +{} From f23736f1ca3e95875014c13ce670a7a4ccfe656f Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Wed, 2 Apr 2025 13:43:19 +1100 Subject: [PATCH 06/15] remove debug --- .github/workflows/custard-ci.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/custard-ci.yaml b/.github/workflows/custard-ci.yaml index 0730f6caba..2e85d1218c 100644 --- a/.github/workflows/custard-ci.yaml +++ b/.github/workflows/custard-ci.yaml @@ -56,13 +56,9 @@ jobs: - name: Find Node.js affected packages id: nodejs run: | - echo "-> run affected" echo "paths=$(./cloud-samples-tools/bin/custard affected .github/config/nodejs-prod.jsonc diffs.txt paths.txt)" >> $GITHUB_OUTPUT - echo "Status: $?" cat paths.txt - echo "-> run setup-files" echo "setups=$(./cloud-samples-tools/bin/custard setup-files .github/config/nodejs-prod.jsonc paths.txt)" >> $GITHUB_OUTPUT - echo "Status: $?" lint: needs: affected From 0a6b420a2fecda4ab95e4e1c5033bb6473690d2a Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Wed, 2 Apr 2025 13:53:04 +1100 Subject: [PATCH 07/15] extend tests time --- compute/ci-setup.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compute/ci-setup.json b/compute/ci-setup.json index 0967ef424b..413822f834 100644 --- a/compute/ci-setup.json +++ b/compute/ci-setup.json @@ -1 +1,5 @@ -{} + +{ + "_justification": "Compute tests take longer to run", + "timeout-minutes": 120 +} From 82162c23c66884553b9428f65ba6d973e76c17fb Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Wed, 2 Apr 2025 15:44:12 +1100 Subject: [PATCH 08/15] try parallel --- compute/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compute/package.json b/compute/package.json index a2dbc1284b..a004aa3e38 100644 --- a/compute/package.json +++ b/compute/package.json @@ -11,7 +11,7 @@ "*.js" ], "scripts": { - "test": "c8 mocha -p -j 2 test --timeout 1100000" + "test": "c8 mocha -p -j 4 test --timeout 1100000" }, "dependencies": { "@google-cloud/compute": "^4.0.0", From 63e6cc3316e71d6cb4800a69c836c0f9d8134adc Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Fri, 4 Apr 2025 13:24:28 +1100 Subject: [PATCH 09/15] make failing tests more linear in a parallel world --- .../createInstanceReplicatedBootDisk.test.js | 28 +++++++++---------- compute/test/replicatedDisk.test.js | 25 +++++++---------- 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/compute/test/createInstanceReplicatedBootDisk.test.js b/compute/test/createInstanceReplicatedBootDisk.test.js index 02dbf9f17d..e15572d8e3 100644 --- a/compute/test/createInstanceReplicatedBootDisk.test.js +++ b/compute/test/createInstanceReplicatedBootDisk.test.js @@ -118,28 +118,16 @@ describe('Create compute instance with replicated boot disk', async () => { let projectId; let diskSnapshotLink; - before(async () => { + it('should create an instance with replicated boot disk', async () => { + + // before const instancesClient = new computeLib.InstancesClient(); projectId = await instancesClient.getProjectId(); diskSnapshotLink = `projects/${projectId}/global/snapshots/${snapshotName}`; await createDisk(projectId, zone1, diskName); await createDiskSnapshot(projectId, zone1, diskName, snapshotName); - }); - after(async () => { - // Cleanup resources - const instances = await getStaleVMInstances(); - await Promise.all( - instances.map(instance => - deleteInstance(instance.zone, instance.instanceName) - ) - ); - await deleteDiskSnapshot(projectId, snapshotName); - await deleteDisk(projectId, zone1, diskName); - }); - - it('should create an instance with replicated boot disk', () => { const response = execSync( `node ./instances/create-start-instance/createInstanceReplicatedBootDisk.js ${zone1} ${zone2} ${vmName} ${diskSnapshotLink}`, { @@ -152,5 +140,15 @@ describe('Create compute instance with replicated boot disk', async () => { `Instance: ${vmName} with replicated boot disk created.` ) ); + + // after Cleanup resources + const instances = await getStaleVMInstances(); + await Promise.all( + instances.map(instance => + deleteInstance(instance.zone, instance.instanceName) + ) + ); + await deleteDiskSnapshot(projectId, snapshotName); + await deleteDisk(projectId, zone1, diskName); }); }); diff --git a/compute/test/replicatedDisk.test.js b/compute/test/replicatedDisk.test.js index d782ec986e..0e194a5a97 100644 --- a/compute/test/replicatedDisk.test.js +++ b/compute/test/replicatedDisk.test.js @@ -57,20 +57,11 @@ describe('Create compute regional replicated disk', async () => { const zone2 = `${region}-b`; let projectId; - before(async () => { + + it('should create a regional replicated disk and attach to vm', async () => { const instancesClient = new computeLib.InstancesClient(); projectId = await instancesClient.getProjectId(); - }); - - after(async () => { - // Cleanup resources - execSync(`node ./deleteInstance.js ${projectId} ${zone1} ${vmName}`, { - cwd, - }); - await deleteDisk(projectId, region, diskName); - }); - it('should create a regional replicated disk', () => { const response = execSync( `node ./disks/createRegionalReplicatedDisk.js ${diskName} ${region} ${zone1} ${zone2}`, { @@ -79,9 +70,7 @@ describe('Create compute regional replicated disk', async () => { ); assert(response.includes(`Regional replicated disk: ${diskName} created.`)); - }); - it('should attach replicated disk to vm', () => { // Create VM, where replicated disk will be attached. execSync( `node ./createInstance.js ${projectId} ${zone1} ${vmName} e2-small`, @@ -90,7 +79,7 @@ describe('Create compute regional replicated disk', async () => { } ); - const response = execSync( + const responseAttach = execSync( `node ./disks/attachRegionalDisk.js ${diskName} ${region} ${vmName} ${zone1}`, { cwd, @@ -98,9 +87,15 @@ describe('Create compute regional replicated disk', async () => { ); assert( - response.includes( + responseAttach.includes( `Replicated disk: ${diskName} attached to VM: ${vmName}.` ) ); + + // Cleanup resources + execSync(`node ./deleteInstance.js ${projectId} ${zone1} ${vmName}`, { + cwd, + }); + await deleteDisk(projectId, region, diskName); }); }); From b9e2adfef45788a2c97b67f7122558a53bfbd5dd Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Fri, 4 Apr 2025 14:57:37 +1100 Subject: [PATCH 10/15] lint --- compute/test/createInstanceReplicatedBootDisk.test.js | 3 +-- compute/test/replicatedDisk.test.js | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/compute/test/createInstanceReplicatedBootDisk.test.js b/compute/test/createInstanceReplicatedBootDisk.test.js index e15572d8e3..321e840519 100644 --- a/compute/test/createInstanceReplicatedBootDisk.test.js +++ b/compute/test/createInstanceReplicatedBootDisk.test.js @@ -19,7 +19,7 @@ const path = require('path'); const assert = require('node:assert/strict'); const uuid = require('uuid'); -const {after, before, describe, it} = require('mocha'); +const {describe, it} = require('mocha'); const cp = require('child_process'); const computeLib = require('@google-cloud/compute'); const {getStaleVMInstances, deleteInstance} = require('./util'); @@ -119,7 +119,6 @@ describe('Create compute instance with replicated boot disk', async () => { let diskSnapshotLink; it('should create an instance with replicated boot disk', async () => { - // before const instancesClient = new computeLib.InstancesClient(); projectId = await instancesClient.getProjectId(); diff --git a/compute/test/replicatedDisk.test.js b/compute/test/replicatedDisk.test.js index 0e194a5a97..bd6fcb45f4 100644 --- a/compute/test/replicatedDisk.test.js +++ b/compute/test/replicatedDisk.test.js @@ -19,7 +19,7 @@ const path = require('path'); const assert = require('node:assert/strict'); const uuid = require('uuid'); -const {after, before, describe, it} = require('mocha'); +const {describe, it} = require('mocha'); const cp = require('child_process'); const computeLib = require('@google-cloud/compute'); @@ -57,7 +57,6 @@ describe('Create compute regional replicated disk', async () => { const zone2 = `${region}-b`; let projectId; - it('should create a regional replicated disk and attach to vm', async () => { const instancesClient = new computeLib.InstancesClient(); projectId = await instancesClient.getProjectId(); From 7be6f982c6d1b82cc888c534a20010db0cd533ad Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Fri, 4 Apr 2025 15:07:36 +1100 Subject: [PATCH 11/15] delete order might be important --- compute/package.json | 1 + compute/test/createInstanceReplicatedBootDisk.test.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compute/package.json b/compute/package.json index a004aa3e38..f842e6d18b 100644 --- a/compute/package.json +++ b/compute/package.json @@ -11,6 +11,7 @@ "*.js" ], "scripts": { + "test-only": "mocha --timeout 1000000 -g", "test": "c8 mocha -p -j 4 test --timeout 1100000" }, "dependencies": { diff --git a/compute/test/createInstanceReplicatedBootDisk.test.js b/compute/test/createInstanceReplicatedBootDisk.test.js index 321e840519..6776b95dd7 100644 --- a/compute/test/createInstanceReplicatedBootDisk.test.js +++ b/compute/test/createInstanceReplicatedBootDisk.test.js @@ -141,13 +141,13 @@ describe('Create compute instance with replicated boot disk', async () => { ); // after Cleanup resources + await deleteDiskSnapshot(projectId, snapshotName); + await deleteDisk(projectId, zone1, diskName); const instances = await getStaleVMInstances(); await Promise.all( instances.map(instance => deleteInstance(instance.zone, instance.instanceName) ) ); - await deleteDiskSnapshot(projectId, snapshotName); - await deleteDisk(projectId, zone1, diskName); }); }); From df15ca2efe259217e35717b34e75c8e6b00a4ea3 Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Fri, 4 Apr 2025 15:26:01 +1100 Subject: [PATCH 12/15] debug why broke --- compute/test/replicatedDisk.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compute/test/replicatedDisk.test.js b/compute/test/replicatedDisk.test.js index bd6fcb45f4..87b3939724 100644 --- a/compute/test/replicatedDisk.test.js +++ b/compute/test/replicatedDisk.test.js @@ -68,6 +68,8 @@ describe('Create compute regional replicated disk', async () => { } ); + console.log(`replicatedDisk.tests.js: Disk ${diskName} created.`) + assert(response.includes(`Regional replicated disk: ${diskName} created.`)); // Create VM, where replicated disk will be attached. @@ -78,6 +80,8 @@ describe('Create compute regional replicated disk', async () => { } ); + console.log(`replicatedDisk.tests.js: Instance ${vmName} created.`) + const responseAttach = execSync( `node ./disks/attachRegionalDisk.js ${diskName} ${region} ${vmName} ${zone1}`, { @@ -85,6 +89,8 @@ describe('Create compute regional replicated disk', async () => { } ); + console.log(`replicatedDisk.tests.js: Disk ${diskName} attached to ${vmName}.`) + assert( responseAttach.includes( `Replicated disk: ${diskName} attached to VM: ${vmName}.` From 57f3a061db5c4029c4b4068d726e689a0b2b719d Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Fri, 4 Apr 2025 15:26:22 +1100 Subject: [PATCH 13/15] increase job parallel --- compute/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compute/package.json b/compute/package.json index f842e6d18b..56002c2cf5 100644 --- a/compute/package.json +++ b/compute/package.json @@ -12,7 +12,7 @@ ], "scripts": { "test-only": "mocha --timeout 1000000 -g", - "test": "c8 mocha -p -j 4 test --timeout 1100000" + "test": "c8 mocha -p -j 8 test --timeout 1100000" }, "dependencies": { "@google-cloud/compute": "^4.0.0", From d7c3bb55dc049e7a07aa7b5f94c20bf458bd981c Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Fri, 4 Apr 2025 15:44:13 +1100 Subject: [PATCH 14/15] lint --- compute/test/replicatedDisk.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compute/test/replicatedDisk.test.js b/compute/test/replicatedDisk.test.js index 87b3939724..3365facc08 100644 --- a/compute/test/replicatedDisk.test.js +++ b/compute/test/replicatedDisk.test.js @@ -68,7 +68,7 @@ describe('Create compute regional replicated disk', async () => { } ); - console.log(`replicatedDisk.tests.js: Disk ${diskName} created.`) + console.log(`replicatedDisk.tests.js: Disk ${diskName} created.`); assert(response.includes(`Regional replicated disk: ${diskName} created.`)); @@ -80,7 +80,7 @@ describe('Create compute regional replicated disk', async () => { } ); - console.log(`replicatedDisk.tests.js: Instance ${vmName} created.`) + console.log(`replicatedDisk.tests.js: Instance ${vmName} created.`); const responseAttach = execSync( `node ./disks/attachRegionalDisk.js ${diskName} ${region} ${vmName} ${zone1}`, @@ -89,7 +89,7 @@ describe('Create compute regional replicated disk', async () => { } ); - console.log(`replicatedDisk.tests.js: Disk ${diskName} attached to ${vmName}.`) + console.log(`replicatedDisk.tests.js: Disk ${diskName} attached to ${vmName}.`); assert( responseAttach.includes( From 68bcb0f15148020ffa8972308df711194e2def4d Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Fri, 4 Apr 2025 16:03:16 +1100 Subject: [PATCH 15/15] more parallel, more problems --- compute/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compute/package.json b/compute/package.json index 56002c2cf5..f842e6d18b 100644 --- a/compute/package.json +++ b/compute/package.json @@ -12,7 +12,7 @@ ], "scripts": { "test-only": "mocha --timeout 1000000 -g", - "test": "c8 mocha -p -j 8 test --timeout 1100000" + "test": "c8 mocha -p -j 4 test --timeout 1100000" }, "dependencies": { "@google-cloud/compute": "^4.0.0",