Test against the correct version in ec2 to allow updates to work

This commit is contained in:
Johannes Zellner 2016-08-08 10:05:04 +02:00
parent 98f9651f73
commit 0c051d373e

View File

@ -13,6 +13,8 @@ var AppStore = require('../appstore.js'),
Cloudron = require('../cloudron.js'),
common = require('../common.js'),
mailer = require('../mailer.js'),
semver = require('semver'),
request = require('superagent-sync'),
util = require('util');
require('colors');
@ -56,6 +58,19 @@ describe('Selfhost EC2 Cloudron creation', function () {
var owner = common.getOwner();
var cloudron, appId, backupInfo, instanceId, newInstanceId;
var fromVersion, toVersion, nextVersion;
it('can query versions', function () {
var res = request.get('https://s3.amazonaws.com/staging-cloudron-releases/versions.json').end();
common.verifyResponse2xx(res);
var boxVersions = Object.keys(common.stripUnreachable(res.body)).sort(semver.rcompare);
fromVersion = boxVersions[2]; // we released a new version in before.js
toVersion = boxVersions[1];
assert.strictEqual(toVersion, BOX_VERSION);
nextVersion = boxVersions[0];
console.log('Will test update from %s to %s and then %s', fromVersion.yellow, toVersion.yellow, nextVersion.yellow);
});
it('can create a cloudron', function () {
var params = [
@ -70,7 +85,7 @@ describe('Selfhost EC2 Cloudron creation', function () {
'--security-group ' + EC2_SECURITY_GROUP,
'--backup-key ' + BACKUP_KEY,
'--backup-bucket ' + BACKUP_BUCKET,
'--release ' + BOX_VERSION
'--release ' + toVersion
];
var out = machine('create ec2 ' + params.join(' '));
@ -88,7 +103,7 @@ describe('Selfhost EC2 Cloudron creation', function () {
cloudron = new Cloudron({
domain: SELFHOST_DOMAIN,
setupToken: null,
version: BOX_VERSION,
version: toVersion,
ip: null
});
});
@ -124,37 +139,23 @@ describe('Selfhost EC2 Cloudron creation', function () {
cloudron.checkAddons(cloudron.appFqdn(location), owner);
});
it('can backup the box', function () {
backupInfo = cloudron.backup();
assert.strictEqual(backupInfo.dependsOn.length, 1);
});
it('can update the box', function () {
cloudron.checkForUpdates();
it('can restore the box', function () {
var params = [
'--fqdn ' + SELFHOST_DOMAIN,
'--type ' + EC2_TYPE,
'--disk-size ' + EC2_SIZE,
'--region ' + EC2_REGION,
SELFHOST_DOMAIN,
'--yes',
'--ssh-key ' + EC2_SSH_KEY,
'--access-key-id ' + AWS_ACCESS_KEY,
'--secret-access-key ' + AWS_ACCESS_SECRET,
'--subnet ' + EC2_SUBNET,
'--security-group ' + EC2_SECURITY_GROUP,
'--backup-key ' + BACKUP_KEY,
'--backup-bucket ' + BACKUP_BUCKET,
'--backup ' + backupInfo.id,
'--username ' + owner.username,
'--password ' + owner.password
];
var out = machine('restore ec2 ' + params.join(' '));
var out = machine('update ' + params.join(' '));
console.log(out.stdout, out.stderr);
if (out.stdout.indexOf('You can now use your Cloudron at') === -1) {
assert(false, 'Restore failed');
assert(false, 'Update 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 () {
@ -186,23 +187,37 @@ describe('Selfhost EC2 Cloudron creation', function () {
cloudron.checkMail(owner, done);
});
it('can update the box', function () {
cloudron.checkForUpdates();
it('can backup the box', function () {
backupInfo = cloudron.backup();
assert.strictEqual(backupInfo.dependsOn.length, 1);
});
it('can restore the box', function () {
var params = [
SELFHOST_DOMAIN,
'--yes',
'--fqdn ' + SELFHOST_DOMAIN,
'--type ' + EC2_TYPE,
'--disk-size ' + EC2_SIZE,
'--region ' + EC2_REGION,
'--ssh-key ' + EC2_SSH_KEY,
'--username ' + owner.username,
'--password ' + owner.password
'--access-key-id ' + AWS_ACCESS_KEY,
'--secret-access-key ' + AWS_ACCESS_SECRET,
'--subnet ' + EC2_SUBNET,
'--security-group ' + EC2_SECURITY_GROUP,
'--backup-key ' + BACKUP_KEY,
'--backup-bucket ' + BACKUP_BUCKET,
'--backup ' + backupInfo.id,
];
var out = machine('update ' + params.join(' '));
var out = machine('restore ec2 ' + params.join(' '));
console.log(out.stdout, out.stderr);
if (out.stdout.indexOf('You can now use your Cloudron at') === -1) {
assert(false, 'Update failed');
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('runs the app', function () {