From 1eefcccf381f3b2008df85e113955c3b64974e74 Mon Sep 17 00:00:00 2001 From: Dave Eddy Date: Tue, 29 Sep 2015 12:53:34 -0400 Subject: [PATCH] more integration tests --- test/integration/cli-manage-workflow.test.js | 106 ++++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) diff --git a/test/integration/cli-manage-workflow.test.js b/test/integration/cli-manage-workflow.test.js index 0d32d5a..4bf9f32 100644 --- a/test/integration/cli-manage-workflow.test.js +++ b/test/integration/cli-manage-workflow.test.js @@ -132,11 +132,115 @@ test('triton manage workflow', opts, function (tt) { }); }); - // remove test instance + // remove instance tt.test('triton delete', function (t) { triton(t, ['delete', '-w', instance.id], function (stdout) { t.end(); }); }); + // create a test machine (non-blocking) + tt.test('triton create', function (t) { + triton(t, ['create', '-jn', VM_ALIAS, VM_IMAGE, VM_PACKAGE], + function (stdout) { + + // parse JSON response + var lines = stdout.trim().split('\n'); + t.equal(lines.length, 1, 'correct number of JSON lines'); + var d; + try { + d = JSON.parse(lines[0]); + } catch (e) { + t.fail('failed to parse JSON'); + t.end(); + } + instance = d; + + t.equal(d.state, 'provisioning', 'correct machine state'); + + t.end(); + }); + }); + + // wait for the machine to start + tt.test('triton wait', function (t) { + triton(t, ['wait', instance.id], + function (stdout) { + + // parse JSON response + var lines = stdout.trim().split('\n'); + t.equal(lines.length, 2, 'correct number of stdout lines'); + + t.ok(lines[0].match(/\(states: running, failed\)$/), + 'first line correct'); + t.ok(lines[1].match(/moved to state running$/), + 'second line correct'); + + t.end(); + }); + }); + + // stop the machine + tt.test('triton stop', function (t) { + triton(t, ['stop', '-w', VM_ALIAS], + function (stdout) { + t.ok(stdout.match(/^Stop instance/, 'correct stdout')); + t.end(); + }); + }); + + // wait for the machine to stop + tt.test('triton confirm stopped', function (t) { + triton(t, ['instance', '-j', VM_ALIAS], + function (stdout) { + var d; + try { + d = JSON.parse(stdout); + } catch (e) { + t.fail('failed to parse JSON'); + t.end(); + } + instance = d; + + t.equal(d.state, 'stopped', 'machine stopped'); + + t.end(); + }); + }); + + // start the machine + tt.test('triton start', function (t) { + triton(t, ['start', '-w', VM_ALIAS], + function (stdout) { + t.ok(stdout.match(/^Start instance/, 'correct stdout')); + t.end(); + }); + }); + + // wait for the machine to start + tt.test('triton confirm running', function (t) { + triton(t, ['instance', '-j', VM_ALIAS], + function (stdout) { + var d; + try { + d = JSON.parse(stdout); + } catch (e) { + t.fail('failed to parse JSON'); + t.end(); + } + instance = d; + + t.equal(d.state, 'running', 'machine running'); + + t.end(); + }); + }); + + // remove test instance + tt.test('triton cleanup (delete)', function (t) { + triton(t, ['delete', '-w', instance.id], function (stdout) { + t.end(); + }); + }); + });