Skip to content

Shard gl jasmine tests #2933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .circleci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
set +e
set +o pipefail

ROOT=$(dirname $0)/..
EXIT_STATE=0
MAX_AUTO_RETRY=5

Expand Down Expand Up @@ -34,7 +35,12 @@ case $1 in
;;

jasmine2)
retry npm run test-jasmine -- --tags=gl --skip-tags=noCI,flaky
SHARDS=($(node $ROOT/tasks/shard_jasmine_tests.js --tag=gl))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node tasks/shard_jasmine_tests.js --tag=gl outputs:

gl2d_plot_interact_test.js
gl3d_plot_interact_test.js
parcoords_test.js
gl2d_click_test.js
splom_test.js,cartesian_test.js,gl2d_scatterplot_contour_test.js,gl2d_pointcloud_test.js,gl_plot_interact_basic_test.js
streamtube_test.js,gl2d_date_axis_render_test.js,cone_test.js

which is then converted into a bash array (that's the outer ()) and then looped below.


for s in ${SHARDS[@]}; do
retry npm run test-jasmine -- "$s" --tags=gl --skip-tags=noCI,flaky
done

retry npm run test-jasmine -- --tags=flaky --skip-tags=noCI
exit $EXIT_STATE
;;
Expand Down
112 changes: 112 additions & 0 deletions tasks/shard_jasmine_tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
var fs = require('fs');
var path = require('path');

var falafel = require('falafel');
var glob = require('glob');
var minimist = require('minimist');

var constants = require('./util/constants');
var pathToJasmineTests = constants.pathToJasmineTests;

var argv = minimist(process.argv.slice(2), {
string: ['tag', 'limit'],
alias: {
tag: ['t'],
limit: ['l'],
},
default: {
limit: 20
}
});

var tag = argv.tag;
var limit = argv.limit;

glob(path.join(pathToJasmineTests, '*.js'), function(err, files) {
if(err) throw err;

var file2cnt = {};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to note, with --limit=20 and --tag=gl, this fills up to:

{ 'cartesian_test.js': 1,
  'cone_test.js': 5,
  'gl_plot_interact_basic_test.js': 2,
  'gl2d_click_test.js': 20,
  'gl2d_date_axis_render_test.js': 4,
  'gl2d_plot_interact_test.js': 28,
  'gl2d_pointcloud_test.js': 2,
  'gl2d_scatterplot_contour_test.js': 2,
  'gl3d_plot_interact_test.js': 26,
  'parcoords_test.js': 30,
  'splom_test.js': 10,
  'streamtube_test.js': 10 }


files.forEach(function(file) {
var code = fs.readFileSync(file, 'utf-8');
var bn = path.basename(file);

falafel(code, function(node) {
if(isTestDescription(node, tag)) {
if(file2cnt[bn]) {
file2cnt[bn]++;
} else {
file2cnt[bn] = 1;
}
}
});
});

var ranking = Object.keys(file2cnt);
var runs = [];

// if 'it' count in file greater than threshold,
// run only this file separately,
// don't try to shard within file
Object.keys(file2cnt).forEach(function(f) {
if(file2cnt[f] > limit) {
runs.push(f);
ranking.splice(ranking.indexOf(f), 1);
}
});

// sort ranking in decreasing order
ranking.sort(function(a, b) { return file2cnt[b] - file2cnt[a]; });

var runi;
var cnt;

function newRun() {
var r0 = ranking[0];
runi = [r0];
cnt = file2cnt[r0];
ranking.shift();
}

function concat() {
runs.push(runi.join(','));
}

// try to match files with many tests with files not-that-many,
// by matching first rank with one or multiple trailing ranks.
newRun();
while(ranking.length) {
var rn = ranking[ranking.length - 1];

if((cnt + file2cnt[rn]) > limit) {
concat();
newRun();
} else {
runi.push(rn);
cnt += file2cnt[rn];
ranking.pop();
}
}
concat();

// print result to stdout
console.log(runs.join('\n'));
});

function isTestDescription(node, tag) {
var isDescription = (
node.type === 'Literal' &&
node.parent &&
node.parent.type === 'CallExpression' &&
node.parent.callee &&
node.parent.callee.type === 'Identifier' &&
node.parent.callee.name === 'it'
);

if(!tag) return isDescription;

return (
isDescription &&
node.source().indexOf('@' + tag) !== -1
);
}
14 changes: 7 additions & 7 deletions test/jasmine/tests/cone_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Test cone defaults', function() {
});
});

describe('@gl Test cone autorange:', function() {
describe('Test cone autorange:', function() {
var gd;

beforeEach(function() {
Expand All @@ -79,7 +79,7 @@ describe('@gl Test cone autorange:', function() {
expect(sceneLayout.zaxis.range).toBeCloseToArray(zrng, 2, 'zaxis range - ' + msg);
}

it('should add pad around cone position to make sure they fit on the scene', function(done) {
it('@gl should add pad around cone position to make sure they fit on the scene', function(done) {
var fig = Lib.extendDeep({}, require('@mocks/gl3d_cone-autorange.json'));
var rng0 = [0.103, 3.897];

Expand Down Expand Up @@ -177,7 +177,7 @@ describe('@gl Test cone autorange:', function() {
});
});

describe('@gl Test cone interactions', function() {
describe('Test cone interactions', function() {
var gd;

beforeEach(function() {
Expand All @@ -189,7 +189,7 @@ describe('@gl Test cone interactions', function() {
destroyGraphDiv();
});

it('should add/clear gl objects correctly', function(done) {
it('@gl should add/clear gl objects correctly', function(done) {
var fig = Lib.extendDeep({}, require('@mocks/gl3d_cone-simple.json'));
// put traces on same subplot
delete fig.data[1].scene;
Expand Down Expand Up @@ -219,7 +219,7 @@ describe('@gl Test cone interactions', function() {
.then(done);
});

it('should not pass zero or infinite `coneSize` to gl-cone3d', function(done) {
it('@gl should not pass zero or infinite `coneSize` to gl-cone3d', function(done) {
var base = {
type: 'cone',
x: [1, 2, 3],
Expand Down Expand Up @@ -254,7 +254,7 @@ describe('@gl Test cone interactions', function() {
.then(done);
});

it('should display hover labels', function(done) {
it('@gl should display hover labels', function(done) {
var fig = Lib.extendDeep({}, require('@mocks/gl3d_cone-simple.json'));
// only one trace on one scene
fig.data = [fig.data[0]];
Expand Down Expand Up @@ -302,7 +302,7 @@ describe('@gl Test cone interactions', function() {
.then(done);
});

it('should display hover labels (multi-trace case)', function(done) {
it('@gl should display hover labels (multi-trace case)', function(done) {
function _hover() {
mouseEvent('mouseover', 282, 240);
return delay(20)();
Expand Down
44 changes: 22 additions & 22 deletions test/jasmine/tests/gl2d_click_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var mock4 = {
layout: {}
};

describe('@gl @flaky Test hover and click interactions', function() {
describe('@flaky Test hover and click interactions', function() {
var gd;

function makeHoverFn(gd, x, y) {
Expand Down Expand Up @@ -185,7 +185,7 @@ describe('@gl @flaky Test hover and click interactions', function() {
destroyGraphDiv();
});

it('should output correct event data for scattergl', function(done) {
it('@gl should output correct event data for scattergl', function(done) {
var _mock = Lib.extendDeep({}, mock1);

_mock.layout.hoverlabel = {
Expand Down Expand Up @@ -222,7 +222,7 @@ describe('@gl @flaky Test hover and click interactions', function() {
.then(done);
});

it('should output correct event data for scattergl in *select* dragmode', function(done) {
it('@gl should output correct event data for scattergl in *select* dragmode', function(done) {
var _mock = Lib.extendDeep({}, mock1);

_mock.layout.dragmode = 'select';
Expand Down Expand Up @@ -261,7 +261,7 @@ describe('@gl @flaky Test hover and click interactions', function() {
.then(done);
});

it('should output correct event data for scattergl in *lasso* dragmode', function(done) {
it('@gl should output correct event data for scattergl in *lasso* dragmode', function(done) {
var _mock = Lib.extendDeep({}, mock1);

_mock.layout.dragmode = 'lasso';
Expand Down Expand Up @@ -300,7 +300,7 @@ describe('@gl @flaky Test hover and click interactions', function() {
.then(done);
});

it('should output correct event data for scattergl with hoverinfo: \'none\'', function(done) {
it('@gl should output correct event data for scattergl with hoverinfo: \'none\'', function(done) {
var _mock = Lib.extendDeep({}, mock1);
_mock.data[0].hoverinfo = 'none';

Expand All @@ -320,7 +320,7 @@ describe('@gl @flaky Test hover and click interactions', function() {
.then(done);
});

it('should show correct label for scattergl when hovertext is set', function(done) {
it('@gl should show correct label for scattergl when hovertext is set', function(done) {
var _mock = Lib.extendDeep({}, mock1);
_mock.data[0].hovertext = 'text';
_mock.data[0].hovertext = 'HoVeRtExT';
Expand All @@ -347,7 +347,7 @@ describe('@gl @flaky Test hover and click interactions', function() {
.then(done);
});

it('should output correct event data for pointcloud', function(done) {
it('@gl should output correct event data for pointcloud', function(done) {
var _mock = Lib.extendDeep({}, mock2);

_mock.layout.hoverlabel = { font: {size: 8} };
Expand Down Expand Up @@ -375,7 +375,7 @@ describe('@gl @flaky Test hover and click interactions', function() {
.then(done);
});

it('should output correct event data for heatmapgl', function(done) {
it('@gl should output correct event data for heatmapgl', function(done) {
var _mock = Lib.extendDeep({}, mock3);
_mock.data[0].type = 'heatmapgl';

Expand Down Expand Up @@ -408,7 +408,7 @@ describe('@gl @flaky Test hover and click interactions', function() {
.then(done);
});

it('should output correct event data for heatmapgl (asymmetric case) ', function(done) {
it('@gl should output correct event data for heatmapgl (asymmetric case) ', function(done) {
var _mock = {
data: [{
type: 'heatmapgl',
Expand Down Expand Up @@ -441,7 +441,7 @@ describe('@gl @flaky Test hover and click interactions', function() {
.then(done);
});

it('should output correct event data for scattergl after visibility restyle', function(done) {
it('@gl should output correct event data for scattergl after visibility restyle', function(done) {
var _mock = Lib.extendDeep({}, mock4);

var run = makeRunner([435, 216], {
Expand Down Expand Up @@ -483,7 +483,7 @@ describe('@gl @flaky Test hover and click interactions', function() {
.then(done);
});

it('should output correct event data for scattergl-fancy', function(done) {
it('@gl should output correct event data for scattergl-fancy', function(done) {
var _mock = Lib.extendDeep({}, mock4);
_mock.data[0].mode = 'markers+lines';
_mock.data[1].mode = 'markers+lines';
Expand Down Expand Up @@ -531,7 +531,7 @@ describe('@gl @flaky Test hover and click interactions', function() {
.then(done);
});

it('should output correct event data contourgl', function(done) {
it('@gl should output correct event data contourgl', function(done) {
var _mock = Lib.extendDeep({}, mock3);

_mock.data[0].hoverlabel = {
Expand Down Expand Up @@ -560,7 +560,7 @@ describe('@gl @flaky Test hover and click interactions', function() {
});
});

describe('@noCI @gl Test gl2d lasso/select:', function() {
describe('@noCI Test gl2d lasso/select:', function() {
var mockFancy = require('@mocks/gl2d_14.json');
delete mockFancy.layout.xaxis.autorange;
delete mockFancy.layout.yaxis.autorange;
Expand Down Expand Up @@ -630,7 +630,7 @@ describe('@noCI @gl Test gl2d lasso/select:', function() {
}


it('should work under fast mode with *select* dragmode', function(done) {
it('@gl should work under fast mode with *select* dragmode', function(done) {
var _mock = Lib.extendDeep({}, mockFast);
_mock.layout.dragmode = 'select';
gd = createGraphDiv();
Expand All @@ -657,7 +657,7 @@ describe('@noCI @gl Test gl2d lasso/select:', function() {
.then(done);
});

it('should work under fast mode with *lasso* dragmode', function(done) {
it('@gl should work under fast mode with *lasso* dragmode', function(done) {
var _mock = Lib.extendDeep({}, mockFast);
_mock.layout.dragmode = 'lasso';
gd = createGraphDiv();
Expand All @@ -681,7 +681,7 @@ describe('@noCI @gl Test gl2d lasso/select:', function() {
.then(done);
});

it('should work under fancy mode with *select* dragmode', function(done) {
it('@gl should work under fancy mode with *select* dragmode', function(done) {
var _mock = Lib.extendDeep({}, mockFancy);
_mock.layout.dragmode = 'select';
gd = createGraphDiv();
Expand All @@ -701,7 +701,7 @@ describe('@noCI @gl Test gl2d lasso/select:', function() {
.then(done);
});

it('should work under fancy mode with *lasso* dragmode', function(done) {
it('@gl should work under fancy mode with *lasso* dragmode', function(done) {
var _mock = Lib.extendDeep({}, mockFancy);
_mock.layout.dragmode = 'lasso';
gd = createGraphDiv();
Expand All @@ -720,7 +720,7 @@ describe('@noCI @gl Test gl2d lasso/select:', function() {
.then(done);
});

it('should work on trace with enabled transforms', function(done) {
it('@gl should work on trace with enabled transforms', function(done) {
var fig = Lib.extendDeep({}, require('@mocks/gl2d_transforms.json'));
fig.layout.dragmode = 'select';
fig.layout.margin = {t: 0, b: 0, l: 0, r: 0};
Expand All @@ -743,7 +743,7 @@ describe('@noCI @gl Test gl2d lasso/select:', function() {
.then(done);
});

it('should work on gl text charts', function(done) {
it('@gl should work on gl text charts', function(done) {
var fig = Lib.extendDeep({}, require('@mocks/gl2d_text_chart_basic.json'));
fig.layout.dragmode = 'select';
fig.layout.margin = {t: 0, b: 0, l: 0, r: 0};
Expand Down Expand Up @@ -826,7 +826,7 @@ describe('@noCI @gl Test gl2d lasso/select:', function() {
.then(done);
});

it('should work on gl text charts with array textfont.color', function(done) {
it('@gl should work on gl text charts with array textfont.color', function(done) {
var fig = Lib.extendDeep({}, require('@mocks/gl2d_text_chart_arrays.json'));
fig.layout.dragmode = 'select';
fig.layout.margin = {t: 0, b: 0, l: 0, r: 0};
Expand Down Expand Up @@ -906,7 +906,7 @@ describe('@noCI @gl Test gl2d lasso/select:', function() {
.then(done);
});

it('should work after a width/height relayout', function(done) {
it('@gl should work after a width/height relayout', function(done) {
gd = createGraphDiv();

var w = 500;
Expand Down Expand Up @@ -965,7 +965,7 @@ describe('@noCI @gl Test gl2d lasso/select:', function() {
.then(done);
});

it('should behave correctly during select+doubleclick+pan scenarios', function(done) {
it('@gl should behave correctly during select+doubleclick+pan scenarios', function(done) {
gd = createGraphDiv();

// See https://github.com/plotly/plotly.js/issues/2767
Expand Down
Loading