mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
Merge pull request #6526 from bevacqua/cleanup/elasticsearch-url-softcoded
Consolidate elasticsearch URL in configuration file. Fixes #5555
This commit is contained in:
commit
dc87fe1884
6 changed files with 25 additions and 12 deletions
|
@ -1,7 +1,9 @@
|
|||
import _ from 'lodash';
|
||||
import Promise from 'bluebird';
|
||||
import sinon from 'sinon';
|
||||
import url from 'url';
|
||||
|
||||
import serverConfig from '../../../../../test/serverConfig';
|
||||
import checkEsVersion from '../check_es_version';
|
||||
|
||||
describe('plugins/elasticsearch', function () {
|
||||
|
@ -23,7 +25,7 @@ describe('plugins/elasticsearch', function () {
|
|||
status: {
|
||||
red: sinon.stub()
|
||||
},
|
||||
url: 'http://localhost:9210'
|
||||
url: url.format(serverConfig.servers.elasticsearch)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
import Promise from 'bluebird';
|
||||
import sinon from 'sinon';
|
||||
import expect from 'expect.js';
|
||||
import url from 'url';
|
||||
|
||||
const NoConnections = require('elasticsearch').errors.NoConnections;
|
||||
|
||||
import healthCheck from '../health_check';
|
||||
import serverConfig from '../../../../../test/serverConfig';
|
||||
|
||||
const esPort = serverConfig.servers.elasticsearch.port;
|
||||
const esUrl = url.format(serverConfig.servers.elasticsearch);
|
||||
|
||||
describe('plugins/elasticsearch', function () {
|
||||
describe('lib/health_check', function () {
|
||||
|
@ -39,7 +45,7 @@ describe('plugins/elasticsearch', function () {
|
|||
nodes: {
|
||||
'node-01': {
|
||||
version: '1.5.0',
|
||||
http_address: 'inet[/127.0.0.1:9210]',
|
||||
http_address: `inet[/127.0.0.1:${esPort}]`,
|
||||
ip: '127.0.0.1'
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +79,7 @@ describe('plugins/elasticsearch', function () {
|
|||
|
||||
it('should set the cluster red if the ping fails, then to green', function () {
|
||||
|
||||
get.withArgs('elasticsearch.url').returns('http://localhost:9210');
|
||||
get.withArgs('elasticsearch.url').returns(esUrl);
|
||||
get.withArgs('elasticsearch.engineVersion').returns('^1.4.4');
|
||||
get.withArgs('kibana.index').returns('.my-kibana');
|
||||
client.ping.onCall(0).returns(Promise.reject(new NoConnections()));
|
||||
|
@ -85,7 +91,7 @@ describe('plugins/elasticsearch', function () {
|
|||
expect(plugin.status.yellow.args[0][0]).to.be('Waiting for Elasticsearch');
|
||||
sinon.assert.calledOnce(plugin.status.red);
|
||||
expect(plugin.status.red.args[0][0]).to.be(
|
||||
'Unable to connect to Elasticsearch at http://localhost:9210.'
|
||||
`Unable to connect to Elasticsearch at ${esUrl}.`
|
||||
);
|
||||
sinon.assert.calledTwice(client.ping);
|
||||
sinon.assert.calledOnce(client.nodes.info);
|
||||
|
@ -97,7 +103,7 @@ describe('plugins/elasticsearch', function () {
|
|||
});
|
||||
|
||||
it('should set the cluster red if the health check status is red, then to green', function () {
|
||||
get.withArgs('elasticsearch.url').returns('http://localhost:9210');
|
||||
get.withArgs('elasticsearch.url').returns(esUrl);
|
||||
get.withArgs('elasticsearch.engineVersion').returns('^1.4.4');
|
||||
get.withArgs('kibana.index').returns('.my-kibana');
|
||||
client.ping.returns(Promise.resolve());
|
||||
|
@ -120,7 +126,7 @@ describe('plugins/elasticsearch', function () {
|
|||
});
|
||||
|
||||
it('should set the cluster yellow if the health check timed_out and create index', function () {
|
||||
get.withArgs('elasticsearch.url').returns('http://localhost:9210');
|
||||
get.withArgs('elasticsearch.url').returns(esUrl);
|
||||
get.withArgs('elasticsearch.engineVersion').returns('^1.4.4');
|
||||
get.withArgs('kibana.index').returns('.my-kibana');
|
||||
client.ping.returns(Promise.resolve());
|
||||
|
|
|
@ -4,6 +4,9 @@ import Bluebird from 'bluebird';
|
|||
import 'elasticsearch-browser';
|
||||
import ngMock from 'ngMock';
|
||||
import sinon from 'sinon';
|
||||
import url from 'url';
|
||||
|
||||
import serverConfig from '../../../../../test/serverConfig';
|
||||
|
||||
describe('Scanner', function () {
|
||||
let es;
|
||||
|
@ -11,7 +14,7 @@ describe('Scanner', function () {
|
|||
beforeEach(ngMock.module('kibana'));
|
||||
beforeEach(ngMock.inject(function (esFactory) {
|
||||
es = esFactory({
|
||||
host: 'http://localhost:9210',
|
||||
host: url.format(serverConfig.servers.elasticsearch),
|
||||
defer: function () {
|
||||
return Bluebird.defer();
|
||||
}
|
||||
|
|
|
@ -2,7 +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('../../test/serverConfig');
|
||||
var serverConfig = require('../../test/serverConfig');
|
||||
|
||||
return {
|
||||
options: {
|
||||
|
@ -36,7 +36,7 @@ module.exports = function (grunt) {
|
|||
purge: true,
|
||||
config: {
|
||||
http: {
|
||||
port: 9210
|
||||
port: serverConfig.servers.elasticsearch.port
|
||||
},
|
||||
cluster: {
|
||||
name: 'esvm-test'
|
||||
|
@ -50,7 +50,7 @@ module.exports = function (grunt) {
|
|||
purge: true,
|
||||
config: {
|
||||
http: {
|
||||
port: uiConfig.servers.elasticsearch.port
|
||||
port: serverConfig.servers.elasticsearch.port
|
||||
},
|
||||
cluster: {
|
||||
name: 'esvm-ui'
|
||||
|
|
|
@ -13,7 +13,7 @@ describe('getUrl', function () {
|
|||
expect(url).to.be('http://localhost/foo');
|
||||
});
|
||||
|
||||
it('should convert to a secure url with port', function () {
|
||||
it('should convert to a url with port', function () {
|
||||
var url = getUrl({
|
||||
protocol: 'http',
|
||||
hostname: 'localhost',
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import url from 'url';
|
||||
import { defaultsDeep, set } from 'lodash';
|
||||
import { header as basicAuthHeader } from './base_auth';
|
||||
import { kibanaUser, kibanaServer } from '../shield';
|
||||
import KbnServer from '../../src/server/KbnServer';
|
||||
import fromRoot from '../../src/utils/fromRoot';
|
||||
import serverConfig from '../serverConfig';
|
||||
|
||||
const SERVER_DEFAULTS = {
|
||||
server: {
|
||||
|
@ -23,7 +25,7 @@ const SERVER_DEFAULTS = {
|
|||
enabled: false
|
||||
},
|
||||
elasticsearch: {
|
||||
url: 'http://localhost:9210',
|
||||
url: url.format(serverConfig.servers.elasticsearch),
|
||||
username: kibanaServer.username,
|
||||
password: kibanaServer.password
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue