From 7935e79b077e8f33dc7969d37872e5176bd24e08 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Fri, 1 Apr 2016 21:11:58 -0700 Subject: [PATCH] rerelease in before/after scripts --- parallel_test.sh | 18 +++++++++++++----- test/after.js | 22 ++++++++++++++++++++++ test/{000-cleanup.js => before.js} | 9 ++++++++- test/cloudron-update-test.js | 14 ++++---------- 4 files changed, 47 insertions(+), 16 deletions(-) create mode 100644 test/after.js rename test/{000-cleanup.js => before.js} (75%) diff --git a/parallel_test.sh b/parallel_test.sh index 3b0e075..fa22cfe 100755 --- a/parallel_test.sh +++ b/parallel_test.sh @@ -8,12 +8,12 @@ export DEBUG_COLORS=true test_pids=() test_logs=() -# cleanup +# before rm -f logs/* -echo "Cleaning up" -if ! ./node_modules/.bin/mocha --bail test/000-cleanup.js > "logs/000-cleanup.log" 2>&1; then - echo "Cleanup script failed" - cat "logs/000-cleanup.log" +echo "Before" +if ! ./node_modules/.bin/mocha --bail test/before.js > "logs/before.log" 2>&1; then + echo "Before script failed" + cat "logs/before.log" exit 1 fi @@ -50,6 +50,14 @@ done 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 for log_file in "${test_logs[@]}"; do diff --git a/test/after.js b/test/after.js new file mode 100644 index 0000000..38e3d8e --- /dev/null +++ b/test/after.js @@ -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 ] }); + }); +}); + diff --git a/test/000-cleanup.js b/test/before.js similarity index 75% rename from test/000-cleanup.js rename to test/before.js index 2e9434c..3dbe699 100644 --- a/test/000-cleanup.js +++ b/test/before.js @@ -7,7 +7,8 @@ 'use strict'; var AppStore = require('../appstore.js'), - common = require('../common.js'); + common = require('../common.js'), + execSync = require('child_process').execSync; 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 ] }); + }); +}); + diff --git a/test/cloudron-update-test.js b/test/cloudron-update-test.js index a7cecdc..c43f2e9 100644 --- a/test/cloudron-update-test.js +++ b/test/cloudron-update-test.js @@ -13,7 +13,6 @@ var AppStore = require('../appstore.js'), assert = require('assert'), Cloudron = require('../cloudron.js'), common = require('../common.js'), - execSync = require('child_process').execSync, request = require('superagent-sync'), semver = require('semver'), sleep = require('sleep').sleep; @@ -22,6 +21,8 @@ require('colors'); process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; +var BOX_VERSION = process.env.BOX_VERSION; + describe('Cloudron update testing', function () { this.timeout(0); @@ -31,20 +32,13 @@ describe('Cloudron update testing', function () { var admin = common.getAdmin(); 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 () { res = request.get('https://s3.amazonaws.com/staging-cloudron-releases/versions.json').end(); common.verifyResponse2xx(res); 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]; + assert.strictEqual(toVersion, BOX_VERSION); nextVersion = boxVersions[0]; console.log('Will test update from %s to %s', fromVersion.yellow, toVersion.yellow);