test box autoupdate

This commit is contained in:
Girish Ramakrishnan 2016-06-07 14:35:30 -07:00
parent 4291c8db5c
commit 2d4dd7b55e
2 changed files with 21 additions and 3 deletions

View File

@ -251,8 +251,14 @@ Cloudron.prototype.update = function (toVersion) {
}
console.log('Update started'.green);
this.waitForUpdate(toVersion);
};
Cloudron.prototype.waitForUpdate = function (toVersion) {
process.stdout.write('Waiting for update.');
for (i = 0; i < 60; i++) {
var res;
for (var i = 0; i < 60; i++) {
sleep(20);
res = request.get(this._origin + '/api/v1/cloudron/status').end();
if (res.statusCode === 200 && res.body.version === toVersion) {
@ -327,6 +333,14 @@ Cloudron.prototype.checkTimeZone = function (tz) {
if (tz !== res.body.timeZone) throw new Error('timezone does not match. expecting: ' + tz + ' got ' + res.body.timeZone);
};
Cloudron.prototype.setAutoupdatePattern = function (pattern) {
var res = request.post(this._origin + '/api/v1/settings/autoupdate_pattern')
.query({ access_token: this._credentials.accessToken })
.send({ pattern: pattern })
.end();
common.verifyResponse2xx(res, 'Could not set autoupdate pattern');
};
Cloudron.prototype.checkA = function (callback) {
var that = this;
dns.resolve4(this._box.domain, function (error, records) {

View File

@ -107,10 +107,14 @@ describe('Cloudron update testing', function () {
cloudron.checkAddons(cloudron.appFqdn(location), owner);
});
it('can set the autoupdate pattern', function () {
cloudron.setAutoupdatePattern('00 */1 * * * *'); // every minute
});
it('can update to new version', function () {
console.log('Wait for cloudron to get the update');
sleep(60 * 2);
cloudron.update(nextVersion);
sleep(60 * 5); // give it 5 mins to autoupdate the box and the app
cloudron.waitForUpdate(nextVersion);
});
it('runs the app', function () {