elasticsearch-extensions 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e107c0460b65ea557da0d707c1d04876e5c09148
|
4
|
+
data.tar.gz: 24c97d1fb54ceddc82bfb832ba8e4e7b4f53107f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 111ae93ac52d93ad54240d735a0d8373d075d25fb3769c830be10024f422a5b9fb803f033e1f9bb03e58cd660678f9fda44f7c6d97b404a493a44216871dd3bc
|
7
|
+
data.tar.gz: 6912205e7419ed78da8520fe15138cea7c4b759209bdc047fcde678b724e78e0d61c4d3de910a5d093f440f04c68dc17b7beae44a7b3e4d349a32e08bc2b262a
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ Display a table with the output of the `_analyze` API:
|
|
25
25
|
|
26
26
|
Allows to programatically start and stop an Elasticsearch cluster suitable for isolating tests.
|
27
27
|
|
28
|
-
HTTP service is running on ports `9250-*` by default
|
28
|
+
The HTTP service is running on ports `9250-*` by default.
|
29
29
|
|
30
30
|
Start and stop the default cluster:
|
31
31
|
|
@@ -51,6 +51,10 @@ Gem::Specification.new do |s|
|
|
51
51
|
s.add_development_dependency "cane"
|
52
52
|
end
|
53
53
|
|
54
|
+
if defined?(RUBY_VERSION) && RUBY_VERSION > '2.2'
|
55
|
+
s.add_development_dependency "test-unit", '~> 2'
|
56
|
+
end
|
57
|
+
|
54
58
|
# Gems for testing integrations
|
55
59
|
s.add_development_dependency "patron"
|
56
60
|
s.add_development_dependency "oj"
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'timeout'
|
2
2
|
require 'net/http'
|
3
|
+
require 'fileutils'
|
3
4
|
require 'uri'
|
4
5
|
require 'json'
|
5
6
|
require 'ansi'
|
@@ -69,21 +70,27 @@ module Elasticsearch
|
|
69
70
|
|
70
71
|
arguments[:command] ||= ENV['TEST_CLUSTER_COMMAND'] || 'elasticsearch'
|
71
72
|
arguments[:port] ||= (ENV['TEST_CLUSTER_PORT'] || 9250).to_i
|
72
|
-
arguments[:cluster_name] ||= ENV['TEST_CLUSTER_NAME'] || 'elasticsearch_test'
|
73
|
-
arguments[:gateway_type] ||= 'none'
|
74
|
-
arguments[:index_store] ||= 'memory'
|
73
|
+
arguments[:cluster_name] ||= (ENV['TEST_CLUSTER_NAME'] || 'elasticsearch_test').chomp
|
75
74
|
arguments[:path_data] ||= ENV['TEST_CLUSTER_DATA'] || '/tmp'
|
76
75
|
arguments[:es_params] ||= ENV['TEST_CLUSTER_PARAMS'] || ''
|
77
76
|
arguments[:path_work] ||= '/tmp'
|
78
77
|
arguments[:node_name] ||= 'node'
|
79
78
|
arguments[:timeout] ||= (ENV['TEST_CLUSTER_TIMEOUT'] || 30).to_i
|
80
79
|
|
80
|
+
# Make sure `cluster_name` is not dangerous
|
81
|
+
if arguments[:cluster_name] =~ /^[\/\\]?$/
|
82
|
+
raise ArgumentError, "The `cluster_name` parameter cannot be empty string or a slash"
|
83
|
+
end
|
84
|
+
|
81
85
|
if running? :on => arguments[:port], :as => arguments[:cluster_name]
|
82
86
|
print "[!] Elasticsearch cluster already running".ansi(:red)
|
83
87
|
wait_for_green(arguments[:port], arguments[:timeout])
|
84
88
|
return false
|
85
89
|
end
|
86
90
|
|
91
|
+
# Wipe out data for this cluster name
|
92
|
+
FileUtils.rm_rf "#{arguments[:path_data]}/#{arguments[:cluster_name]}"
|
93
|
+
|
87
94
|
print "Starting ".ansi(:faint) +
|
88
95
|
@@number_of_nodes.to_s.ansi(:bold, :faint) +
|
89
96
|
" Elasticsearch nodes..".ansi(:faint)
|
@@ -98,8 +105,6 @@ module Elasticsearch
|
|
98
105
|
-D es.cluster.name=#{arguments[:cluster_name]} \
|
99
106
|
-D es.node.name=#{arguments[:node_name]}-#{n} \
|
100
107
|
-D es.http.port=#{arguments[:port].to_i + (n-1)} \
|
101
|
-
-D es.gateway.type=#{arguments[:gateway_type]} \
|
102
|
-
-D es.index.store.type=#{arguments[:index_store]} \
|
103
108
|
-D es.path.data=#{arguments[:path_data]} \
|
104
109
|
-D es.path.work=#{arguments[:path_work]} \
|
105
110
|
-D es.cluster.routing.allocation.disk.threshold_enabled=false \
|
@@ -154,10 +159,10 @@ module Elasticsearch
|
|
154
159
|
pids = nodes['nodes'].map { |id, info| info['process']['id'] }
|
155
160
|
|
156
161
|
unless pids.empty?
|
157
|
-
print "
|
162
|
+
print "\nStopping Elasticsearch nodes... ".ansi(:faint)
|
158
163
|
pids.each_with_index do |pid, i|
|
159
164
|
begin
|
160
|
-
print "stopped PID #{pid}. ".ansi(:green) if Process.kill '
|
165
|
+
print "stopped PID #{pid}. ".ansi(:green) if Process.kill 'INT', pid
|
161
166
|
rescue Exception => e
|
162
167
|
print "[#{e.class}] PID #{pid} not found. ".ansi(:red)
|
163
168
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karel Minarik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ansi
|