diff --git a/circle.yml b/circle.yml index 2615242402e..672e1e5328e 100644 --- a/circle.yml +++ b/circle.yml @@ -15,8 +15,8 @@ dependencies: - docker pull plotly/imageserver:latest post: - npm run cibuild - - docker run -d --name myimageserver -v $PWD:/var/www/streambed/image_server/plotly.js -p 9010:9010 plotly/imageserver:latest; sleep 20 - + - docker run -d --name myimageserver -v $PWD:/var/www/streambed/image_server/plotly.js -p 9010:9010 plotly/imageserver:latest + - wget --server-response --spider --tries=8 --retry-connrefused http://localhost:9010/ping test: override: - sudo lxc-attach -n "$(docker inspect --format '{{.Id}}' myimageserver)" -- bash -c "cd /var/www/streambed/image_server/plotly.js && node test/image/compare_pixels_test.js" diff --git a/docker-compose.yml b/docker-compose.yml index c65bde79315..c5e54bb707f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,4 +18,4 @@ dev: - .:/var/www/streambed/image_server/plotly.js ports: - "9010:9010" - - "2022:22" \ No newline at end of file + - "2022:22" diff --git a/tasks/baseline.sh b/tasks/baseline.sh index 3b60509bc27..84dcd638e13 100755 --- a/tasks/baseline.sh +++ b/tasks/baseline.sh @@ -12,8 +12,8 @@ CONTAINER_NAME="imagetest" # same as in docker-compose.yml CMD=( "cd /var/www/streambed/image_server/plotly.js &&" "cp -f test/image/index.html ../server_app/index.html &&" - "monit restart nw1 &&" - "sleep 5 &&" + "supervisorctl restart nw1 &&" + "wget --server-response --spider --tries=8 --retry-connrefused http://localhost:9010/ping &&" "node test/image/make_baseline.js $1" ) diff --git a/tasks/test_image.sh b/tasks/test_image.sh index d4f3de554a5..c931f5710f3 100755 --- a/tasks/test_image.sh +++ b/tasks/test_image.sh @@ -12,8 +12,8 @@ CONTAINER_NAME="imagetest" # same as in docker-compose.yml CMD=( "cd /var/www/streambed/image_server/plotly.js &&" "cp -f test/image/index.html ../server_app/index.html &&" - "monit restart nw1 &&" - "sleep 5 &&" + "supervisorctl restart nw1 && " + "wget --server-response --spider --tries=8 --retry-connrefused http://localhost:9010/ping &&" "node test/image/compare_pixels_test.js $1" ) diff --git a/test/image/compare_pixels_test.js b/test/image/compare_pixels_test.js index 0caf0136bff..b85099df378 100644 --- a/test/image/compare_pixels_test.js +++ b/test/image/compare_pixels_test.js @@ -9,24 +9,29 @@ var request = require('request'); var test = require('tape'); var gm = require('gm'); +var touch = function(fileName) { + fs.closeSync(fs.openSync(fileName, 'w')); +}; + // make artifact folders -if(!fs.existsSync(constants.pathToTestImagesDiff)) fs.mkdirSync(constants.pathToTestImagesDiff); -if(!fs.existsSync(constants.pathToTestImages)) fs.mkdirSync(constants.pathToTestImages); +if(!fs.existsSync(constants.pathToTestImagesDiff)) { + fs.mkdirSync(constants.pathToTestImagesDiff); +} +if(!fs.existsSync(constants.pathToTestImages)) { + fs.mkdirSync(constants.pathToTestImages); +} var userFileName = process.argv[2]; -var touch = function(fileName) { - fs.closeSync(fs.openSync(fileName, 'w')); -}; - -if (!userFileName) runAll(); +// run the test(s) +if(!userFileName) runAll(); else runSingle(userFileName); function runAll () { test('testing mocks', function (t) { - var files = fs.readdirSync(constants.pathToTestImageMocks); + var allMocks = fs.readdirSync(constants.pathToTestImageMocks); /* * Some test cases exhibit run-to-run randomness; @@ -35,15 +40,34 @@ function runAll () { * More info: * https://github.com/plotly/plotly.js/issues/62 * - * 40 test cases are removed: + * 41 test cases are removed: * - font-wishlist (1 test case) * - all gl2d (38) - * - gl2d_bunny-hull (1) + * - gl3d_bunny-hull (1) + * - polar_scatter (1) */ - t.plan(files.length - 40); + var mocks = allMocks.filter(function(mock) { + return !( + mock === 'font-wishlist.json' || + mock.indexOf('gl2d') !== -1 || + mock === 'gl3d_bunny-hull.json' || + mock === 'polar_scatter.json' + ); + }); + + var BASE_TIMEOUT = 500, // base timeout time + BATCH_SIZE = 5, // size of each test 'batch' + cnt = 0; + + function testFunction() { + testMock(mocks[cnt++], t); + } + + t.plan(mocks.length); - for (var i = 0; i < files.length; i ++) { - testMock(files[i], t); + for(var i = 0; i < mocks.length; i++) { + setTimeout(testFunction, + BASE_TIMEOUT * Math.floor(i / BATCH_SIZE) * BATCH_SIZE); } }); @@ -57,15 +81,6 @@ function runSingle (userFileName) { } function testMock (fileName, t) { - if(path.extname(fileName) !== '.json') return; - if(fileName === 'font-wishlist.json' && !userFileName) return; - - // TODO fix race condition in gl2d image generation - if(fileName.indexOf('gl2d_') !== -1) return; - - // TODO fix run-to-run randomness - if(fileName === 'gl3d_bunny-hull.json') return; - var figure = require(path.join(constants.pathToTestImageMocks, fileName)); var bodyMock = { figure: figure,