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

137 lines
4.3 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();
var admin = common.getAdmin();
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 () {
2015-10-12 20:49:26 +00:00
execSync(__dirname + '/../../release/release rerelease --env staging', { stdio: [ null, process.stdout, process.stderr ] });
2015-07-24 22:49:56 +00:00
});
after('can revert the fake release from staging', function () {
2015-10-12 20:49:26 +00:00
execSync(__dirname + '/../../release/release revert --env staging', { stdio: [ null, process.stdout, process.stderr ] });
2015-07-24 22:49:56 +00:00
});
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-09-15 18:55:06 +00:00
var boxVersions = Object.keys(common.stripUnreachable(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-09-15 18:55:06 +00:00
nextVersion = boxVersions[0];
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);
var adminAccessToken = appStore.getAccessToken(admin);
2015-11-29 16:57:47 +00:00
appStore.setAdminCredentials(admin.password, adminAccessToken);
2015-06-14 04:33:42 +00:00
});
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
region: 'sfo1',
size: '1gb',
2015-06-14 04:33:42 +00:00
version: fromVersion
});
2015-09-29 04:02:27 +00:00
box = 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 () {
var manifest = appStore.getManifest(common.TESTAPP_ID, common.PREV_TESTAPP_VERSION);
appId = cloudron.installApp(location, manifest, fromVersion);
2015-06-14 04:33:42 +00:00
});
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');
2015-10-10 21:38:54 +00:00
assert.strictEqual(res.body.localstorage, 'OK');
assert.strictEqual(res.body.redis, 'OK');
2015-06-16 04:49:30 +00:00
});
it('can check the addons', function () {
2015-10-21 00:53:57 +00:00
cloudron.checkAddons(location, owner);
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);
});
it('can check the addons', function () {
2015-10-21 00:53:57 +00:00
cloudron.checkAddons(location, owner);
2015-06-16 04:49:30 +00:00
});
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 () {
2015-10-21 00:53:57 +00:00
cloudron.checkAddons(location, owner);
2015-06-16 21:07:31 +00:00
});
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);
});
});