Skip to content

Commit

Permalink
test: cleanup logic causes errors (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe authored and Ace Nassri committed Nov 21, 2022
1 parent c4b1156 commit 57a6ffa
Showing 1 changed file with 37 additions and 27 deletions.
64 changes: 37 additions & 27 deletions compute/test/samples.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,50 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});

const compute = new Compute();

describe('quickstart', () => {
const name = `gcloud-ubuntu-${uuid.v4().split('-')[0]}`;
after(async () => deleteVM(name));
it('should run the quickstart', async () => {
const output = execSync(`node quickstart ${name}`);
assert.match(output, /Virtual machine created!/);
describe('samples', () => {
describe('quickstart', () => {
const name = `gcloud-ubuntu-${uuid.v4().split('-')[0]}`;
after(async () => deleteVM(name));
it('should run the quickstart', () => {
const output = execSync(`node quickstart ${name}`);
assert.match(output, /Virtual machine created!/);
});
});
});

describe('lifecycle', async () => {
const name = `gcloud-ubuntu-${uuid.v4().split('-')[0]}`;
describe('lifecycle', () => {
const name = `gcloud-ubuntu-${uuid.v4().split('-')[0]}`;

it('should create a VM', async () => {
const output = execSync(`node createVM ${name}`);
assert.match(output, /Virtual machine created!/);
});
it('should create a VM', () => {
const output = execSync(`node createVM ${name}`);
assert.match(output, /Virtual machine created!/);
});

it('should list the VMs', async () => {
const output = execSync('node listVMs');
assert.match(output, /Found \d+ VMs!/);
});
it('should list the VMs', () => {
const output = execSync('node listVMs');
assert.match(output, /Found \d+ VMs!/);
});

it('should delete the VM', async () => {
const output = execSync(`node deleteVM ${name}`);
assert.match(output, /VM deleted!/);
it('should delete the VM', () => {
const output = execSync(`node deleteVM ${name}`);
assert.match(output, /VM deleted!/);
});
});
});

describe('start-up script', async () => {
const name = `gcloud-apache-${uuid.v4().split('-')[0]}`;
after(async () => deleteVM(name));
it('should create vm with startup script', async () => {
const output = execSync(`node startupScript ${name}`);
assert.match(output, /created succesfully/);
describe('start-up script', () => {
const name = `gcloud-apache-${uuid.v4().split('-')[0]}`;
after(async () => deleteVM(name));
it('should create vm with startup script', function(done) {
this.timeout(280000);
this.retries(3);
const {spawn} = require('child_process');
const startupScript = spawn('node', ['startupScript', name], {
stdio: 'inherit',
});
startupScript.on('close', code => {
assert.strictEqual(code, 0);
return done();
});
});
});
});

Expand Down

0 comments on commit 57a6ffa

Please sign in to comment.