cloudron-e2e-test/test/cloudron-update-test.js

144 lines
4.9 KiB
JavaScript
Raw Normal View History

2015-06-14 04:33:42 +00:00
#!/usr/bin/env node
/*
* This tests a flow for the cloudron owner updating a cloudron.
* It checks if an existing installed app retains it's data after
2015-06-16 21:07:31 +00:00
* an update. It then check if the cloudron can be updated to
* the next (unreleased) version.
*/
2015-06-14 04:33:42 +00:00
'use strict';
2015-06-15 04:15:49 +00:00
var AppStore = require('../appstore.js'),
2015-06-14 04:33:42 +00:00
assert = require('assert'),
2015-06-15 04:15:49 +00:00
Cloudron = require('../cloudron.js'),
2015-06-17 02:13:17 +00:00
common = require('../common.js'),
2015-06-16 21:16:37 +00:00
execSync = require('child_process').execSync,
2015-06-14 04:33:42 +00:00
request = require('superagent-sync'),
semver = require('semver'),
2015-06-22 07:14:44 +00:00
sleep = require('sleep').sleep;
2015-06-14 04:33:42 +00:00
require('colors');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
2015-06-16 03:50:39 +00:00
describe('Cloudron update testing', function () {
2015-06-14 04:33:42 +00:00
this.timeout(0);
var appStore = new AppStore('https://api.staging.cloudron.io');
2015-07-23 20:46:47 +00:00
var owner = common.getOwner();
2015-06-16 21:07:31 +00:00
var res, fromVersion, toVersion, cloudron, appId, box, nextVersion;
2015-06-14 04:33:42 +00:00
2015-07-24 22:49:56 +00:00
before('can release a fake version to staging', function () {
execSync(__dirname + '/../../installer/release/release rerelease --env staging', { stdio: [ null, process.stdout, process.stderr ] });
});
after('can revert the fake release from staging', function () {
execSync(__dirname + '/../../installer/release/release revert --env staging', { stdio: [ null, process.stdout, process.stderr ] });
});
2015-06-14 04:33:42 +00:00
it('can query versions', function () {
res = request.get('https://s3.amazonaws.com/staging-cloudron-releases/versions.json').end();
2015-06-19 20:06:00 +00:00
common.verifyResponse(res);
2015-06-14 04:33:42 +00:00
var boxVersions = Object.keys(res.body).sort(semver.rcompare);
2015-07-25 00:34:10 +00:00
fromVersion = boxVersions[2]; // we released a new version in before()
toVersion = boxVersions[1];
2015-06-16 21:07:31 +00:00
nextVersion = semver.inc(toVersion, 'patch');
2015-06-14 04:33:42 +00:00
console.log('Will test update from %s to %s', fromVersion.yellow, toVersion.yellow);
});
it('can login to the store', function () {
var accessToken = appStore.getAccessToken(owner);
appStore.setCredentials(owner.password, accessToken);
});
it('can create a cloudron', function () {
box = appStore.createCloudron({
2015-06-19 20:06:00 +00:00
domain: common.cloudronDomain(__filename),
2015-06-14 04:33:42 +00:00
zoneName: 'smartserver.io',
region: 'sfo1',
size: '512mb',
version: fromVersion
});
2015-06-16 19:00:46 +00:00
appStore.waitForCloudron(box.id);
2015-06-14 04:33:42 +00:00
cloudron = new Cloudron(box);
});
it('can activate the box', function () {
cloudron.activate(owner);
});
it('can login to the box', function () {
var token = cloudron.getOauthToken(owner);
cloudron.setCredentials(owner.password, token);
});
2015-06-16 04:49:30 +00:00
var location = 'test' + (Math.random() * 10000).toFixed();
2015-06-14 04:33:42 +00:00
it('can install app', function () {
2015-06-17 02:13:17 +00:00
var manifest = appStore.getManifest(common.TESTAPP_ID, common.TESTAPP_VERSION);
2015-06-14 04:33:42 +00:00
appId = cloudron.installApp(location, manifest);
});
2015-06-16 04:49:30 +00:00
it('can populate the addons', function () {
2015-06-16 05:14:48 +00:00
var res = request.post('https://' + location + '-' + box.domain + '/populate_addons').end();
2015-06-16 04:49:30 +00:00
assert.strictEqual(res.statusCode, 200);
assert.strictEqual(res.body.mysql, 'OK');
assert.strictEqual(res.body.postgresql, 'OK');
assert.strictEqual(res.body.mongodb, 'OK');
});
it('can check the addons', function () {
2015-06-16 05:06:27 +00:00
var res = request.post('https://' + location + '-' + box.domain + '/check_addons').end();
2015-06-16 04:49:30 +00:00
assert.strictEqual(res.statusCode, 200);
assert.strictEqual(res.body.mysql, 'OK');
assert.strictEqual(res.body.postgresql, 'OK');
assert.strictEqual(res.body.mongodb, 'OK');
2015-06-14 04:33:42 +00:00
});
it('can update the box', function () {
cloudron.update(toVersion);
});
2015-06-16 05:28:48 +00:00
it('runs the app', function () {
cloudron.waitForApp(appId);
});
2015-06-16 04:49:30 +00:00
it('can check the addons', function () {
2015-06-16 05:06:27 +00:00
var res = request.post('https://' + location + '-' + box.domain + '/check_addons').end();
2015-06-16 04:49:30 +00:00
assert.strictEqual(res.statusCode, 200);
assert.strictEqual(res.body.mysql, 'OK');
assert.strictEqual(res.body.postgresql, 'OK');
assert.strictEqual(res.body.mongodb, 'OK');
});
2015-06-16 21:07:31 +00:00
it('can update to new version', function () {
console.log('Wait for cloudron to get the update');
sleep(60 * 2);
cloudron.update(nextVersion);
});
it('runs the app', function () {
cloudron.waitForApp(appId);
});
it('can check the addons', function () {
var res = request.post('https://' + location + '-' + box.domain + '/check_addons').end();
assert.strictEqual(res.statusCode, 200);
assert.strictEqual(res.body.mysql, 'OK');
assert.strictEqual(res.body.postgresql, 'OK');
assert.strictEqual(res.body.mongodb, 'OK');
});
2015-06-14 04:33:42 +00:00
it('can uninstall app', function () {
cloudron.uninstallApp(appId);
});
it('can delete the cloudron', function () {
appStore.deleteCloudron(box);
});
});