Skip to content

Commit

Permalink
Replace xvfb with headless browser (#24904) (#25151)
Browse files Browse the repository at this point in the history
* Replace xvfb with headless browser

* Update karma to run in headless chrome

Update Karma tests for an option to run chrome in headless.

* Fix lint issues

* Fix spaces
  • Loading branch information
liza-mae authored Nov 5, 2018
1 parent cf3de7b commit 3a5e748
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
20 changes: 13 additions & 7 deletions tasks/config/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

import { resolve, dirname } from 'path';
import { platform as getOsPlatform } from 'os';
import { times } from 'lodash';

const TOTAL_CI_SHARDS = 4;
Expand All @@ -29,13 +28,10 @@ module.exports = function (grunt) {
if (grunt.option('browser')) {
return grunt.option('browser');
}

switch (getOsPlatform()) {
case 'win32':
return 'Chrome';
default:
return 'Chrome';
if (process.env.TEST_BROWSER_HEADLESS) {
return 'Chrome_Headless';
}
return 'Chrome';
}

const config = {
Expand All @@ -51,6 +47,16 @@ module.exports = function (grunt) {
logLevel: grunt.option('debug') || grunt.option('verbose') ? 'DEBUG' : 'INFO',
autoWatch: false,
browsers: [pickBrowser()],
customLaunchers: {
Chrome_Headless: {
base: 'Chrome',
flags: [
'--headless',
'--disable-gpu',
'--remote-debugging-port=9222',
],
},
},

// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: process.env.CI ? ['dots', 'junit'] : ['progress'],
Expand Down
3 changes: 2 additions & 1 deletion test/scripts/jenkins_cloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ set -e

source "$(dirname $0)/../../src/dev/ci_setup/setup.sh"

xvfb-run node scripts/functional_test_runner --debug --exclude-tag skipCloud $@
TEST_BROWSER_HEADLESS=1
node scripts/functional_test_runner --debug --exclude-tag skipCloud $@
3 changes: 2 additions & 1 deletion test/scripts/jenkins_selenium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ source "$(dirname $0)/../../src/dev/ci_setup/java_setup.sh"

node scripts/build --release --debug --oss;

export TEST_BROWSER_HEADLESS=1
export TEST_ES_FROM=${TEST_ES_FROM:-source}
xvfb-run "$(FORCE_COLOR=0 yarn bin)/grunt" jenkins:selenium --from=source;
"$(FORCE_COLOR=0 yarn bin)/grunt" jenkins:selenium --from=source;
3 changes: 2 additions & 1 deletion test/scripts/jenkins_unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ source "$(dirname $0)/../../src/dev/ci_setup/setup.sh"
source "$(dirname $0)/../../src/dev/ci_setup/git_setup.sh"
source "$(dirname $0)/../../src/dev/ci_setup/java_setup.sh"

export TEST_BROWSER_HEADLESS=1
export TEST_ES_FROM=${TEST_ES_FROM:-source}
xvfb-run "$(FORCE_COLOR=0 yarn bin)/grunt" jenkins:unit --from=source;
"$(FORCE_COLOR=0 yarn bin)/grunt" jenkins:unit --from=source;
6 changes: 3 additions & 3 deletions test/scripts/jenkins_xpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ source "$(dirname $0)/../../src/dev/ci_setup/setup.sh"
source "$(dirname $0)/../../src/dev/ci_setup/git_setup.sh"
source "$(dirname $0)/../../src/dev/ci_setup/java_setup.sh"


export TEST_BROWSER_HEADLESS=1
export XPACK_DIR="$(cd "$(dirname "$0")/../../x-pack"; pwd)"
echo "-> XPACK_DIR ${XPACK_DIR}"


echo " -> Running mocha tests"
cd "$XPACK_DIR"
xvfb-run yarn test
yarn test
echo ""
echo ""

Expand All @@ -37,6 +37,6 @@ tar -xzf "$linuxBuild" -C "$installDir" --strip=1
export TEST_ES_FROM=${TEST_ES_FROM:-source}
echo " -> Running functional and api tests"
cd "$XPACK_DIR"
xvfb-run node scripts/functional_tests --debug --bail --kibana-install-dir "$installDir"
node scripts/functional_tests --debug --bail --kibana-install-dir "$installDir"
echo ""
echo ""

0 comments on commit 3a5e748

Please sign in to comment.