Skip to content

Commit 61e0234

Browse files
devversiondylhunn
authored andcommitted
ci: attempt to increase stability of saucelabs legacy job (angular#44281)
This is an attempt to increase the stability of the Saucelabs legacy job by using an emulator recommended by the Saucelabs platform configurator, explicitly specifying the appium server version etc. PR Close angular#44281
1 parent 3aafa76 commit 61e0234

File tree

4 files changed

+156
-107
lines changed

4 files changed

+156
-107
lines changed

Diff for: browser-providers.conf.js

+20-82
Original file line numberDiff line numberDiff line change
@@ -10,98 +10,36 @@
1010
// If the target is set to null, then the browser is not run anywhere during CI.
1111
// If a category becomes empty (e.g. BS and required), then the corresponding job must be commented
1212
// out in the CI configuration.
13-
var CIconfiguration = {
14-
// Chrome and Firefox run as part of the Bazel browser tests, so we do not run them as
15-
// part of the legacy Saucelabs tests.
16-
'Chrome': {unitTest: {target: null, required: false}, e2e: {target: null, required: true}},
17-
'Firefox': {unitTest: {target: null, required: false}, e2e: {target: null, required: true}},
18-
// Set ESR as a not required browser as it fails for Ivy acceptance tests.
19-
'FirefoxESR': {unitTest: {target: 'SL', required: false}, e2e: {target: null, required: true}},
20-
// Disabled because using the "beta" channel of Chrome can cause non-deterministic CI results.
21-
// e.g. a new chrome beta version has been released, but the Saucelabs selenium server does
22-
// not provide a chromedriver version that is compatible with the new beta.
23-
'ChromeBeta': {unitTest: {target: 'SL', required: false}, e2e: {target: null, required: false}},
24-
'ChromeDev': {unitTest: {target: 'SL', required: false}, e2e: {target: null, required: true}},
25-
// FirefoxBeta and FirefoxDev should be target:'BS' or target:'SL', and required:true
26-
// Currently deactivated due to https://github.com/angular/angular/issues/7560
27-
'FirefoxBeta': {unitTest: {target: null, required: true}, e2e: {target: null, required: false}},
28-
'FirefoxDev': {unitTest: {target: null, required: true}, e2e: {target: null, required: true}},
29-
'Edge': {unitTest: {target: 'SL', required: false}, e2e: {target: null, required: true}},
30-
'Android10': {unitTest: {target: 'SL', required: true}, e2e: {target: null, required: true}},
31-
'Android11': {unitTest: {target: 'SL', required: true}, e2e: {target: null, required: true}},
32-
'Safari12': {unitTest: {target: 'SL', required: false}, e2e: {target: null, required: true}},
33-
'Safari13': {unitTest: {target: 'SL', required: false}, e2e: {target: null, required: true}},
34-
'iOS12': {unitTest: {target: 'SL', required: false}, e2e: {target: null, required: true}},
35-
'iOS13': {unitTest: {target: 'SL', required: false}, e2e: {target: null, required: true}},
36-
'WindowsPhone': {unitTest: {target: 'BS', required: false}, e2e: {target: null, required: true}}
13+
const config = {
14+
'Android10': {unitTest: {target: 'SL', required: true}},
15+
'Android11': {unitTest: {target: 'SL', required: true}},
3716
};
3817

39-
var customLaunchers = {
40-
'DartiumWithWebPlatform':
41-
{base: 'Dartium', flags: ['--enable-experimental-web-platform-features']},
42-
'ChromeNoSandbox': {base: 'Chrome', flags: ['--no-sandbox']},
43-
'SL_CHROME': {base: 'SauceLabs', browserName: 'chrome', version: '81'},
44-
'SL_CHROMEBETA': {base: 'SauceLabs', browserName: 'chrome', version: 'beta'},
45-
'SL_CHROMEDEV': {base: 'SauceLabs', browserName: 'chrome', version: 'dev'},
46-
'SL_FIREFOX': {base: 'SauceLabs', browserName: 'firefox', version: '76'},
47-
// Firefox 68 is the current ESR vesion
48-
'SL_FIREFOXESR': {base: 'SauceLabs', browserName: 'firefox', version: '68'},
49-
'SL_FIREFOXBETA':
50-
{base: 'SauceLabs', platform: 'Windows 10', browserName: 'firefox', version: 'beta'},
51-
'SL_FIREFOXDEV':
52-
{base: 'SauceLabs', platform: 'Windows 10', browserName: 'firefox', version: 'dev'},
53-
'SL_SAFARI12':
54-
{base: 'SauceLabs', browserName: 'safari', platform: 'macOS 10.13', version: '12.1'},
55-
'SL_SAFARI13':
56-
{base: 'SauceLabs', browserName: 'safari', platform: 'macOS 10.15', version: '13.0'},
57-
'SL_IOS12': {
58-
base: 'SauceLabs',
59-
browserName: 'Safari',
60-
platform: 'iOS',
61-
version: '12.0',
62-
device: 'iPhone 7 Simulator'
63-
},
64-
'SL_IOS13': {
65-
base: 'SauceLabs',
66-
browserName: 'Safari',
67-
platform: 'iOS',
68-
version: '13.0',
69-
device: 'iPhone 11 Simulator'
70-
},
71-
'SL_EDGE': {
72-
base: 'SauceLabs',
73-
browserName: 'MicrosoftEdge',
74-
platform: 'Windows 10',
75-
version: '14.14393'
76-
},
18+
/** Whether browsers should be remotely acquired in debug mode. */
19+
const debugMode = false;
20+
21+
const customLaunchers = {
7722
'SL_ANDROID10': {
7823
base: 'SauceLabs',
7924
browserName: 'Chrome',
80-
platform: 'Android',
81-
version: '10.0',
82-
device: 'Android GoogleAPI Emulator'
25+
platformName: 'Android',
26+
platformVersion: '10.0',
27+
deviceName: 'Google Pixel 3a GoogleAPI Emulator',
28+
appiumVersion: '1.20.2',
29+
extendedDebugging: debugMode,
8330
},
8431
'SL_ANDROID11': {
8532
base: 'SauceLabs',
8633
browserName: 'Chrome',
87-
platform: 'Android',
88-
version: '11.0',
89-
device: 'Android GoogleAPI Emulator'
34+
platformName: 'Android',
35+
platformVersion: '11.0',
36+
deviceName: 'Google Pixel 3a GoogleAPI Emulator',
37+
appiumVersion: '1.20.2',
38+
extendedDebugging: debugMode,
9039
},
9140
};
9241

93-
var sauceAliases = {
94-
'ALL': Object.keys(customLaunchers).filter(function(item) {
95-
return customLaunchers[item].base == 'SauceLabs';
96-
}),
97-
'DESKTOP': ['SL_CHROME', 'SL_FIREFOX', 'SL_EDGE', 'SL_SAFARI12', 'SL_SAFARI13', 'SL_FIREFOXESR'],
98-
'MOBILE': ['SL_ANDROID10', 'SL_ANDROID11', 'SL_IOS12', 'SL_IOS13'],
99-
'ANDROID': ['SL_ANDROID10', 'SL_ANDROID11'],
100-
'FIREFOX': ['SL_FIREFOXESR'],
101-
'IOS': ['SL_IOS12', 'SL_IOS13'],
102-
'SAFARI': ['SL_SAFARI12', 'SL_SAFARI13'],
103-
'BETA': ['SL_CHROMEBETA', 'SL_FIREFOXBETA'],
104-
'DEV': ['SL_CHROMEDEV', 'SL_FIREFOXDEV'],
42+
const sauceAliases = {
10543
'CI_REQUIRED': buildConfiguration('unitTest', 'SL', true),
10644
'CI_OPTIONAL': buildConfiguration('unitTest', 'SL', false)
10745
};
@@ -112,9 +50,9 @@ module.exports = {
11250
};
11351

11452
function buildConfiguration(type, target, required) {
115-
return Object.keys(CIconfiguration)
53+
return Object.keys(config)
11654
.filter((item) => {
117-
var conf = CIconfiguration[item][type];
55+
const conf = config[item][type];
11856
return conf.required === required && conf.target === target;
11957
})
12058
.map((item) => target + '_' + item.toUpperCase());

Diff for: karma-js.conf.js

+19-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ const browserProvidersConf = require('./browser-providers.conf');
1010
const {generateSeed} = require('./tools/jasmine-seed-generator');
1111
const {hostname} = require('os');
1212

13-
// Karma configuration
14-
// Generated on Thu Sep 25 2014 11:52:02 GMT-0700 (PDT)
1513
module.exports = function(config) {
1614
const conf = {
1715
frameworks: ['jasmine'],
@@ -21,7 +19,7 @@ module.exports = function(config) {
2119
random: true,
2220
seed: generateSeed('karma-js.conf'),
2321
},
24-
captureConsole: process.env.CI ? false : true,
22+
captureConsole: true,
2523
},
2624

2725
files: [
@@ -133,8 +131,8 @@ module.exports = function(config) {
133131
maxDuration: 5400,
134132
},
135133

136-
// Try "websocket" for a faster transmission first. Fallback to "polling" if necessary.
137-
transports: ['websocket', 'polling'],
134+
// Always use `polling` for increased communication stability.
135+
transports: ['polling'],
138136

139137
port: 9876,
140138
captureTimeout: 180000,
@@ -151,6 +149,15 @@ module.exports = function(config) {
151149
set: () => {},
152150
});
153151

152+
if (process.env.CIRCLECI) {
153+
conf.frameworks.unshift('parallel');
154+
conf.plugins.unshift(require('karma-parallel'));
155+
conf.parallelOptions = {
156+
executors: 2,
157+
shardStrategy: 'round-robin',
158+
};
159+
}
160+
154161
if (process.env['SAUCE_TUNNEL_IDENTIFIER']) {
155162
console.log(`SAUCE_TUNNEL_IDENTIFIER: ${process.env.SAUCE_TUNNEL_IDENTIFIER}`);
156163

@@ -159,6 +166,13 @@ module.exports = function(config) {
159166
// Setup the Saucelabs plugin so that it can launch browsers using the proper tunnel.
160167
conf.sauceLabs.build = tunnelIdentifier;
161168
conf.sauceLabs.tunnelIdentifier = tunnelIdentifier;
169+
170+
// Patch the `saucelabs` package so that `karma-sauce-launcher` does not attempt downloading
171+
// the test logs from upstream and tries re-uploading them with the Karma enhanced details.
172+
// This slows-down tests/browser restarting and can decrease stability.
173+
// https://github.com/karma-runner/karma-sauce-launcher/blob/59b0c5c877448e064ad56449cd906743721c6b62/src/launcher/launcher.ts#L72-L79.
174+
require('saucelabs').default.prototype.downloadJobAsset =
175+
() => Promise.resolve('<FAKE-LOGS>');
162176
}
163177

164178
// For SauceLabs jobs, we set up a domain which resolves to the machine which launched

Diff for: package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,10 @@
176176
"gulp-conventional-changelog": "^2.0.35",
177177
"husky": "7.0.4",
178178
"inquirer": "^8.0.0",
179+
"karma-parallel": "^0.3.1",
179180
"karma-sauce-launcher": "^4.3.6",
180181
"madge": "^5.0.0",
181-
"sauce-connect": "https://saucelabs.com/downloads/sc-4.6.2-linux.tar.gz",
182+
"sauce-connect": "https://saucelabs.com/downloads/sc-4.7.1-linux.tar.gz",
182183
"semver": "^7.3.5",
183184
"ts-node": "^10.0.0",
184185
"tsec": "0.2.0",
@@ -192,6 +193,7 @@
192193
"// 5": "Ensure a single version of webdriver-manager so it is hoisted as the integration tests depend on it being found at ../../node_modules/webdriver-manager",
193194
"// 6": "Ensure that `@babel/*` packages match the below versions to avoid conflicts with `types/babel__*`",
194195
"// 7": "Ensure that transitive dependencies on `https-proxy-agent` are at minimum v5 as older versions patch NodeJS directly, breaking tools like webdriver which is used by the karma-sauce-launcher as an example.",
196+
"// 8": "Ensure that a single instance of the `saucelabs` package is used. Protractor and the Karma sauce launcher pull this package as dependency. A single instance allows for e.g. easier patching in the Karma config.",
195197
"resolutions": {
196198
"**/graceful-fs": "4.2.8",
197199
"**/webdriver-manager": "12.1.8",
@@ -202,6 +204,7 @@
202204
"@babel/template": "7.8.6",
203205
"@babel/traverse": "7.8.6",
204206
"@babel/types": "7.8.6",
205-
"**/https-proxy-agent": "5.0.0"
207+
"**/https-proxy-agent": "5.0.0",
208+
"**/saucelabs": "4.7.8"
206209
}
207210
}

0 commit comments

Comments
 (0)