test data dir migration

This commit is contained in:
Girish Ramakrishnan
2019-09-09 16:37:59 -07:00
parent d8cb100fc0
commit 6f53723169
5 changed files with 85 additions and 6 deletions

View File

@@ -9,6 +9,7 @@ let apps = require('../../apps.js'),
child_process = require('child_process'),
clients = require('../../clients.js'),
constants = require('../../constants.js'),
crypto = require('crypto'),
database = require('../../database.js'),
docker = require('../../docker.js').connection,
expect = require('expect.js'),
@@ -1354,6 +1355,80 @@ describe('App API', function () {
});
});
describe('configure data dir', function () {
it('fails with missing datadir', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/data_dir')
.query({ access_token: token })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
done();
});
});
it('fails with bad data dir', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/data_dir')
.query({ access_token: token })
.send({ dataDir: 'what' })
.end(function (err, res) {
expect(res.statusCode).to.equal(400);
done();
});
});
it('can set data dir', function (done) {
let dataDir = path.join(paths.baseDir(), 'apps-test-datadir-' + crypto.randomBytes(4).readUInt32LE(0));
fs.mkdirSync(dataDir);
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/data_dir')
.query({ access_token: token })
.send({ dataDir: dataDir })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
taskId = res.body.taskId;
done();
});
});
it('wait for task', function (done) {
waitForTask(taskId, done);
});
it('app can check addons', function (done) {
console.log('This test can take a while as it waits for scheduler addon to tick 4');
apps.get(APP_ID, function (error, app) {
if (error) return done(error);
checkAddons(app, done);
});
});
it('can reset data dir', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/data_dir')
.query({ access_token: token })
.send({ dataDir: null })
.end(function (err, res) {
expect(res.statusCode).to.equal(202);
taskId = res.body.taskId;
done();
});
});
it('wait for task', function (done) {
waitForTask(taskId, done);
});
it('app can check addons', function (done) {
console.log('This test can take a while as it waits for scheduler addon to tick 4');
apps.get(APP_ID, function (error, app) {
if (error) return done(error);
checkAddons(app, done);
});
});
});
describe('start/stop', function () {
it('non admin cannot stop app', function (done) {
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/stop')