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/.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] diff --git a/compute/ci-setup.json b/compute/ci-setup.json new file mode 100644 index 0000000000..413822f834 --- /dev/null +++ b/compute/ci-setup.json @@ -0,0 +1,5 @@ + +{ + "_justification": "Compute tests take longer to run", + "timeout-minutes": 120 +} diff --git a/compute/package.json b/compute/package.json index 131aac53f3..f842e6d18b 100644 --- a/compute/package.json +++ b/compute/package.json @@ -11,7 +11,8 @@ "*.js" ], "scripts": { - "test": "c8 mocha -p -j 2 test --timeout 1200000" + "test-only": "mocha --timeout 1000000 -g", + "test": "c8 mocha -p -j 4 test --timeout 1100000" }, "dependencies": { "@google-cloud/compute": "^4.0.0", diff --git a/compute/test/createInstanceReplicatedBootDisk.test.js b/compute/test/createInstanceReplicatedBootDisk.test.js index 02dbf9f17d..6776b95dd7 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'); @@ -118,28 +118,15 @@ 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 +139,15 @@ describe('Create compute instance with replicated boot disk', async () => { `Instance: ${vmName} with replicated boot disk created.` ) ); + + // 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) + ) + ); }); }); diff --git a/compute/test/replicatedDisk.test.js b/compute/test/replicatedDisk.test.js index d782ec986e..3365facc08 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,20 +57,10 @@ 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}`, { @@ -78,10 +68,10 @@ describe('Create compute regional replicated disk', async () => { } ); + console.log(`replicatedDisk.tests.js: Disk ${diskName} created.`); + 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,17 +80,27 @@ describe('Create compute regional replicated disk', async () => { } ); - const response = execSync( + console.log(`replicatedDisk.tests.js: Instance ${vmName} created.`); + + const responseAttach = execSync( `node ./disks/attachRegionalDisk.js ${diskName} ${region} ${vmName} ${zone1}`, { cwd, } ); + console.log(`replicatedDisk.tests.js: Disk ${diskName} attached to ${vmName}.`); + 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); }); });