diff --git a/compute/test/createComputeHyperdisk.test.js b/compute/test/createComputeHyperdisk.test.js index 252ce9ccc06..ac88369666a 100644 --- a/compute/test/createComputeHyperdisk.test.js +++ b/compute/test/createComputeHyperdisk.test.js @@ -21,7 +21,6 @@ const {assert} = require('chai'); const {describe, it} = require('mocha'); const cp = require('child_process'); const {DisksClient} = require('@google-cloud/compute').v1; -const {deleteDisk} = require('./util'); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); const cwd = path.join(__dirname, '..'); @@ -37,7 +36,11 @@ describe('Create compute hyperdisk', async () => { }); after(async () => { - await deleteDisk(disksClient, projectId, zone, diskName); + await disksClient.delete({ + project: projectId, + disk: diskName, + zone, + }); }); it('should create a new hyperdisk', () => { diff --git a/compute/test/createComputeHyperdiskFromPool.test.js b/compute/test/createComputeHyperdiskFromPool.test.js index ccf83de9580..fa203ebec1b 100644 --- a/compute/test/createComputeHyperdiskFromPool.test.js +++ b/compute/test/createComputeHyperdiskFromPool.test.js @@ -20,8 +20,7 @@ const path = require('path'); const {assert} = require('chai'); const {describe, it} = require('mocha'); const cp = require('child_process'); -const {DisksClient} = require('@google-cloud/compute').v1; -const {deleteDisk} = require('./util'); +const {DisksClient, StoragePoolsClient} = require('@google-cloud/compute').v1; const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); const cwd = path.join(__dirname, '..'); @@ -31,14 +30,27 @@ describe('Create compute hyperdisk from pool', async () => { const zone = 'europe-central2-b'; const storagePoolName = 'storage-pool-name'; const disksClient = new DisksClient(); + const storagePoolsClient = new StoragePoolsClient(); let projectId; before(async () => { projectId = await disksClient.getProjectId(); + execSync('node ./disks/createComputeHyperdiskPool.js', { + cwd, + }); }); after(async () => { - await deleteDisk(disksClient, projectId, zone, diskName); + await disksClient.delete({ + project: projectId, + disk: diskName, + zone, + }); + await storagePoolsClient.delete({ + project: projectId, + storagePool: storagePoolName, + zone, + }); }); it('should create a new hyperdisk from pool', () => { diff --git a/compute/test/createComputeHyperdiskPool.test.js b/compute/test/createComputeHyperdiskPool.test.js index 61c052af5b2..eec28d7394d 100644 --- a/compute/test/createComputeHyperdiskPool.test.js +++ b/compute/test/createComputeHyperdiskPool.test.js @@ -24,24 +24,11 @@ const {StoragePoolsClient} = require('@google-cloud/compute').v1; const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); const cwd = path.join(__dirname, '..'); -const storagePoolsClient = new StoragePoolsClient(); - -async function deleteStoragePool(projectId, zone, storagePoolName) { - try { - await storagePoolsClient.delete({ - project: projectId, - storagePool: storagePoolName, - zone, - }); - } catch (err) { - console.error('Deleting storage pool failed: ', err); - throw new Error(err); - } -} describe('Create compute hyperdisk pool', async () => { const storagePoolName = 'storage-pool-name'; const zone = 'us-central1-a'; + const storagePoolsClient = new StoragePoolsClient(); let projectId; before(async () => { @@ -49,7 +36,11 @@ describe('Create compute hyperdisk pool', async () => { }); after(async () => { - await deleteStoragePool(projectId, zone, storagePoolName); + await storagePoolsClient.delete({ + project: projectId, + storagePool: storagePoolName, + zone, + }); }); it('should create a new storage pool', () => { diff --git a/compute/test/util.js b/compute/test/util.js index 9eb3e87f875..d192788ac1f 100644 --- a/compute/test/util.js +++ b/compute/test/util.js @@ -82,22 +82,8 @@ async function deleteInstance(zone, instanceName) { } } -async function deleteDisk(disksClient, projectId, zone, diskName) { - try { - await disksClient.delete({ - project: projectId, - disk: diskName, - zone, - }); - } catch (err) { - console.error('Deleting disk failed: ', err); - throw new Error(err); - } -} - module.exports = { generateTestId, getStaleVMInstances, deleteInstance, - deleteDisk, };