From f0bc1391f6b57b874543c915f09223ee322b9098 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Thu, 23 Jul 2015 14:10:21 -0700 Subject: [PATCH] Give appstore sometime to catch up on new release --- common.js | 2 +- e2etestrunner.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/common.js b/common.js index 22aa59c..3a75a4c 100644 --- a/common.js +++ b/common.js @@ -11,7 +11,7 @@ exports = module.exports = { getOwner: getOwner, }; -var gNow = (new Date()).getTime().toString(); +var gNow = ((new Date()).getTime() / 1000).toFixed(); function cloudronDomain(filename) { return 't-' + path.basename(filename, '-test.js') + '-' + gNow + '.smartserver.io'; diff --git a/e2etestrunner.js b/e2etestrunner.js index 10911f2..38a5388 100755 --- a/e2etestrunner.js +++ b/e2etestrunner.js @@ -29,15 +29,21 @@ function start() { function runTestsIfNeeded(callback) { debug('Getting latest box version'); - getLatestBoxVersion(function (error, latestETag, latestBoxVersion) { + getLatestBoxVersion(function (error, latestETag, latestBoxVersion, lastModified) { if (error) return callback(error); if (latestETag === gLatestETag) { debug('Box version has not changed. etag %s', gLatestETag); - return callback(null); + return callback(); } - debug('Box version has changed. etag %s', latestETag); + debug('Box version has changed. etag %s lm:%s', latestETag, lastModified); + + var diff = (new Date() - lastModified); + if (diff < 3 * 60 * 1000) { // give appstore 3 mins + debug('Waiting for appstore gets the new release. diff=%s', diff); + return callback(); + } runTests(latestETag, latestBoxVersion, function (error) { debug('Finished running tests for etag %s: %s', latestETag, error); @@ -57,10 +63,11 @@ function getLatestBoxVersion(callback) { var latestVersion = Object.keys(res.body).sort(semver.rcompare)[0]; var latestETag = res.headers['etag']; + var lastModified = new Date(res.headers['last-modified']); debug('%j:', res.headers); - callback(null, latestETag, latestVersion); + callback(null, latestETag, latestVersion, lastModified); }); }