fix(build): simplify the e2e/perf config via command line arguments
This commit is contained in:
@ -1,83 +1,35 @@
|
||||
// load traceur runtime as our tests are written in es6
|
||||
require('traceur/bin/traceur-runtime.js');
|
||||
|
||||
var nodeUuid = require('node-uuid');
|
||||
var benchpress = require('./dist/js/cjs/benchpress/benchpress');
|
||||
var SeleniumWebDriverAdapter = require('./dist/js/cjs/benchpress/src/webdriver/selenium_webdriver_adapter').SeleniumWebDriverAdapter;
|
||||
var cmdArgs = require('minimist')(process.argv);
|
||||
|
||||
var cmdLineBrowsers = cmdArgs.browsers ? cmdArgs.browsers.split(',') : [];
|
||||
|
||||
var config = exports.config = {
|
||||
// Disable waiting for Angular as we don't have an integration layer yet...
|
||||
// TODO(tbosch): Implement a proper debugging API for Ng2.0, remove this here
|
||||
// and the sleeps in all tests.
|
||||
onPrepare: function() {
|
||||
browser.ignoreSynchronization = true;
|
||||
var _get = browser.get;
|
||||
var sleepInterval = process.env.TRAVIS || process.env.JENKINS_URL ? 7000 : 3000;
|
||||
browser.get = function() {
|
||||
var result = _get.apply(this, arguments);
|
||||
browser.sleep(sleepInterval);
|
||||
return result;
|
||||
}
|
||||
},
|
||||
|
||||
framework: 'jasmine2',
|
||||
|
||||
jasmineNodeOpts: {
|
||||
showColors: true,
|
||||
defaultTimeoutInterval: 30000
|
||||
},
|
||||
params: {
|
||||
benchmark: {
|
||||
scaling: [{
|
||||
userAgent: /Android/, value: 0.125
|
||||
}]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.createBenchpressRunner = function(options) {
|
||||
// TODO(tbosch): add cloud reporter again (only when !options.test)
|
||||
// var cloudReporterConfig;
|
||||
// if (process.env.CLOUD_SECRET_PATH) {
|
||||
// console.log('using cloud reporter!');
|
||||
// cloudReporterConfig = {
|
||||
// auth: require(process.env.CLOUD_SECRET_PATH),
|
||||
// projectId: 'angular-perf',
|
||||
// datasetId: 'benchmarks',
|
||||
// tableId: 'ng2perf'
|
||||
// };
|
||||
// }
|
||||
|
||||
var runId = nodeUuid.v1();
|
||||
if (process.env.GIT_SHA) {
|
||||
runId = process.env.GIT_SHA + ' ' + runId;
|
||||
}
|
||||
var bindings = [
|
||||
benchpress.bind(benchpress.WebDriverAdapter).toFactory(
|
||||
function() { return new SeleniumWebDriverAdapter(global.browser); }, []
|
||||
),
|
||||
benchpress.bind(benchpress.Options.FORCE_GC).toValue(options.forceGc),
|
||||
benchpress.bind(benchpress.Options.DEFAULT_DESCRIPTION).toValue({
|
||||
'lang': options.lang,
|
||||
'runId': runId
|
||||
var argv = require('yargs')
|
||||
.usage('Angular e2e/perf test options.')
|
||||
.options({
|
||||
'sample-size': {
|
||||
describe: 'sample size',
|
||||
default: 20,
|
||||
type: 'boolean'
|
||||
},
|
||||
'force-gc': {
|
||||
describe: 'force gc',
|
||||
default: false,
|
||||
type: 'boolean'
|
||||
},
|
||||
'benchmark': {
|
||||
describe: 'whether to run the benchmarks',
|
||||
default: false
|
||||
},
|
||||
'browsers': {
|
||||
describe: 'preconfigured browsers that should be used',
|
||||
default: 'ChromeDesktop'
|
||||
}
|
||||
})
|
||||
];
|
||||
if (options.test) {
|
||||
bindings.push(benchpress.SizeValidator.BINDINGS);
|
||||
bindings.push(benchpress.bind(benchpress.SizeValidator.SAMPLE_SIZE).toValue(1));
|
||||
} else {
|
||||
bindings.push(benchpress.RegressionSlopeValidator.BINDINGS);
|
||||
bindings.push(benchpress.bind(benchpress.RegressionSlopeValidator.SAMPLE_SIZE).toValue(options.sampleSize));
|
||||
}
|
||||
.help('ng-help')
|
||||
.wrap(40)
|
||||
.argv
|
||||
|
||||
global.benchpressRunner = new benchpress.Runner(bindings);
|
||||
}
|
||||
var browsers = argv['browsers'].split(',');
|
||||
|
||||
|
||||
var POSSIBLE_CAPS = {
|
||||
var BROWSER_CAPS = {
|
||||
Dartium: {
|
||||
name: 'Dartium',
|
||||
browserName: 'chrome',
|
||||
@ -112,14 +64,96 @@ var POSSIBLE_CAPS = {
|
||||
}
|
||||
}
|
||||
};
|
||||
if (cmdLineBrowsers.length) {
|
||||
config.multiCapabilities = cmdLineBrowsers.map(function(browserName) {
|
||||
var caps = POSSIBLE_CAPS[browserName];
|
||||
|
||||
var config = exports.config = {
|
||||
// Disable waiting for Angular as we don't have an integration layer yet...
|
||||
// TODO(tbosch): Implement a proper debugging API for Ng2.0, remove this here
|
||||
// and the sleeps in all tests.
|
||||
onPrepare: function() {
|
||||
browser.ignoreSynchronization = true;
|
||||
var _get = browser.get;
|
||||
var sleepInterval = process.env.TRAVIS || process.env.JENKINS_URL ? 7000 : 3000;
|
||||
browser.get = function() {
|
||||
var result = _get.apply(this, arguments);
|
||||
browser.sleep(sleepInterval);
|
||||
return result;
|
||||
}
|
||||
},
|
||||
|
||||
specs: argv['benchmark'] ? [
|
||||
'dist/js/cjs/**/e2e_test/**/*_perf.js'
|
||||
] : [
|
||||
'dist/js/cjs/**/e2e_test/**/*_spec.js',
|
||||
'dist/js/cjs/**/e2e_test/**/*_perf.js'
|
||||
],
|
||||
|
||||
exclude: [
|
||||
'dist/js/cjs/**/node_modules/**',
|
||||
],
|
||||
|
||||
multiCapabilities: browsers.map(function(browserName) {
|
||||
var caps = BROWSER_CAPS[browserName];
|
||||
console.log('Testing against', browserName);
|
||||
if (!caps) {
|
||||
throw new Error('Not configured browser name: '+browserName);
|
||||
}
|
||||
return caps;
|
||||
});
|
||||
} else {
|
||||
config.multiCapabilities = [POSSIBLE_CAPS.ChromeDesktop];
|
||||
}),
|
||||
|
||||
framework: 'jasmine2',
|
||||
|
||||
jasmineNodeOpts: {
|
||||
showColors: true,
|
||||
defaultTimeoutInterval: argv.benchpress ? 80000 : 30000
|
||||
},
|
||||
params: {
|
||||
benchmark: {
|
||||
scaling: [{
|
||||
userAgent: /Android/, value: 0.125
|
||||
}]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.createBenchpressRunner = function(options) {
|
||||
var nodeUuid = require('node-uuid');
|
||||
var benchpress = require('./dist/js/cjs/benchpress/benchpress');
|
||||
var SeleniumWebDriverAdapter =
|
||||
require('./dist/js/cjs/benchpress/src/webdriver/selenium_webdriver_adapter').SeleniumWebDriverAdapter;
|
||||
|
||||
// TODO(tbosch): add cloud reporter again (only when !options.test)
|
||||
// var cloudReporterConfig;
|
||||
// if (process.env.CLOUD_SECRET_PATH) {
|
||||
// console.log('using cloud reporter!');
|
||||
// cloudReporterConfig = {
|
||||
// auth: require(process.env.CLOUD_SECRET_PATH),
|
||||
// projectId: 'angular-perf',
|
||||
// datasetId: 'benchmarks',
|
||||
// tableId: 'ng2perf'
|
||||
// };
|
||||
// }
|
||||
|
||||
var runId = nodeUuid.v1();
|
||||
if (process.env.GIT_SHA) {
|
||||
runId = process.env.GIT_SHA + ' ' + runId;
|
||||
}
|
||||
var bindings = [
|
||||
benchpress.bind(benchpress.WebDriverAdapter).toFactory(
|
||||
function() { return new SeleniumWebDriverAdapter(global.browser); }, []
|
||||
),
|
||||
benchpress.bind(benchpress.Options.FORCE_GC).toValue(argv['force-gc']),
|
||||
benchpress.bind(benchpress.Options.DEFAULT_DESCRIPTION).toValue({
|
||||
'lang': options.lang,
|
||||
'runId': runId
|
||||
})
|
||||
];
|
||||
if (argv['benchmark']) {
|
||||
bindings.push(benchpress.RegressionSlopeValidator.BINDINGS);
|
||||
bindings.push(benchpress.bind(benchpress.RegressionSlopeValidator.SAMPLE_SIZE).toValue(argv['sample-size']));
|
||||
} else {
|
||||
bindings.push(benchpress.SizeValidator.BINDINGS);
|
||||
bindings.push(benchpress.bind(benchpress.SizeValidator.SAMPLE_SIZE).toValue(1));
|
||||
}
|
||||
|
||||
global.benchpressRunner = new benchpress.Runner(bindings);
|
||||
}
|
||||
|
Reference in New Issue
Block a user