From 6368d12a2f24af21d2f369b826f02fc9af610357 Mon Sep 17 00:00:00 2001 From: spalger Date: Tue, 25 Aug 2015 11:31:39 -0700 Subject: [PATCH] Support setting elasticsearch bind host for tests --- .travis.yml | 4 ++-- grunt/config/esvm.js | 3 ++- grunt/tasks.js | 1 + scripts/ci.js | 2 ++ test/integration/yaml_suite/client_manager.js | 6 +++--- test/integration/yaml_suite/run.js | 3 ++- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index ecef4aa87..246bc2e1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ before_cache: sudo: false secure: "UFAGQ6m/VnEahbj9vttY9YoA5h5rEBE6K7AvEEbWnt+VKppV+w3hu3HZxgKr8C9PWhCzqlGvsLh+kCqykZhISU1fBCK/Ttp3nSpMvvF5tI2u51Rj1qZ/7NUGRU0qVI9KFt0rJeXMJwq3fivb1H6aojfPD1gsIte7NHNjUfd0iUg=" env: - - ES_REF=2.0 RUN=NODE_INTEGRATION - - ES_REF=2.0 RUN=NODE_UNIT,CHECK_COVERAGE,SAUCE_LABS + - ES_HOST=0.0.0.0 ES_RELEASE=1.7.1 RUN=NODE_INTEGRATION + - ES_HOST=0.0.0.0 ES_RELEASE=1.7.1 RUN=NODE_UNIT,CHECK_COVERAGE,SAUCE_LABS script: node ./scripts/ci.js email: recipients: diff --git a/grunt/config/esvm.js b/grunt/config/esvm.js index a2cc64424..4feba0a3b 100644 --- a/grunt/config/esvm.js +++ b/grunt/config/esvm.js @@ -5,6 +5,7 @@ var fromRoot = require('path').join.bind(null, __dirname, '..', '..'); var release = process.env.ES_RELEASE; var ref = process.env.ES_REF; var port = parseFloat(_.get(process.env, 'ES_PORT', 9400)); +var host = _.get(process.env, 'ES_HOST', 'localhost'); var Version = require('../../scripts/Version'); var versionedOpts = [ @@ -18,7 +19,7 @@ var versionedOpts = [ 'node.name': 'elasticsearch_js_test_runner', 'cluster.name': 'elasticsearch_js_test_runners', 'http.port': port, - 'network.host': 'localhost', + 'network.host': host, 'discovery.zen.ping.multicast.enabled': false } }, diff --git a/grunt/tasks.js b/grunt/tasks.js index 5886fdd45..3370b9a5a 100644 --- a/grunt/tasks.js +++ b/grunt/tasks.js @@ -20,6 +20,7 @@ module.exports = function (grunt) { var branches = branch ? [branch] : utils.branches; process.env.ES_PORT = process.env.ES_PORT || 9400; + process.env.ES_HOST = process.env.ES_HOST || 'localhost'; branches.forEach(function (branch) { tasks.push( 'esvm:' + branch, diff --git a/scripts/ci.js b/scripts/ci.js index 0fd2e926d..054b8dcf2 100644 --- a/scripts/ci.js +++ b/scripts/ci.js @@ -6,6 +6,7 @@ * ES_REF - the ES branch/tag we should use to generate the tests and download es * ES_RELEASE - a specific ES release to download in use for testing * ES_PORT - the port number we should run elasticsearch on + * ES_HOST - the hostname elasticsearch should bind to * ES_V - a version identifier used by jenkins. don't use this * * Tasks: @@ -152,6 +153,7 @@ execTask('SETUP', function () { throw new Error('Unable to run the ci script without at least an ES_REF or ES_RELEASE environment var.'); log('ES_PORT:', ENV.ES_PORT = parseInt(ENV.ES_PORT || 9400, 10)); + log('ES_HOST:', ENV.ES_HOST = ENV.ES_HOST || 'localhost'); if (ver[0]) log('ES_REF:', ENV.ES_REF = ver[0]); else delete ENV.ES_REF; diff --git a/test/integration/yaml_suite/client_manager.js b/test/integration/yaml_suite/client_manager.js index f86840112..7959ea1c4 100644 --- a/test/integration/yaml_suite/client_manager.js +++ b/test/integration/yaml_suite/client_manager.js @@ -23,7 +23,7 @@ var client = null; var externalExists; module.exports = { - create: function create(apiVersion, port, cb) { + create: function create(apiVersion, port, host, cb) { // create a client and ping the server for up to 15 seconds doCreateClient({ logConfig: null @@ -40,7 +40,7 @@ module.exports = { setTimeout(ping, timeout); } else if (err) { cb(new Error('unable to establish contact with ES at ' + JSON.stringify({ - host: 'localhost', + host: host, port: port, err: err }))); @@ -92,7 +92,7 @@ module.exports = { apiVersion: apiVersion, hosts: [ { - host: 'localhost', + host: host, port: port } ], diff --git a/test/integration/yaml_suite/run.js b/test/integration/yaml_suite/run.js index be64b769e..1ee63484c 100644 --- a/test/integration/yaml_suite/run.js +++ b/test/integration/yaml_suite/run.js @@ -10,6 +10,7 @@ module.exports = function (branch) { var clientManager = require('./client_manager'); var port = parseInt(process.env.ES_PORT || 9200, 10); + var host = process.env.ES_HOST || 'localhost'; var _release = branch.match(/^v(\d+\.\d+)\.\d+$/); var apiVersion = _release ? _release[1] : branch; @@ -23,7 +24,7 @@ module.exports = function (branch) { // before running any tests... before(function (done) { this.timeout(5 * 60 * 1000); - clientManager.create(apiVersion, port, done); + clientManager.create(apiVersion, port, host, done); }); before(function () {