Skip to content

Commit

Permalink
[test/common] put server config into common
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed May 17, 2017
1 parent 7851ed8 commit cd2f336
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import sinon from 'sinon';
import expect from 'expect.js';
import url from 'url';

import serverConfig from '../../../../../test/server_config';
import { esTestServerUrlParts } from '../../../../../test/es_test_server_url_parts';
import { ensureEsVersion } from '../ensure_es_version';

describe('plugins/elasticsearch', () => {
Expand All @@ -22,7 +22,7 @@ describe('plugins/elasticsearch', () => {
status: {
red: sinon.stub()
},
url: url.format(serverConfig.servers.elasticsearch)
url: url.format(esTestServerUrlParts)
}
}
};
Expand Down
6 changes: 3 additions & 3 deletions src/core_plugins/elasticsearch/lib/__tests__/health_check.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const NoConnections = require('elasticsearch').errors.NoConnections;
import mappings from './fixtures/mappings';
import healthCheck from '../health_check';
import kibanaVersion from '../kibana_version';
import serverConfig from '../../../../../test/server_config';
import { esTestServerUrlParts } from '../../../../../test/es_test_server_url_parts';

const esPort = serverConfig.servers.elasticsearch.port;
const esUrl = url.format(serverConfig.servers.elasticsearch);
const esPort = esTestServerUrlParts.port;
const esUrl = url.format(esTestServerUrlParts);

describe('plugins/elasticsearch', () => {
describe('lib/health_check', function () {
Expand Down
4 changes: 2 additions & 2 deletions src/test_utils/kbn_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import url from 'url';
import { defaultsDeep, set } from 'lodash';
import { header as basicAuthHeader } from './base_auth';
import { kibanaUser, kibanaServer } from '../../test/shield';
import serverConfig from '../../test/server_config';
import { esTestServerUrlParts } from '../../test/es_test_server_url_parts';
import KbnServer from '../../src/server/kbn_server';

const SERVER_DEFAULTS = {
Expand All @@ -20,7 +20,7 @@ const SERVER_DEFAULTS = {
enabled: false
},
elasticsearch: {
url: url.format(serverConfig.servers.elasticsearch),
url: url.format(esTestServerUrlParts),
username: kibanaServer.username,
password: kibanaServer.password
}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/utils/__tests__/scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import ngMock from 'ng_mock';
import sinon from 'sinon';
import url from 'url';

import serverConfig from '../../../../../test/server_config';
import { esTestServerUrlParts } from '../../../../../test/es_test_server_url_parts';

describe('Scanner', function () {
let es;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (esFactory) {
es = esFactory({
host: url.format(serverConfig.servers.elasticsearch),
host: url.format(esTestServerUrlParts),
defer: function () {
return Bluebird.defer();
}
Expand Down
11 changes: 6 additions & 5 deletions tasks/config/esvm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import serverConfig from '../../test/server_config';
import { esTestServerUrlParts } from '../../test/es_test_server_url_parts';

module.exports = function (grunt) {
const resolve = require('path').resolve;
const directory = resolve(__dirname, '../../esvm');
Expand Down Expand Up @@ -92,7 +93,7 @@ module.exports = function (grunt) {
purge: true,
config: {
http: {
port: serverConfig.servers.elasticsearch.port
port: esTestServerUrlParts.port
},
cluster: {
name: 'esvm-test'
Expand All @@ -101,7 +102,7 @@ module.exports = function (grunt) {
zen: {
ping: {
unicast: {
hosts: [ `localhost:${serverConfig.servers.elasticsearch.port}` ]
hosts: [ `localhost:${esTestServerUrlParts.port}` ]
}
}
}
Expand All @@ -116,7 +117,7 @@ module.exports = function (grunt) {
purge: true,
config: {
http: {
port: serverConfig.servers.elasticsearch.port
port: esTestServerUrlParts.port
},
cluster: {
name: 'esvm-ui'
Expand All @@ -125,7 +126,7 @@ module.exports = function (grunt) {
zen: {
ping: {
unicast: {
hosts: [ `localhost:${serverConfig.servers.elasticsearch.port}` ]
hosts: [ `localhost:${esTestServerUrlParts.port}` ]
}
}
}
Expand Down
21 changes: 10 additions & 11 deletions tasks/config/run.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { format } from 'url';
import { resolve } from 'path';
import { esTestServerUrlParts } from '../../test/es_test_server_url_parts';
import { kibanaTestServerUrlParts } from '../../test/kibana_test_server_url_parts';

module.exports = function (grunt) {
const platform = require('os').platform();
const root = p => resolve(__dirname, '../../', p);
const binScript = /^win/.test(platform) ? '.\\bin\\kibana.bat' : './bin/kibana';
const buildScript = /^win/.test(platform) ? '.\\build\\kibana\\bin\\kibana.bat' : './build/kibana/bin/kibana';
const pkgVersion = grunt.config.get('pkg.version');
const releaseBinScript = `./build/kibana-${pkgVersion}-linux-x86_64/bin/kibana`;
const uiConfig = require(root('test/server_config'));

const stdDevArgs = [
'--env.name=development',
Expand Down Expand Up @@ -56,8 +55,8 @@ module.exports = function (grunt) {
args: [
...stdDevArgs,
'--optimize.enabled=false',
'--elasticsearch.url=' + format(uiConfig.servers.elasticsearch),
'--server.port=' + uiConfig.servers.kibana.port,
'--elasticsearch.url=' + format(esTestServerUrlParts),
'--server.port=' + kibanaTestServerUrlParts.port,
'--server.xsrf.disableProtection=true',
...kbnServerFlags,
]
Expand All @@ -73,8 +72,8 @@ module.exports = function (grunt) {
cmd: binScript,
args: [
...stdDevArgs,
'--server.port=' + uiConfig.servers.kibana.port,
'--elasticsearch.url=' + format(uiConfig.servers.elasticsearch),
'--server.port=' + kibanaTestServerUrlParts.port,
'--elasticsearch.url=' + format(esTestServerUrlParts),
...kbnServerFlags,
]
},
Expand All @@ -89,8 +88,8 @@ module.exports = function (grunt) {
cmd: releaseBinScript,
args: [
...stdDevArgs,
'--server.port=' + uiConfig.servers.kibana.port,
'--elasticsearch.url=' + format(uiConfig.servers.elasticsearch),
'--server.port=' + kibanaTestServerUrlParts.port,
'--elasticsearch.url=' + format(esTestServerUrlParts),
...kbnServerFlags,
]
},
Expand All @@ -105,8 +104,8 @@ module.exports = function (grunt) {
cmd: binScript,
args: [
...stdDevArgs,
'--server.port=' + uiConfig.servers.kibana.port,
'--elasticsearch.url=' + format(uiConfig.servers.elasticsearch),
'--server.port=' + kibanaTestServerUrlParts.port,
'--elasticsearch.url=' + format(esTestServerUrlParts),
'--dev',
'--no-base-path',
'--no-ssl',
Expand Down
4 changes: 1 addition & 3 deletions test/api_integration/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {
SupertestProvider,
} from './services';

import { servers } from '../server_config';

export default async function ({ readConfigFile }) {
const commonConfig = await readConfigFile(require.resolve('../common/config'));

Expand All @@ -18,7 +16,7 @@ export default async function ({ readConfigFile }) {
esArchiver: commonConfig.get('services.esArchiver'),
supertest: SupertestProvider,
},
servers,
servers: commonConfig.get('servers'),
esArchiver: {
directory: resolve(__dirname, './fixtures/es_archives')
},
Expand Down
7 changes: 7 additions & 0 deletions test/common/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ import {
EsArchiverProvider,
} from './services';

import { esTestServerUrlParts } from '../es_test_server_url_parts';
import { kibanaTestServerUrlParts } from '../kibana_test_server_url_parts';

export default function () {
return {
servers: {
kibana: kibanaTestServerUrlParts,
elasticsearch: esTestServerUrlParts,
},
services: {
kibanaServer: KibanaServerProvider,
es: EsProvider,
Expand Down
10 changes: 10 additions & 0 deletions test/es_test_server_url_parts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const shield = require('./shield');

export const esTestServerUrlParts = {
protocol: process.env.TEST_ES_PROTOCOL || 'http',
hostname: process.env.TEST_ES_HOSTNAME || 'localhost',
port: parseInt(process.env.TEST_ES_PORT, 10) || 9220,
auth: shield.admin.username + ':' + shield.admin.password,
username: shield.admin.username,
password: shield.admin.password,
};
34 changes: 30 additions & 4 deletions test/functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import {
ScreenshotsProvider,
} from './services';

import { servers, apps } from '../server_config';

export default async function ({ readConfigFile }) {
const commonConfig = await readConfigFile(require.resolve('../common/config'));

Expand Down Expand Up @@ -65,8 +63,36 @@ export default async function ({ readConfigFile }) {
docTable: DocTableProvider,
screenshots: ScreenshotsProvider,
},
servers,
apps,
servers: commonConfig.get('servers'),
apps: {
status_page: {
pathname: '/status',
},
discover: {
pathname: '/app/kibana',
hash: '/discover',
},
context: {
pathname: '/app/kibana',
hash: '/context',
},
visualize: {
pathname: '/app/kibana',
hash: '/visualize',
},
dashboard: {
pathname: '/app/kibana',
hash: '/dashboards',
},
settings: {
pathname: '/app/kibana',
hash: '/management',
},
console: {
pathname: '/app/kibana',
hash: '/dev_tools/console',
},
},
esArchiver: {
directory: resolve(__dirname, './fixtures/es_archives')
},
Expand Down
2 changes: 1 addition & 1 deletion test/functional/page_objects/common_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function CommonPageProvider({ getService, getPageObjects }) {
}

/**
* @param {string} appName As defined in the apps objects in test/server_config.js
* @param {string} appName As defined in the apps config
* @param {string} subUrl The route after the hash (#)
*/
navigateToUrl(appName, subUrl) {
Expand Down
10 changes: 10 additions & 0 deletions test/kibana_test_server_url_parts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const shield = require('./shield');

export const kibanaTestServerUrlParts = {
protocol: process.env.TEST_KIBANA_PROTOCOL || 'http',
hostname: process.env.TEST_KIBANA_HOSTNAME || 'localhost',
port: parseInt(process.env.TEST_KIBANA_PORT, 10) || 5620,
auth: shield.kibanaUser.username + ':' + shield.kibanaUser.password,
username: shield.kibanaUser.username,
password: shield.kibanaUser.password,
};
52 changes: 0 additions & 52 deletions test/server_config.js

This file was deleted.

0 comments on commit cd2f336

Please sign in to comment.