rerelease in before/after scripts

This commit is contained in:
Girish Ramakrishnan 2016-04-01 21:11:58 -07:00
parent ed62ae7bf3
commit 7935e79b07
4 changed files with 47 additions and 16 deletions

View File

@ -8,12 +8,12 @@ export DEBUG_COLORS=true
test_pids=() test_pids=()
test_logs=() test_logs=()
# cleanup # before
rm -f logs/* rm -f logs/*
echo "Cleaning up" echo "Before"
if ! ./node_modules/.bin/mocha --bail test/000-cleanup.js > "logs/000-cleanup.log" 2>&1; then if ! ./node_modules/.bin/mocha --bail test/before.js > "logs/before.log" 2>&1; then
echo "Cleanup script failed" echo "Before script failed"
cat "logs/000-cleanup.log" cat "logs/before.log"
exit 1 exit 1
fi fi
@ -50,6 +50,14 @@ done
kill -9 "${tail_pid}" kill -9 "${tail_pid}"
# after
echo "After"
if ! ./node_modules/.bin/mocha --bail test/after.js > "logs/after.js" 2>&1; then
echo "After script failed"
cat "logs/after.log"
fi
# dump logs for email
echo echo
echo echo
for log_file in "${test_logs[@]}"; do for log_file in "${test_logs[@]}"; do

22
test/after.js Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env node
/*
* This test cleans up all t-* cloudrons from previous run.
*/
'use strict';
var AppStore = require('../appstore.js'),
common = require('../common.js'),
execSync = require('child_process').execSync;
require('colors');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
describe('Revert fake release', function () {
it('can revert the fake release from staging', function () {
execSync(__dirname + '/../../release/release revert --env staging', { stdio: [ null, process.stdout, process.stderr ] });
});
});

View File

@ -7,7 +7,8 @@
'use strict'; 'use strict';
var AppStore = require('../appstore.js'), var AppStore = require('../appstore.js'),
common = require('../common.js'); common = require('../common.js'),
execSync = require('child_process').execSync;
require('colors'); require('colors');
@ -41,3 +42,9 @@ describe('Cleanup old cloudrons', function () {
}); });
}); });
describe('Fake release', function () {
it('can release a fake version to staging', function () {
execSync(__dirname + '/../../release/release rerelease --env staging', { stdio: [ null, process.stdout, process.stderr ] });
});
});

View File

@ -13,7 +13,6 @@ var AppStore = require('../appstore.js'),
assert = require('assert'), assert = require('assert'),
Cloudron = require('../cloudron.js'), Cloudron = require('../cloudron.js'),
common = require('../common.js'), common = require('../common.js'),
execSync = require('child_process').execSync,
request = require('superagent-sync'), request = require('superagent-sync'),
semver = require('semver'), semver = require('semver'),
sleep = require('sleep').sleep; sleep = require('sleep').sleep;
@ -22,6 +21,8 @@ require('colors');
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
var BOX_VERSION = process.env.BOX_VERSION;
describe('Cloudron update testing', function () { describe('Cloudron update testing', function () {
this.timeout(0); this.timeout(0);
@ -31,20 +32,13 @@ describe('Cloudron update testing', function () {
var admin = common.getAdmin(); var admin = common.getAdmin();
var res, fromVersion, toVersion, cloudron, appId, box, nextVersion; var res, fromVersion, toVersion, cloudron, appId, box, nextVersion;
before('can release a fake version to staging', function () {
execSync(__dirname + '/../../release/release rerelease --env staging', { stdio: [ null, process.stdout, process.stderr ] });
});
after('can revert the fake release from staging', function () {
execSync(__dirname + '/../../release/release revert --env staging', { stdio: [ null, process.stdout, process.stderr ] });
});
it('can query versions', function () { it('can query versions', function () {
res = request.get('https://s3.amazonaws.com/staging-cloudron-releases/versions.json').end(); res = request.get('https://s3.amazonaws.com/staging-cloudron-releases/versions.json').end();
common.verifyResponse2xx(res); common.verifyResponse2xx(res);
var boxVersions = Object.keys(common.stripUnreachable(res.body)).sort(semver.rcompare); var boxVersions = Object.keys(common.stripUnreachable(res.body)).sort(semver.rcompare);
fromVersion = boxVersions[2]; // we released a new version in before() fromVersion = boxVersions[2]; // we released a new version in before.js
toVersion = boxVersions[1]; toVersion = boxVersions[1];
assert.strictEqual(toVersion, BOX_VERSION);
nextVersion = boxVersions[0]; nextVersion = boxVersions[0];
console.log('Will test update from %s to %s', fromVersion.yellow, toVersion.yellow); console.log('Will test update from %s to %s', fromVersion.yellow, toVersion.yellow);