Wait for dns to propagate on restore

This commit is contained in:
Girish Ramakrishnan 2015-07-27 12:34:56 -07:00
parent d5f77ca116
commit b19d5a1d66
3 changed files with 19 additions and 5 deletions

View File

@ -47,10 +47,11 @@ AppStore.prototype.waitForCloudron = function (boxId) {
var creationTime = new Date();
process.stdout.write('Waiting for cloudron to come up.');
var res;
while (true) {
sleep(10);
process.stdout.write('.');
var res = request.get(this._origin + '/api/v1/cloudrons/' + boxId).query({ accessToken: this._credentials.accessToken }).end();
res = request.get(this._origin + '/api/v1/cloudrons/' + boxId).query({ accessToken: this._credentials.accessToken }).end();
verifyResponse(res, 'Could not query cloudron status');
if (res.body.box.status === 'ready') {
@ -59,7 +60,9 @@ AppStore.prototype.waitForCloudron = function (boxId) {
}
}
debug('Box created in %s minutes'.green, (new Date() - creationTime) / 60000);
debug('Box created in %s minutes with IP:%s'.green, (new Date() - creationTime) / 60000, res.body.box.ip);
return res.body.box;
};
AppStore.prototype.createCloudron = function (box) {

View File

@ -17,6 +17,7 @@
"async": "^1.4.0",
"colors": "^1.1.0",
"debug": "^2.2.0",
"dns-sync": "^0.1.3",
"mocha": "^2.2.5",
"once": "^1.3.2",
"parallel-mocha": "0.0.7",

View File

@ -11,6 +11,7 @@ var AppStore = require('../appstore.js'),
assert = require('assert'),
Cloudron = require('../cloudron.js'),
common = require('../common.js'),
dnsSync = require('dns-sync'),
request = require('superagent-sync'),
semver = require('semver'),
sleep = require('sleep').sleep;
@ -89,13 +90,22 @@ describe('Cloudron backup testing', function () {
assert.strictEqual(backupInfo.dependsOn.length, 1);
});
var cloudronIp;
it('can restore the box', function () {
appStore.restore(box.id, backupInfo.restoreKey);
appStore.waitForCloudron(box.id);
cloudronIp = appStore.waitForCloudron(box.id);
});
it('wait for cloudron to be networked', function () {
sleep(30); // DO networking
it('wait for local dns', function () {
for (var i = 0; i < 20; i++) {
var ip = dnsSync.resolve(box.domain);
console.dir(ip);
if (ip === cloudronIp) return;
debug('waiting for local dns to change from %s to %s', ips[0], cloudronIp);
sleep(30);
}
});
it('can login to cloudron', function () {