Also cleanup the ec2 instances

This commit is contained in:
Johannes Zellner 2016-06-23 21:46:02 +02:00
parent 6645436577
commit 82244edf49
1 changed files with 28 additions and 4 deletions

View File

@ -9,6 +9,7 @@
var AppStore = require('../appstore.js'),
assert = require('assert'),
async = require('async'),
AWS = require('aws-sdk'),
child_process = require('child_process'),
Cloudron = require('../cloudron.js'),
common = require('../common.js'),
@ -53,13 +54,23 @@ describe('Selfhost EC2 Cloudron creation', function () {
this.timeout(0);
var appStore = new AppStore('https://api.staging.cloudron.io');
var ec2 = new AWS.Route53({ accessKeyId: AWS_ACCESS_KEY, secretAccessKey: AWS_ACCESS_SECRET, region: EC2_REGION });
var owner = common.getOwner();
var cloudron, appId, backupInfo;
var cloudron, appId, backupInfo, instanceId, newInstanceId;
it('can create a cloudron', function () {
var out = machine(util.format('create ec2 --fqdn %s --type %s --region %s --ssh-key %s --access-key-id %s --secret-access-key %s --subnet %s --security-group %s --backup-key %s --backup-bucket %s --release %s', CUSTOM_DOMAIN, EC2_TYPE, EC2_REGION, EC2_SSH_KEY, AWS_ACCESS_KEY, AWS_ACCESS_SECRET, EC2_SUBNET, EC2_SECURITY_GROUP, BACKUP_KEY, BACKUP_BUCKET, BOX_VERSION));
assert(out.stdout.indexOf('You can now use your Cloudron at') !== -1);
if (out.stdout.indexOf('You can now use your Cloudron at') === -1) {
console.error(out.stdout, out.stderr);
assert(false, 'Creation failed');
}
// Wohooo strings!
instanceId = out.stdout.split('\n').filter(function (l) { return l.indexOf('ID: ') !== -1; })[0].split(':')[1].trim();
console.log('New instance created with ID', instanceId);
cloudron = new Cloudron({
domain: CUSTOM_DOMAIN,
@ -103,7 +114,15 @@ describe('Selfhost EC2 Cloudron creation', function () {
it('can restore the box', function () {
var out = machine(util.format('restore ec2 --fqdn %s --type %s --region %s --ssh-key %s --access-key-id %s --secret-access-key %s --subnet %s --security-group %s --backup-key %s --backup-bucket %s --backup %s', CUSTOM_DOMAIN, EC2_TYPE, EC2_REGION, EC2_SSH_KEY, AWS_ACCESS_KEY, AWS_ACCESS_SECRET, EC2_SUBNET, EC2_SECURITY_GROUP, BACKUP_KEY, BACKUP_BUCKET, backupInfo.id));
assert(out.stdout.indexOf('You can now use your Cloudron at') !== -1);
if (out.stdout.indexOf('You can now use your Cloudron at') === -1) {
console.error(out.stdout, out.stderr);
assert(false, 'Restore failed');
}
newInstanceId = out.stdout.split('\n').filter(function (l) { return l.indexOf('ID: ') !== -1; })[0].split(':')[1].trim();
console.log('New instance created with ID', newInstanceId);
});
it('wait for app to be ready', function () {
@ -146,6 +165,11 @@ describe('Selfhost EC2 Cloudron creation', function () {
], done);
});
xit('can delete the cloudron', function () {
it('can delete the cloudron', function (done) {
var params = {
InstanceIds: [ instanceId, newInstanceId ]
};
ec2.terminateInstances(params, done);
});
});