Skip to content

Commit 57a6ffa

Browse files
Benjamin E. CoeAce Nassri
authored andcommitted
test: cleanup logic causes errors (#452)
1 parent c4b1156 commit 57a6ffa

1 file changed

Lines changed: 37 additions & 27 deletions

File tree

compute/test/samples.test.js

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,40 +23,50 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
2323

2424
const compute = new Compute();
2525

26-
describe('quickstart', () => {
27-
const name = `gcloud-ubuntu-${uuid.v4().split('-')[0]}`;
28-
after(async () => deleteVM(name));
29-
it('should run the quickstart', async () => {
30-
const output = execSync(`node quickstart ${name}`);
31-
assert.match(output, /Virtual machine created!/);
26+
describe('samples', () => {
27+
describe('quickstart', () => {
28+
const name = `gcloud-ubuntu-${uuid.v4().split('-')[0]}`;
29+
after(async () => deleteVM(name));
30+
it('should run the quickstart', () => {
31+
const output = execSync(`node quickstart ${name}`);
32+
assert.match(output, /Virtual machine created!/);
33+
});
3234
});
33-
});
3435

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

38-
it('should create a VM', async () => {
39-
const output = execSync(`node createVM ${name}`);
40-
assert.match(output, /Virtual machine created!/);
41-
});
39+
it('should create a VM', () => {
40+
const output = execSync(`node createVM ${name}`);
41+
assert.match(output, /Virtual machine created!/);
42+
});
4243

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

48-
it('should delete the VM', async () => {
49-
const output = execSync(`node deleteVM ${name}`);
50-
assert.match(output, /VM deleted!/);
49+
it('should delete the VM', () => {
50+
const output = execSync(`node deleteVM ${name}`);
51+
assert.match(output, /VM deleted!/);
52+
});
5153
});
52-
});
5354

54-
describe('start-up script', async () => {
55-
const name = `gcloud-apache-${uuid.v4().split('-')[0]}`;
56-
after(async () => deleteVM(name));
57-
it('should create vm with startup script', async () => {
58-
const output = execSync(`node startupScript ${name}`);
59-
assert.match(output, /created succesfully/);
55+
describe('start-up script', () => {
56+
const name = `gcloud-apache-${uuid.v4().split('-')[0]}`;
57+
after(async () => deleteVM(name));
58+
it('should create vm with startup script', function(done) {
59+
this.timeout(280000);
60+
this.retries(3);
61+
const {spawn} = require('child_process');
62+
const startupScript = spawn('node', ['startupScript', name], {
63+
stdio: 'inherit',
64+
});
65+
startupScript.on('close', code => {
66+
assert.strictEqual(code, 0);
67+
return done();
68+
});
69+
});
6070
});
6171
});
6272

0 commit comments

Comments
 (0)