[functional testing] Centralize server configs

This commit is contained in:
Jonathan Budzenski 2015-10-26 13:07:02 -05:00
parent 94996e8442
commit 8af41458ae
5 changed files with 45 additions and 31 deletions

View file

@ -2,6 +2,7 @@ module.exports = function (grunt) {
var resolve = require('path').resolve;
var directory = resolve(__dirname, '../../esvm');
var dataDir = resolve(directory, 'data_dir');
var uiConfig = require('requirefrom')('test')('serverConfig');
return {
options: {
@ -43,7 +44,7 @@ module.exports = function (grunt) {
purge: true,
config: {
http: {
port: 9220
port: uiConfig.elasticsearch.port
}
}
}

View file

@ -1,8 +1,10 @@
module.exports = function (grunt) {
let platform = require('os').platform();
let {format} = require('url');
let {resolve} = require('path');
let root = p => resolve(__dirname, '../../', p);
let binScript = /^win/.test(platform) ? '.\\bin\\kibana.bat' : './bin/kibana';
let uiConfig = require(root('test/serverConfig'));
return {
testServer: {
@ -31,8 +33,8 @@ module.exports = function (grunt) {
},
cmd: /^win/.test(platform) ? '.\\bin\\kibana.bat' : './bin/kibana',
args: [
'--server.port=5620',
'--elasticsearch.url=http://localhost:9220',
'--server.port=' + uiConfig.kibana.port,
'--elasticsearch.url=' + format(uiConfig.elasticsearch),
'--logging.json=false'
]
},
@ -85,7 +87,9 @@ module.exports = function (grunt) {
cmd: 'java',
args: [
'-jar',
'selenium/selenium-server-standalone-2.47.1.jar'
'selenium/selenium-server-standalone-2.47.1.jar',
'-port',
uiConfig.webdriver.port
]
},
@ -99,7 +103,9 @@ module.exports = function (grunt) {
cmd: 'java',
args: [
'-jar',
'selenium/selenium-server-standalone-2.47.1.jar'
'selenium/selenium-server-standalone-2.47.1.jar',
'-port',
uiConfig.webdriver.port
]
},

View file

@ -1,27 +1,17 @@
define({
capabilities: {
'selenium-version': '2.47.1',
'idle-timeout': 30
},
environments: [
{
define(function (require) {
var serverConfig = require('intern/dojo/node!./serverConfig');
var _ = require('intern/dojo/node!lodash');
return _.assign({
capabilities: {
'selenium-version': '2.47.1',
'idle-timeout': 30
},
environments: [{
browserName: 'firefox'
}
],
webdriver: {
host: 'localhost',
port: 4444
},
kibana: {
protocol: 'http',
hostname: 'localhost',
port: 5620
},
elasticsearch: {
protocol: 'http',
hostname: 'localhost',
port: 9220
},
functionalSuites: ['test/functional/status.js'],
excludeInstrumentation: /(fixtures|node_modules)\//
}],
tunnelOptions: serverConfig.webdriver,
functionalSuites: ['test/functional/status.js'],
excludeInstrumentation: /(fixtures|node_modules)\//
}, serverConfig);
});

17
test/serverConfig.js Normal file
View file

@ -0,0 +1,17 @@
module.exports = {
webdriver: {
protocol: process.env.TEST_UI_WEBDRIVER_PROTOCOL || 'http',
hostname: process.env.TEST_UI_WEBDRIVER_HOSTNAME || 'localhost',
port: parseInt(process.env.TEST_UI_WEBDRIVER_PORT, 10) || 4444
},
kibana: {
protocol: process.env.TEST_UI_KIBANA_PROTOCOL || 'http',
hostname: process.env.TEST_UI_KIBANA_HOSTNAME || 'localhost',
port: parseInt(process.env.TEST_UI_KIBANA_PORT, 10) || 5620
},
elasticsearch: {
protocol: process.env.TEST_UI_ES_PROTOCOL || 'http',
hostname: process.env.TEST_UI_ES_HOSTNAME || 'localhost',
port: parseInt(process.env.TEST_UI_ES_PORT, 10) || 9220
}
};

View file

@ -2,7 +2,7 @@ var expect = require('expect.js');
var getUrl = require('../getUrl');
describe('getUrl', function () {
it('should be able to convert a config and a path to a url', function() {
it('should be able to convert a config and a path to a url', function () {
expect(getUrl({
protocol: 'http',
hostname: 'localhost',