Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a905ebd

Browse files
authoredJun 21, 2018
Fixes failing CI tests (#428)
Upgrades tests to Node 8. Upgrades protractor to the latest version. Switches from phantomjs to headless chrome. Adds various new timeout durations to decrease likelihood of failure. Adds new criteria for test retry, though this needs more confirmation.
1 parent 0e445f3 commit a905ebd

File tree

6 files changed

+263
-273
lines changed

6 files changed

+263
-273
lines changed
 

‎.travis.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
language: node_js
22
node_js:
3-
- '6'
Code has comments. Press enter to view.
3+
- '8'
44
install: npm install
55
script: npm test -- --saucelabs
66
before_install:
7+
- export CHROME_BIN=/usr/bin/google-chrome
8+
- export DISPLAY=:99.0
9+
- sh -e /etc/init.d/xvfb start
10+
- sudo apt-get update
11+
- sudo apt-get install -y libappindicator1 fonts-liberation
12+
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
13+
- sudo dpkg -i google-chrome*.deb
714
- unset _JAVA_OPTIONS
815
addons:
916
sauce_connect: true

‎buildtools/run_tests.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,21 @@
4848
# Travis will run `npm test -- --saucelabs`.
4949

5050
cd "$(dirname $(dirname "$0"))"
51+
BIN_PATH="./node_modules/.bin"
52+
PROTRACTOR_BIN_PATH="./node_modules/protractor/bin"
5153

5254
function killServer () {
5355
if [ "$seleniumStarted" = true ]; then
5456
echo "Stopping Selenium..."
55-
./node_modules/.bin/webdriver-manager shutdown
56-
./node_modules/.bin/webdriver-manager clean
57+
$PROTRACTOR_BIN_PATH/webdriver-manager shutdown
58+
$PROTRACTOR_BIN_PATH/webdriver-manager clean
5759
fi
5860
echo "Killing HTTP Server..."
5961
kill $serverPid
6062
}
6163

6264
# Start the local webserver.
63-
./node_modules/.bin/gulp serve &
65+
$BIN_PATH/gulp serve &
6466
serverPid=$!
6567
echo "Local HTTP Server started with PID $serverPid."
6668

@@ -73,16 +75,18 @@ if [[ $1 = "--saucelabs" ]]; then
7375
sleep 2
7476
echo "Using SauceLabs."
7577
# $2 contains the tunnelIdentifier argument if specified, otherwise is empty.
76-
./node_modules/.bin/protractor protractor.conf.js --saucelabs $2
78+
$PROTRACTOR_BIN_PATH/protractor protractor.conf.js --saucelabs $2
7779
else
78-
echo "Using PhantomJS."
80+
echo "Using Headless Chrome."
7981
# Updates Selenium Webdriver.
80-
./node_modules/.bin/webdriver-manager update
82+
echo "$PROTRACTOR_BIN_PATH/webdriver-manager update --gecko=false"
83+
$PROTRACTOR_BIN_PATH/webdriver-manager update --gecko=false
8184
# Start Selenium Webdriver.
82-
./node_modules/.bin/webdriver-manager start &>/dev/null &
85+
echo "$PROTRACTOR_BIN_PATH/webdriver-manager start &>/dev/null &"
86+
$PROTRACTOR_BIN_PATH/webdriver-manager start &>/dev/null &
8387
seleniumStarted=true
8488
echo "Selenium Server started."
8589
# Wait for servers to come up.
8690
sleep 10
87-
./node_modules/.bin/protractor protractor.conf.js
91+
$PROTRACTOR_BIN_PATH/protractor protractor.conf.js
8892
fi

‎package-lock.json

Lines changed: 223 additions & 251 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@
4646
"gulp-sass": "^2.3.2",
4747
"gulp-util": "^3.0.7",
4848
"material-design-lite": "^1.2.0",
49-
"phantomjs-prebuilt": "^2.1.13",
Code has comments. Press enter to view.
50-
"protractor": "^4.0.9",
Code has comments. Press enter to view.
49+
"protractor": "^5.3.2",
5150
"streamqueue": "^1.1.1"
5251
},
5352
"dependencies": {

‎protractor.conf.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ config = {
4848
// Jasmine options. Increase the timeout to 5min instead of the default 30s.
4949
jasmineNodeOpts: {
5050
// Default time to wait in ms before a test fails.
51-
defaultTimeoutInterval: 5 * 60 * 1000
51+
defaultTimeoutInterval: 20 * 60 * 1000
5252
}
5353
};
5454

@@ -89,21 +89,27 @@ if (options.saucelabs) {
8989
}
9090
// Avoid going over the SauceLabs concurrency limit (5).
9191
config.maxSessions = 5;
92+
config.allScriptsTimeout = 10 * 60 * 1000;
9293
// List of browsers configurations tested.
9394
var sauceBrowsers = require('./sauce_browsers.json');
9495
// Configuration for SauceLabs browsers.
9596
config.multiCapabilities = sauceBrowsers.map(function(browser) {
9697
browser['tunnel-identifier'] = options.tunnelIdentifier;
98+
browser.maxDuration = 2000;
99+
browser.commandTimeout = 600;
100+
browser.idleTimeout = 120;
97101
return browser;
98102
});
99103
} else {
100-
// Configuration for phantomJS.
101-
config.seleniumAddress = 'http://localhost:4444/wd/hub';
102-
config.capabilities = {
103-
'browserName': 'phantomjs',
104-
'phantomjs.binary.path': require('phantomjs-prebuilt').path,
105-
'phantomjs.ghostdriver.cli.args': ['--loglevel=DEBUG']
106-
};
104+
// Configuration for headless chrome.
105+
config.directConnect = true;
106+
config.multiCapabilities = [{
107+
browserName: 'chrome',
108+
chromeOptions: {
109+
args: [ "--headless", "--disable-gpu", "--window-size=800,600",
110+
"--no-sandbox", "--disable-dev-shm-usage" ]
111+
}
112+
}];
107113
}
108114

109115
exports.config = config;

‎protractor_spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ var TEST_SERVER = 'http://localhost:4000';
1818

1919
var FLAKY_TEST_RETRIAL = 3;
2020

21+
var RETRY_MESSAGE_REGEX = /(ETIMEDOUT|WebDriverError|Internal Server Error|504)/;
22+
2123
describe('Run all Closure unit tests', function() {
2224
/**
2325
* Waits for current tests to be executed.
@@ -85,7 +87,7 @@ describe('Run all Closure unit tests', function() {
8587
}, function(err) {
8688
// If browser test execution times out try up to trial times.
8789
if (err.message &&
88-
err.message.indexOf('ETIMEDOUT') != -1 &&
90+
err.message.match(RETRY_MESSAGE_REGEX) &&
8991
tries > 0) {
9092
runRoutine(tries - 1, done);
9193
} else {
@@ -95,8 +97,8 @@ describe('Run all Closure unit tests', function() {
9597
}, function(err) {
9698
// If browser test execution times out try up to trial times.
9799
if (err.message &&
98-
err.message.indexOf('ETIMEOUT') != -1 &&
99-
trial > 0) {
100+
err.message.match(RETRY_MESSAGE_REGEX) &&
101+
tries > 0) {
100102
runRoutine(tries - 1, done);
101103
} else {
102104
done.fail(err);

0 commit comments

Comments
 (0)
Please sign in to comment.