Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ language: node_js
node_js:
- 4.2.2

addons:
# Run tests that require a browser on SauceLabs CI provider. Learn more at: https://saucelabs.com
sauce_connect:
username: k8s-dashboard-ci
access_key: "18b7e71b-60e9-4177-9a7f-e769977dbb39"

# Docker is required to set up a simple, single node Kubernetes cluster.
# Local Docker-based cluster is the simplest way to create kubernetes on the host machine.
services:
- docker

before_script:
# Prepare environment for the Chrome browser.
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start

script: ./node_modules/.bin/gulp check:local-cluster
after_script: ./node_modules/.bin/gulp coverage-codecov-upload
2 changes: 1 addition & 1 deletion build/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ gulp.task('wait-for-cluster', function(doneFn) {

// constantly query the cluster until it is properly running
clusterHealthCheck(function(result) {
if (result === 'ok') {
if (result === 'ok' && isRunningSetIntervalHandler !== null) {
gulpUtil.log(gulpUtil.colors.magenta('Kubernetes cluster is up and running.'));
clearTimeout(isRunningSetIntervalHandler);
isRunningSetIntervalHandler = null;
Expand Down
11 changes: 11 additions & 0 deletions build/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ export default {
rootModuleName: 'kubernetesDashboard',
},

/**
* Configuration for tests.
*/
test: {
/**
* Whether to use sauce labs for running tests that require a browser.
*/
useSauceLabs:
!!process.env.SAUCE_USERNAME && !!process.env.SAUCE_ACCESS_KEY && !!process.env.TRAVIS,
},

/**
* Absolute paths to known directories, e.g., to source directory.
*/
Expand Down
44 changes: 30 additions & 14 deletions build/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,9 @@ module.exports = function(config) {

frameworks: ['jasmine', 'browserify'],

browsers: ['Chrome'],

browserNoActivityTimeout: 60 * 1000, // 60 seconds.

customLaunchers: {
// Custom launcher for Travis CI. It is required because Travis environment cannot use
// sandbox.
chromeTravis: {
base: 'Chrome',
flags: ['--no-sandbox'],
},
},

reporters: ['progress', 'coverage'],
reporters: ['dots', 'coverage'],

coverageReporter: {
dir: conf.paths.coverage,
Expand All @@ -89,6 +78,7 @@ module.exports = function(config) {
'karma-ng-html2js-preprocessor',
'karma-sourcemap-loader',
'karma-browserify',
'karma-sauce-launcher',
],

// karma-browserify plugin config.
Expand All @@ -115,8 +105,34 @@ module.exports = function(config) {
};

// Use custom browser configuration when running on Travis CI.
if (process.env.TRAVIS) {
configuration.browsers = ['chromeTravis'];
if (conf.test.useSauceLabs) {
configuration.reporters.push('saucelabs');

let testName;
if (process.env.TRAVIS) {
testName = `Karma tests ${process.env.TRAVIS_REPO_SLUG}, build ` +
`${process.env.TRAVIS_BUILD_NUMBER}`;
if (process.env.TRAVIS_PULL_REQUEST !== 'false') {
testName += `, PR: https://github.com/${process.env.TRAVIS_REPO_SLUG}/pull/` +
`${process.env.TRAVIS_PULL_REQUEST}`;
}
} else {
testName = 'Local karma tests';
}

configuration.sauceLabs = {
testName: testName,
connectOptions: {port: 5757, logfile: 'sauce_connect.log'},
public: 'public',
},
configuration.customLaunchers = {
sl_chrome: {base: 'SauceLabs', browserName: 'chrome'},
sl_firefox: {base: 'SauceLabs', browserName: 'firefox'},
sl_ie: {base: 'SauceLabs', browserName: 'internet explorer'},
};
configuration.browsers = Object.keys(configuration.customLaunchers);
} else {
configuration.browsers = ['Chrome'];
}

// Convert all JS code written ES6 with modules to ES5 bundles that browsers can digest.
Expand Down
60 changes: 48 additions & 12 deletions build/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,61 @@
*
* TODO(bryk): Start using ES6 modules in this file when supported.
*/
/* eslint strict: [0] */
'use strict';
require('babel-core/register');
const conf = require('./conf').default;
const path = require('path');

/**
* Exported protractor config required by the framework.
*
* Schema can be found here: https://github.com/angular/protractor/blob/master/docs/referenceConf.js
* @return {!Object}
*/
exports.config = {
baseUrl: `http://localhost:${conf.frontend.serverPort}`,
function createConfig() {
const config = {
baseUrl: `http://localhost:${conf.frontend.serverPort}`,

framework: 'jasmine',

specs: [path.join(conf.paths.integrationTest, '**/*.js')],
};

if (conf.test.useSauceLabs) {
let name = `Integration tests ${process.env.TRAVIS_REPO_SLUG}, build ` +
`${process.env.TRAVIS_BUILD_NUMBER}`;
if (process.env.TRAVIS_PULL_REQUEST !== 'false') {
name += `, PR: https://github.com/${process.env.TRAVIS_REPO_SLUG}/pull/` +
`${process.env.TRAVIS_PULL_REQUEST}`;
}

capabilities: {
// Firefox is used instead of Chrome, because that's what Travis supports best.
// The browser that is used in the integration tests should not affect the results, anyway.
'browserName': 'firefox',
},
config.sauceUser = process.env.SAUCE_USERNAME;
config.sauceKey = process.env.SAUCE_ACCESS_KEY;
config.multiCapabilities = [
{
'browserName': 'chrome',
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
'name': name,
},
{
'browserName': 'firefox',
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
'name': name,
},
{
'browserName': 'internet explorer',
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER,
'name': name,
},
];

framework: 'jasmine',
} else {
config.capabilities = {'browserName': 'chrome'};
}

specs: [path.join(conf.paths.integrationTest, '**/*.js')],
};
return config;
}

/**
* Exported protractor config required by the framework.
*/
exports.config = createConfig();
3 changes: 1 addition & 2 deletions build/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ gulp.task('integration-test:prod', ['serve:prod', 'webdriver-update'], runProtra
* Runs application integration tests. Uses production version of the application.
*/
gulp.task(
'local-cluster-integration-test:prod', ['serve:prod', 'webdriver-update', 'local-up-cluster'],
runProtractorTests);
'local-cluster-integration-test:prod', ['serve:prod', 'local-up-cluster'], runProtractorTests);

/**
* Downloads and updates webdriver. Required to keep it up to date.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"karma-coverage": "~0.5.3",
"karma-jasmine": "~0.3.6",
"karma-ng-html2js-preprocessor": "~0.2.0",
"karma-sauce-launcher": "^0.3.0",
"karma-sourcemap-loader": "~0.3.6",
"lodash": "~4.1.0",
"proxy-middleware": "~0.15.0",
Expand Down