Add reboot test
This commit is contained in:
parent
fd22b09e4d
commit
92fc9fbd40
28
cloudron.js
28
cloudron.js
@ -94,10 +94,11 @@ Cloudron.prototype.waitForApp = function (appId) {
|
|||||||
// wait for app to come up
|
// wait for app to come up
|
||||||
process.stdout.write('Waiting for app to come up.');
|
process.stdout.write('Waiting for app to come up.');
|
||||||
|
|
||||||
|
var res;
|
||||||
for (var i = 0; i < 60; i++) {
|
for (var i = 0; i < 60; i++) {
|
||||||
sleep(10);
|
sleep(10);
|
||||||
process.stdout.write('.');
|
process.stdout.write('.');
|
||||||
var res = request.get(this._origin + '/api/v1/apps/'+ appId).query({ access_token: this._credentials.accessToken }).end();
|
res = request.get(this._origin + '/api/v1/apps/'+ appId).query({ access_token: this._credentials.accessToken }).end();
|
||||||
verifyResponse(res, 'Could not query app status');
|
verifyResponse(res, 'Could not query app status');
|
||||||
|
|
||||||
if (res.body.installationState === 'installed' && res.body.runState === 'running' && res.body.health === 'healthy') {
|
if (res.body.installationState === 'installed' && res.body.runState === 'running' && res.body.health === 'healthy') {
|
||||||
@ -109,6 +110,21 @@ Cloudron.prototype.waitForApp = function (appId) {
|
|||||||
assert.strictEqual(res.body.runState, 'running');
|
assert.strictEqual(res.body.runState, 'running');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Cloudron.prototype.waitForBox = function () {
|
||||||
|
process.stdout.write('Waiting for box.');
|
||||||
|
var res;
|
||||||
|
for (var i = 0; i < 40; i++) {
|
||||||
|
sleep(10);
|
||||||
|
res = request.get(this._origin + '/api/v1/cloudron/status').end();
|
||||||
|
if (res.statusCode === 202) {
|
||||||
|
console.log();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
process.stdout.write('.');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Cloudron.prototype.setCredentials = function (password, accessToken) {
|
Cloudron.prototype.setCredentials = function (password, accessToken) {
|
||||||
this._credentials = {
|
this._credentials = {
|
||||||
password: password,
|
password: password,
|
||||||
@ -166,10 +182,11 @@ Cloudron.prototype.uninstallApp = function (appId) {
|
|||||||
|
|
||||||
Cloudron.prototype.update = function (toVersion) {
|
Cloudron.prototype.update = function (toVersion) {
|
||||||
process.stdout.write('Trying to update');
|
process.stdout.write('Trying to update');
|
||||||
|
var res;
|
||||||
while (true) {
|
while (true) {
|
||||||
sleep(10);
|
sleep(10);
|
||||||
process.stdout.write('.');
|
process.stdout.write('.');
|
||||||
var res = request.post(this._origin + '/api/v1/cloudron/update').query({ access_token: this._credentials.accessToken }).send({ password: this._credentials.password }).end();
|
res = request.post(this._origin + '/api/v1/cloudron/update').query({ access_token: this._credentials.accessToken }).send({ password: this._credentials.password }).end();
|
||||||
if (res.statusCode === 422) continue; // box has not seen the update yet
|
if (res.statusCode === 422) continue; // box has not seen the update yet
|
||||||
verifyResponse(res, 'Could not update');
|
verifyResponse(res, 'Could not update');
|
||||||
break;
|
break;
|
||||||
@ -190,7 +207,7 @@ Cloudron.prototype.update = function (toVersion) {
|
|||||||
assert.strictEqual(res.body.activated, true);
|
assert.strictEqual(res.body.activated, true);
|
||||||
|
|
||||||
console.log('Updated successfully'.green);
|
console.log('Updated successfully'.green);
|
||||||
}
|
};
|
||||||
|
|
||||||
Cloudron.prototype.addUser = function (username, email) {
|
Cloudron.prototype.addUser = function (username, email) {
|
||||||
var res = request.post(this._origin + '/api/v1/users').query({ access_token: this._credentials.accessToken }).send({ username: username, email: email }).end();
|
var res = request.post(this._origin + '/api/v1/users').query({ access_token: this._credentials.accessToken }).send({ username: username, email: email }).end();
|
||||||
@ -237,3 +254,8 @@ Cloudron.prototype.backup = function () {
|
|||||||
return latestBackups[0]; // { creationTime, boxVersion, restoreKey, dependsOn }
|
return latestBackups[0]; // { creationTime, boxVersion, restoreKey, dependsOn }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Cloudron.prototype.reboot = function () {
|
||||||
|
var res = request.post(this._origin + '/api/v1/cloudron/reboot').send({ }).end();
|
||||||
|
verifyResponse(res, 'Box could not be rebooted');
|
||||||
|
this.waitForBox();
|
||||||
|
};
|
||||||
|
@ -97,6 +97,19 @@ describe('Application flow test', function () {
|
|||||||
assert.strictEqual(res.body.localstorage, 'OK');
|
assert.strictEqual(res.body.localstorage, 'OK');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can reboot the cloudron', function () {
|
||||||
|
cloudron.reboot();
|
||||||
|
});
|
||||||
|
|
||||||
|
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');
|
||||||
|
assert.strictEqual(res.body.localstorage, 'OK');
|
||||||
|
});
|
||||||
|
|
||||||
it('can uninstall app', function () {
|
it('can uninstall app', function () {
|
||||||
cloudron.uninstallApp(appId);
|
cloudron.uninstallApp(appId);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user