Skip to content

Commit

Permalink
consolidate saucelabs tests to address flake (#3019)
Browse files Browse the repository at this point in the history
- run browser tests concurrently to avoid SauceLabs flake
- remove some "unit" tests of questionable value
- linting of `karma.conf.js`
  • Loading branch information
boneskull authored Sep 28, 2017
1 parent 86e76f9 commit 0ed5297
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 242 deletions.
29 changes: 1 addition & 28 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,8 @@ matrix:
env: TARGET=test-node
- node_js: '8'
env: TARGET=lint
# phantomjs
- node_js: '8'
env: TARGET=test-browser
# chrome
- node_js: '8'
env: TARGET=test-browser BROWSER="chrome@latest" PLATFORM="Windows 8"
# edge
- node_js: '8'
env: TARGET=test-browser BROWSER="MicrosoftEdge@latest" PLATFORM="Windows 10"
# ie11
- node_js: '8'
env: TARGET=test-browser BROWSER="internet [email protected]" PLATFORM="Windows 8.1"
# ie10
- node_js: '8'
env: TARGET=test-browser BROWSER="internet [email protected]" PLATFORM="Windows 8"
# ie9
- node_js: '8'
env: TARGET=test-browser BROWSER="internet [email protected]" PLATFORM="Windows 7"
# ie8
- node_js: '8'
env: TARGET=test-browser BROWSER="internet [email protected]" PLATFORM="Windows 7"
# ie7
- node_js: '8'
env: TARGET=test-browser BROWSER="internet [email protected]" PLATFORM="Windows XP"
# firefox
- node_js: '8'
env: TARGET=test-browser BROWSER="firefox@latest" PLATFORM="Windows 8.1"
# safari
- node_js: '8'
env: TARGET=test-browser BROWSER="safari@latest" PLATFORM="OS X 10.11"

before_install: scripts/travis-before-install.sh

Expand All @@ -76,3 +48,4 @@ addons:
paths:
- .karma/
- ./mocha.js
sauce_connect: true
79 changes: 48 additions & 31 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ var mkdirp = require('mkdirp');
var baseBundleDirpath = path.join(__dirname, '.karma');
var osName = require('os-name');

var browserPlatformPairs = {
'chrome@latest': 'Windows 8',
'MicrosoftEdge@latest': 'Windows 10',
'internet [email protected]': 'Windows 8.1',
'internet [email protected]': 'Windows 8',
'internet [email protected]': 'Windows 7',
'firefox@latest': 'Windows 10',
'safari@latest': 'OS X 10.12'
};

module.exports = function (config) {
var bundleDirpath;
var cfg = {
Expand Down Expand Up @@ -51,7 +61,7 @@ module.exports = function (config) {
reporters: ['spec'],
colors: true,
browsers: [osName() === 'macOS Sierra' ? 'Chrome' : 'PhantomJS'], // This is the default browser to run, locally
logLevel: config.LOG_INFO,
logLevel: config.LOG_DEBUG,
client: {
mocha: {
reporter: 'html'
Expand Down Expand Up @@ -79,18 +89,17 @@ module.exports = function (config) {
if (env.TRAVIS) {
console.error('Travis-CI detected');
bundleDirpath = path.join(baseBundleDirpath, process.env.TRAVIS_BUILD_ID);
if (env.BROWSER && env.PLATFORM) {
if (env.SAUCE_USERNAME && env.SAUCE_ACCESS_KEY) {
// correlate build/tunnel with Travis
sauceConfig = {
build: 'TRAVIS #' + env.TRAVIS_BUILD_NUMBER +
if (env.SAUCE_USERNAME && env.SAUCE_ACCESS_KEY) {
// correlate build/tunnel with Travis
sauceConfig = {
build: 'TRAVIS #' + env.TRAVIS_BUILD_NUMBER +
' (' + env.TRAVIS_BUILD_ID + ')',
tunnelIdentifier: env.TRAVIS_JOB_NUMBER
};
console.error('Configured SauceLabs');
} else {
console.error('No SauceLabs credentials present');
}
tunnelIdentifier: env.TRAVIS_JOB_NUMBER,
startConnect: false
};
console.error('Configured SauceLabs');
} else {
console.error('No SauceLabs credentials present');
}
} else if (env.APPVEYOR) {
console.error('AppVeyor detected');
Expand All @@ -100,9 +109,11 @@ module.exports = function (config) {
bundleDirpath = path.join(baseBundleDirpath, 'local');
// don't need to run sauce from appveyor b/c travis does it.
if (env.SAUCE_USERNAME || env.SAUCE_ACCESS_KEY) {
var id = require('os').hostname() + ' (' + Date.now() + ')';
sauceConfig = {
build: require('os')
.hostname() + ' (' + Date.now() + ')'
build: id,
tunnelIdentifier: id,
startConnect: true
};
console.error('Configured SauceLabs');
} else {
Expand Down Expand Up @@ -140,31 +151,37 @@ module.exports = function (config) {
};

function addSauceTests (cfg) {
var env = process.env;
cfg.reporters.push('saucelabs');
cfg.customLaunchers = {};
cfg.customLaunchers[env.BROWSER] = {
base: 'SauceLabs',
browserName: env.BROWSER.split('@')[0],
version: env.BROWSER.split('@')[1],
platform: env.PLATFORM
};
cfg.browsers = [env.BROWSER];
var browsers = Object.keys(browserPlatformPairs);
cfg.browsers = cfg.browsers.concat(browsers);
cfg.customLaunchers = browsers.reduce(function (acc, browser) {
var platform = browserPlatformPairs[browser];
var browserParts = browser.split('@');
var browserName = browserParts[0];
var version = browserParts[1];
acc[browser] = {
base: 'SauceLabs',
browserName: browserName,
version: version,
platform: platform
};
return acc;
}, {});

// See https://github.com/karma-runner/karma-sauce-launcher
// See https://github.com/bermi/sauce-connect-launcher#advanced-usage
cfg.sauceLabs = {
Object.assign(cfg.sauceLabs, {
public: 'public',
startConnect: true,
connectOptions: {
connectRetries: 10,
connectRetryTimeout: 60000
connectRetries: 2,
connectRetryTimeout: 30000,
detached: cfg.sauceLabs.startConnect,
tunnelIdentifier: cfg.sauceLabs.tunnelIdentifier
}
};

cfg.concurrency = 5;
});

cfg.retryLimit = 5;
cfg.concurrency = Infinity;
cfg.retryLimit = 1;

// for slow browser booting, ostensibly
cfg.captureTimeout = 120000;
Expand Down
96 changes: 0 additions & 96 deletions test/node-unit/http-meta-2.spec.js

This file was deleted.

69 changes: 0 additions & 69 deletions test/node-unit/http-meta.spec.js

This file was deleted.

18 changes: 0 additions & 18 deletions test/node-unit/http.spec.js

This file was deleted.

0 comments on commit 0ed5297

Please sign in to comment.