lib/elasticsearch/extensions/test/cluster.rb in elasticsearch-extensions-0.0.26 vs lib/elasticsearch/extensions/test/cluster.rb in elasticsearch-extensions-0.0.27
- old
+ new
@@ -172,13 +172,32 @@
-E discovery.zen.minimum_master_nodes=#{arguments[:number_of_nodes]-1} \
-E node.max_local_storage_nodes=#{arguments[:number_of_nodes]} \
-E logger.level=#{ENV['DEBUG'] ? 'DEBUG' : 'INFO'} \
#{arguments[:es_params]}
COMMAND
+ },
+
+ '6.0' => lambda { |arguments, node_number|
+ <<-COMMAND.gsub(/ /, '').gsub(/\n$/, '')
+ #{arguments[:command]} \
+ -E cluster.name=#{arguments[:cluster_name]} \
+ -E node.name=#{arguments[:node_name]}-#{node_number} \
+ -E http.port=#{arguments[:port].to_i + (node_number-1)} \
+ -E path.data=#{arguments[:path_data]} \
+ -E path.logs=#{arguments[:path_logs]} \
+ -E cluster.routing.allocation.disk.threshold_enabled=false \
+ -E network.host=#{arguments[:network_host]} \
+ -E node.attr.testattr=test \
+ -E path.repo=/tmp \
+ -E repositories.url.allowed_urls=http://snapshot.test* \
+ -E discovery.zen.minimum_master_nodes=#{arguments[:number_of_nodes]-1} \
+ -E node.max_local_storage_nodes=#{arguments[:number_of_nodes]} \
+ -E logger.level=#{ENV['DEBUG'] ? 'DEBUG' : 'INFO'} \
+ #{arguments[:es_params]}
+ COMMAND
}
}
- COMMANDS['6.0'] = COMMANDS['5.0']
COMMANDS.freeze
# Create a new instance of the Cluster class
#
# @option arguments [String] :cluster_name Cluster name (default: `elasticsearch_test`)
@@ -189,10 +208,11 @@
# @option arguments [String] :path_data Path to the directory to store data in
# @option arguments [String] :path_work Path to the directory with auxiliary files
# @option arguments [String] :path_logs Path to the directory with log files
# @option arguments [Boolean] :multicast_enabled Whether multicast is enabled (default: true)
# @option arguments [Integer] :timeout Timeout when starting the cluster (default: 60)
+ # @option arguments [Integer] :timeout_version Timeout when waiting for `elasticsearch --version` (default: 15)
# @option arguments [String] :network_host The host that nodes will bind on and publish to
# @option arguments [Boolean] :clear_cluster Wipe out cluster content on startup (default: true)
# @option arguments [Boolean] :quiet Disable printing to STDERR (default: false)
#
# You can also use environment variables to set the constructor options (see source).
@@ -210,10 +230,11 @@
@arguments[:path_work] ||= ENV.fetch('TEST_CLUSTER_TMP', '/tmp')
@arguments[:path_logs] ||= ENV.fetch('TEST_CLUSTER_LOGS', '/tmp/log/elasticsearch')
@arguments[:es_params] ||= ENV.fetch('TEST_CLUSTER_PARAMS', '')
@arguments[:multicast_enabled] ||= ENV.fetch('TEST_CLUSTER_MULTICAST', 'true')
@arguments[:timeout] ||= ENV.fetch('TEST_CLUSTER_TIMEOUT', 60).to_i
+ @arguments[:timeout_version] ||= ENV.fetch('TEST_CLUSTER_TIMEOUT_VERSION', 15).to_i
@arguments[:number_of_nodes] ||= ENV.fetch('TEST_CLUSTER_NODES', 2).to_i
@arguments[:network_host] ||= ENV.fetch('TEST_CLUSTER_NETWORK_HOST', __default_network_host)
@arguments[:quiet] ||= ! ENV.fetch('QUIET', '').empty?
@clear_cluster = !!@arguments[:clear_cluster] || (ENV.fetch('TEST_CLUSTER_CLEAR', 'true') != 'false')
@@ -417,23 +438,23 @@
end
end
# Determine Elasticsearch version to be launched
#
- # Tries to parse the version number from the `lib/elasticsearch-X.Y.Z.jar` file,
- # it not available, uses `elasticsearch --version` or `elasticsearch -v`
+ # Tries to get the version from the arguments passed,
+ # if not available, it parses the version number from the `lib/elasticsearch-X.Y.Z.jar` file,
+ # if that is not available, uses `elasticsearch --version` or `elasticsearch -v`
#
# @api private
#
# @return String
#
def __determine_version
path_to_lib = File.dirname(arguments[:command]) + '/../lib/'
-
- jar = Dir.entries(path_to_lib).select { |f| f.start_with? 'elasticsearch' }.first if File.exist? path_to_lib
-
- version = if jar
+ version = if arguments[:version]
+ arguments[:version]
+ elsif File.exist?(path_to_lib) && !(jar = Dir.entries(path_to_lib).select { |f| f.start_with? 'elasticsearch' }.first).nil?
__log "Determining version from [#{jar}]" if ENV['DEBUG']
if m = jar.match(/elasticsearch\-(\d+\.\d+\.\d+).*/)
m[1]
else
raise RuntimeError, "Cannot determine Elasticsearch version from jar [#{jar}]"
@@ -462,10 +483,10 @@
# First, try the new `--version` syntax...
__log "Running [#{arguments[:command]} --version] to determine version" if ENV['DEBUG']
rout, wout = IO.pipe
pid = Process.spawn("#{arguments[:command]} --version", out: wout)
- Timeout::timeout(10) do
+ Timeout::timeout(arguments[:timeout_version]) do
Process.wait(pid)
wout.close unless wout.closed?
output = rout.read unless rout.closed?
rout.close unless rout.closed?
end