cloudron-e2e-test/test/cloudron-autoupdate-sfo1-test.js

149 lines
4.7 KiB
JavaScript
Raw Normal View History

/*
2016-06-07 22:15:24 +00:00
* This tests a flow for the cloudron autoupdating itself in sfo region.
* It checks if an existing installed app retains it's data after
2016-06-07 22:15:24 +00:00
* an update. It then check if the cloudron can be auto-updated to
2015-06-16 21:07:31 +00:00
* 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'),
2016-05-19 01:48:15 +00:00
mailer = require('../mailer.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),
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);
});
2016-05-19 01:48:15 +00:00
it('send mail to cloudron user', function (done) {
mailer.sendMailToCloudronUser(owner.username + '@' + box.domain, done);
});
2015-06-14 04:33:42 +00:00
it('can login to the box', function () {
var token = cloudron.getOauthToken(owner);
cloudron.setCredentials(owner.password, token);
});
2016-09-01 16:03:27 +00:00
it('can enable email', function () {
cloudron.setEmailEnabled(true);
});
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 () {
2016-06-08 01:55:59 +00:00
var manifest = appStore.getManifest(common.TESTAPP_ID, common.PREV_TESTAPP_VERSION);
appId = cloudron.installApp(location, common.TESTAPP_ID + '@' + common.PREV_TESTAPP_VERSION);
2015-06-14 04:33:42 +00:00
});
2015-06-16 04:49:30 +00:00
it('can populate the addons', function () {
2016-04-26 19:27:06 +00:00
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 () {
2016-06-18 18:51:31 +00:00
cloudron.checkForUpdates();
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
});
2016-06-07 21:35:30 +00:00
it('can set the autoupdate pattern', function () {
2016-06-07 22:11:41 +00:00
cloudron.setAutoupdatePattern('00 */1 * * * *'); // every 1 minute (but updateChecker runs only every 10 mins :/)
2016-06-07 21:35: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-08 03:31:02 +00:00
cloudron.checkForUpdates();
2016-06-18 18:33:03 +00:00
sleep(60 * 10); // give it 10 mins to autoupdate the box and the app
2016-06-07 21:35:30 +00:00
cloudron.waitForUpdate(nextVersion);
2015-06-16 21:07:31 +00:00
});
2016-06-07 23:50:37 +00:00
it('auto updates the app with new version', function () {
2016-06-08 03:31:02 +00:00
cloudron.checkForUpdates();
2016-06-18 18:33:03 +00:00
sleep(60 * 10); // give it 10 mins to autoupdate the box and the app
2016-06-07 23:50:37 +00:00
cloudron.waitForApp(appId, common.TESTAPP_VERSION);
2015-06-16 21:07:31 +00:00
});
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 01:48:15 +00:00
it('can check mail', function (done) {
cloudron.checkMail(owner, done);
});
2015-06-14 04:33:42 +00:00
it('can delete the cloudron', function () {
appStore.deleteCloudron(box);
});
});