@@ -23,40 +23,50 @@ const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
2323
2424const 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 , / V i r t u a l m a c h i n e c r e a t e d ! / ) ;
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 , / V i r t u a l m a c h i n e c r e a t e d ! / ) ;
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 , / V i r t u a l m a c h i n e c r e a t e d ! / ) ;
41- } ) ;
39+ it ( 'should create a VM' , ( ) => {
40+ const output = execSync ( `node createVM ${ name } ` ) ;
41+ assert . match ( output , / V i r t u a l m a c h i n e c r e a t e d ! / ) ;
42+ } ) ;
4243
43- it ( 'should list the VMs' , async ( ) => {
44- const output = execSync ( 'node listVMs' ) ;
45- assert . match ( output , / F o u n d \d + V M s ! / ) ;
46- } ) ;
44+ it ( 'should list the VMs' , ( ) => {
45+ const output = execSync ( 'node listVMs' ) ;
46+ assert . match ( output , / F o u n d \d + V M s ! / ) ;
47+ } ) ;
4748
48- it ( 'should delete the VM' , async ( ) => {
49- const output = execSync ( `node deleteVM ${ name } ` ) ;
50- assert . match ( output , / V M d e l e t e d ! / ) ;
49+ it ( 'should delete the VM' , ( ) => {
50+ const output = execSync ( `node deleteVM ${ name } ` ) ;
51+ assert . match ( output , / V M d e l e t e d ! / ) ;
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 , / c r e a t e d s u c c e s f u l l y / ) ;
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