more integration tests

This commit is contained in:
Dave Eddy 2015-09-29 12:53:34 -04:00
parent a01c7eede6
commit 1eefcccf38
1 changed files with 105 additions and 1 deletions

View File

@ -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();
});
});
});