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

144 lines
4.3 KiB
JavaScript
Raw Normal View History

/*
* 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-14 04:33:42 +00:00
request = require('superagent-sync'),
semver = require('semver'),
sleep = require('../shell.js').sleep;
2015-06-14 04:33:42 +00:00
require('colors');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
2016-04-02 04:11:58 +00:00
var BOX_VERSION = process.env.BOX_VERSION;
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
it('can query versions', function () {
res = request.get('https://s3.amazonaws.com/staging-cloudron-releases/versions.json').end();
2016-01-27 17:21:41 +00:00
common.verifyResponse2xx(res);
2015-09-15 18:55:06 +00:00
var boxVersions = Object.keys(common.stripUnreachable(res.body)).sort(semver.rcompare);
2016-04-02 04:11:58 +00:00
fromVersion = boxVersions[2]; // we released a new version in before.js
2015-07-25 00:34:10 +00:00
toVersion = boxVersions[1];
2016-04-02 04:11:58 +00:00
assert.strictEqual(toVersion, BOX_VERSION);
2015-09-15 18:55:06 +00:00
nextVersion = boxVersions[0];
2015-06-14 04:33:42 +00:00
2016-04-02 04:37:26 +00:00
console.log('Will test update from %s to %s and then %s', fromVersion.yellow, toVersion.yellow, nextVersion.yellow);
2015-06-14 04:33:42 +00:00
});
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),
2016-06-29 17:21:18 +00:00
region: 'ams2',
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);
});
2016-09-08 20:13:15 +00:00
it('can login to the box', function () {
var token = cloudron.getOauthToken(owner);
cloudron.setCredentials(owner.password, token);
});
it('can enable email', function () {
cloudron.setEmailEnabled(true);
});
2016-05-19 02:35:22 +00:00
it('can save a sieve script', function (done) {
cloudron.saveSieveScript(owner, done);
});
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);
2016-05-05 22:02:33 +00:00
appId = cloudron.installApp(location, manifest);
2015-06-14 04:33:42 +00:00
});
2015-06-16 04:49:30 +00:00
it('can populate the addons', function () {
cloudron.populateAddons(cloudron.appFqdn(location));
2015-06-16 04:49:30 +00:00
});
it('can check the addons', function () {
cloudron.checkAddons(cloudron.appFqdn(location), owner);
2015-06-14 04:33:42 +00:00
});
it('can update the box', function () {
2017-05-01 21:22:50 +00:00
console.log('Wait for cloudron to get the update');
cloudron.checkForUpdates();
sleep(60); // give it a minute to get update info
2015-06-14 04:33:42 +00:00
cloudron.update(toVersion);
});
xit('can login to the box', function () {
2016-06-07 17:08:35 +00:00
var token = cloudron.getOauthToken(owner);
cloudron.setCredentials(owner.password, token);
});
2015-06-16 05:28:48 +00:00
it('runs the app', function () {
cloudron.waitForApp(appId);
});
it('can check the addons', function () {
2016-04-26 17:34:26 +00:00
cloudron.checkAddons(cloudron.appFqdn(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');
2016-06-18 18:51:31 +00:00
cloudron.checkForUpdates();
2015-06-16 21:07:31 +00:00
sleep(60 * 2);
cloudron.update(nextVersion);
});
it('runs the app', function () {
cloudron.waitForApp(appId);
});
it('can check the addons', function () {
2016-04-26 17:34:26 +00:00
cloudron.checkAddons(cloudron.appFqdn(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);
});
2016-05-19 02:35:22 +00:00
it('can check sieve script', function (done) {
cloudron.checkSieveScript(owner, done);
});
2015-06-14 04:33:42 +00:00
it('can delete the cloudron', function () {
appStore.deleteCloudron(box);
});
});