From 667913c0796c08d03593469403a210588ba627a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 16 Mar 2017 17:27:32 -0400 Subject: [PATCH 1/2] throttle image export tests - in an effort to make `npm run test-export` not fail intermittently on the (weaker-hardware) CI machines. --- test/image/export_test.js | 40 +++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/test/image/export_test.js b/test/image/export_test.js index 516178d851e..69ac40d3a01 100644 --- a/test/image/export_test.js +++ b/test/image/export_test.js @@ -30,6 +30,12 @@ var HEIGHT = 500; // minimum satisfactory file size [in bytes] var MIN_SIZE = 100; +// wait time between each test batch +var BATCH_WAIT = 500; + +// number of tests in each test batch +var BATCH_SIZE = 5; + /** * Image export test script. * @@ -65,21 +71,39 @@ if(mockList.length === 0) { runInBatch(mockList); function runInBatch(mockList) { + var running = 0; + test('testing image export formats', function(t) { t.plan(mockList.length * FORMATS.length); - // send all requests out at once - mockList.forEach(function(mockName) { - FORMATS.forEach(function(format) { - testExport(mockName, format, t); - }); - }); + for(var i = 0; i < mockList.length; i++) { + for(var j = 0; j < FORMATS.length; j++) { + run(mockList[i], FORMATS[j], t); + } + } }); + + function run(mockName, format, t) { + if(running >= BATCH_SIZE) { + setTimeout(function() { + run(mockName, format, t); + }, BATCH_WAIT); + return; + } + running++; + + // throttle the number of tests running concurrently + + testExport(mockName, format, function(didExport, mockName, format) { + running--; + t.ok(didExport, mockName + ' should be properly exported as a ' + format); + }); + } } // The tests below determine whether the images are properly // exported by (only) checking the file size of the generated images. -function testExport(mockName, format, t) { +function testExport(mockName, format, cb) { var specs = { mockName: mockName, format: format, @@ -105,7 +129,7 @@ function testExport(mockName, format, t) { didExport = stats.size > MIN_SIZE; } - t.ok(didExport, mockName + ' should be properly exported as a ' + format); + cb(didExport, mockName, format); } request(requestOpts) From 32b969668018335403db12fe7958a612a843677b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 16 Mar 2017 17:31:03 -0400 Subject: [PATCH 2/2] swap containers for test-export <-> test-bundle - in an effort to reduce image-server "stress" in container 0 - this should also reduce total test time as test-jasmine is by far the slowest test command. --- tasks/ci_test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/ci_test.sh b/tasks/ci_test.sh index 5e2b7d40a95..12608154d92 100755 --- a/tasks/ci_test.sh +++ b/tasks/ci_test.sh @@ -7,7 +7,7 @@ case $CIRCLE_NODE_INDEX in 0) npm run test-image || EXIT_STATE=$? npm run test-image-gl2d || EXIT_STATE=$? - npm run test-export || EXIT_STATE=$? + npm run test-bundle || EXIT_STATE=$? npm run test-syntax || EXIT_STATE=$? npm run lint || EXIT_STATE=$? exit $EXIT_STATE @@ -15,7 +15,7 @@ case $CIRCLE_NODE_INDEX in 1) npm run test-jasmine || EXIT_STATE=$? - npm run test-bundle || EXIT_STATE=$? + npm run test-export || EXIT_STATE=$? exit $EXIT_STATE ;;