fluent-plugin-elasticsearch 4.1.1 → 5.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/issue-auto-closer.yml +2 -2
- data/.github/workflows/linux.yml +5 -2
- data/.github/workflows/macos.yml +5 -2
- data/.github/workflows/windows.yml +5 -2
- data/Gemfile +1 -2
- data/History.md +146 -0
- data/README.ElasticsearchGenID.md +4 -4
- data/README.ElasticsearchInput.md +1 -1
- data/README.Troubleshooting.md +692 -0
- data/README.md +260 -550
- data/fluent-plugin-elasticsearch.gemspec +4 -1
- data/lib/fluent/plugin/elasticsearch_compat.rb +31 -0
- data/lib/fluent/plugin/elasticsearch_error_handler.rb +19 -4
- data/lib/fluent/plugin/elasticsearch_fallback_selector.rb +2 -2
- data/lib/fluent/plugin/elasticsearch_index_lifecycle_management.rb +18 -4
- data/lib/fluent/plugin/elasticsearch_index_template.rb +65 -21
- data/lib/fluent/plugin/elasticsearch_simple_sniffer.rb +2 -1
- data/lib/fluent/plugin/filter_elasticsearch_genid.rb +1 -1
- data/lib/fluent/plugin/in_elasticsearch.rb +8 -2
- data/lib/fluent/plugin/oj_serializer.rb +2 -1
- data/lib/fluent/plugin/out_elasticsearch.rb +192 -36
- data/lib/fluent/plugin/out_elasticsearch_data_stream.rb +298 -0
- data/lib/fluent/plugin/out_elasticsearch_dynamic.rb +3 -1
- data/test/helper.rb +0 -4
- data/test/plugin/mock_chunk.dat +0 -0
- data/test/plugin/test_elasticsearch_error_handler.rb +130 -23
- data/test/plugin/test_elasticsearch_fallback_selector.rb +17 -8
- data/test/plugin/test_elasticsearch_index_lifecycle_management.rb +57 -18
- data/test/plugin/test_elasticsearch_tls.rb +8 -2
- data/test/plugin/test_filter_elasticsearch_genid.rb +16 -16
- data/test/plugin/test_in_elasticsearch.rb +51 -21
- data/test/plugin/test_index_alias_template.json +11 -0
- data/test/plugin/test_index_template.json +25 -0
- data/test/plugin/test_out_elasticsearch.rb +2118 -704
- data/test/plugin/test_out_elasticsearch_data_stream.rb +1199 -0
- data/test/plugin/test_out_elasticsearch_dynamic.rb +170 -31
- metadata +62 -10
- data/.coveralls.yml +0 -2
- data/.travis.yml +0 -44
- data/appveyor.yml +0 -20
- data/gemfiles/Gemfile.without.ilm +0 -10
@@ -6,10 +6,15 @@ class TestElasticsearchIndexLifecycleManagement < Test::Unit::TestCase
|
|
6
6
|
include Fluent::Plugin::ElasticsearchIndexLifecycleManagement
|
7
7
|
|
8
8
|
def setup
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
if Gem::Version.new(Elasticsearch::VERSION) < Gem::Version.new("7.14.0")
|
10
|
+
begin
|
11
|
+
require "elasticsearch/xpack"
|
12
|
+
rescue LoadError
|
13
|
+
omit "ILM testcase needs elasticsearch-xpack gem."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
if Gem::Version.create(::TRANSPORT_CLASS::VERSION) < Gem::Version.create("7.4.0")
|
17
|
+
omit "elastisearch-ruby v7.4.0 or later is needed for ILM."
|
13
18
|
end
|
14
19
|
Fluent::Plugin::ElasticsearchIndexLifecycleManagement.module_eval(<<-CODE)
|
15
20
|
def client
|
@@ -24,40 +29,74 @@ class TestElasticsearchIndexLifecycleManagement < Test::Unit::TestCase
|
|
24
29
|
CODE
|
25
30
|
end
|
26
31
|
|
32
|
+
def elasticsearch_version
|
33
|
+
if Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("8.0.0")
|
34
|
+
TRANSPORT_CLASS::VERSION
|
35
|
+
else
|
36
|
+
'6.4.2'.freeze
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def ilm_existence_endpoint(policy_id)
|
41
|
+
if Gem::Version.new(Elasticsearch::VERSION) >= Gem::Version.new("8.0.0")
|
42
|
+
"_ilm/policy/#{policy_id}"
|
43
|
+
else
|
44
|
+
"_ilm/policy/%7B:policy_id=%3E%22#{policy_id}%22%7D"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def ilm_creation_endpoint(policy_id)
|
49
|
+
"_ilm/policy/#{policy_id}"
|
50
|
+
end
|
51
|
+
|
52
|
+
def stub_elastic_info(url="http://localhost:9200/", version=elasticsearch_version)
|
53
|
+
body ="{\"version\":{\"number\":\"#{version}\", \"build_flavor\":\"default\"},\"tagline\" : \"You Know, for Search\"}"
|
54
|
+
stub_request(:get, url).to_return({:status => 200, :body => body, :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
|
55
|
+
end
|
56
|
+
|
27
57
|
def test_xpack_info
|
28
58
|
stub_request(:get, "http://localhost:9200/_xpack").
|
29
|
-
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
59
|
+
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch' })
|
60
|
+
stub_elastic_info
|
30
61
|
expected = {"features"=>{"ilm"=>{"available"=>true, "enabled"=>true}}}
|
31
|
-
|
62
|
+
if xpack_info.is_a?(Elasticsearch::API::Response)
|
63
|
+
assert_equal(expected, xpack_info.body)
|
64
|
+
else
|
65
|
+
assert_equal(expected, xpack_info)
|
66
|
+
end
|
32
67
|
end
|
33
68
|
|
34
69
|
def test_verify_ilm_working
|
35
70
|
stub_request(:get, "http://localhost:9200/_xpack").
|
36
|
-
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
|
71
|
+
to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch' })
|
72
|
+
stub_elastic_info
|
37
73
|
assert_nothing_raised { verify_ilm_working }
|
38
74
|
end
|
39
75
|
|
40
76
|
def test_ilm_policy_doesnt_exists
|
41
|
-
stub_request(:get, "http://localhost:9200
|
42
|
-
to_return(:status => 404, :body => "", :headers => {})
|
43
|
-
|
77
|
+
stub_request(:get, "http://localhost:9200/#{ilm_existence_endpoint("fluentd-policy")}").
|
78
|
+
to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
|
79
|
+
stub_elastic_info
|
80
|
+
assert_false(ilm_policy_exists?("fluentd-policy"))
|
44
81
|
end
|
45
82
|
|
46
83
|
def test_ilm_policy_exists
|
47
|
-
stub_request(:get, "http://localhost:9200
|
48
|
-
to_return(:status => 200, :body => "", :headers => {})
|
49
|
-
|
84
|
+
stub_request(:get, "http://localhost:9200/#{ilm_existence_endpoint("fluent-policy")}").
|
85
|
+
to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
|
86
|
+
stub_elastic_info
|
87
|
+
assert_true(ilm_policy_exists?("fluent-policy"))
|
50
88
|
end
|
51
89
|
|
52
90
|
def test_create_ilm_policy
|
53
|
-
stub_request(:get, "http://localhost:9200
|
54
|
-
to_return(:status => 404, :body => "", :headers => {})
|
55
|
-
stub_request(:put, "http://localhost:9200
|
91
|
+
stub_request(:get, "http://localhost:9200/#{ilm_creation_endpoint("fluent-policy")}").
|
92
|
+
to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
|
93
|
+
stub_request(:put, "http://localhost:9200/#{ilm_creation_endpoint("fluent-policy")}").
|
56
94
|
with(:body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}",
|
57
95
|
:headers => {'Content-Type'=>'application/json'}).
|
58
|
-
to_return(:status => 200, :body => "", :headers => {})
|
96
|
+
to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
|
97
|
+
stub_elastic_info
|
59
98
|
create_ilm_policy("fluent-policy")
|
60
99
|
|
61
|
-
assert_requested(:put, "http://localhost:9200
|
100
|
+
assert_requested(:put, "http://localhost:9200/#{ilm_creation_endpoint("fluent-policy")}", times: 1)
|
62
101
|
end
|
63
102
|
end
|
@@ -62,8 +62,14 @@ class TestElasticsearchTLS < Test::Unit::TestCase
|
|
62
62
|
d = driver('')
|
63
63
|
ssl_version_options = d.instance.set_tls_minmax_version_config(d.instance.ssl_version, nil, nil)
|
64
64
|
if @use_tls_minmax_version
|
65
|
-
|
66
|
-
|
65
|
+
if @enabled_tlsv1_3
|
66
|
+
assert_equal({max_version: OpenSSL::SSL::TLS1_3_VERSION,
|
67
|
+
min_version: OpenSSL::SSL::TLS1_2_VERSION}, ssl_version_options)
|
68
|
+
else
|
69
|
+
assert_equal({max_version: nil,
|
70
|
+
min_version: OpenSSL::SSL::TLS1_2_VERSION}, ssl_version_options)
|
71
|
+
|
72
|
+
end
|
67
73
|
else
|
68
74
|
assert_equal({version: Fluent::Plugin::ElasticsearchTLS::DEFAULT_VERSION}, ssl_version_options)
|
69
75
|
end
|
@@ -132,10 +132,10 @@ class ElasticsearchGenidFilterTest < Test::Unit::TestCase
|
|
132
132
|
end
|
133
133
|
|
134
134
|
class UseEntireRecordAsSeedTest < self
|
135
|
-
data("md5" => ["md5", "
|
136
|
-
"sha1" => ["sha1", "
|
137
|
-
"sha256" => ["sha256", "
|
138
|
-
"sha512" => ["sha512", "
|
135
|
+
data("md5" => ["md5", "OAod7J0DR9s9/rOQnkeSFw=="],
|
136
|
+
"sha1" => ["sha1", "0CT4aMJ4gxMT3TKaYPCYApiVsq8="],
|
137
|
+
"sha256" => ["sha256", "mbAuKF5can0TTj/JBk71AXtOyoVqw5W5gMPUxx6pxLk="],
|
138
|
+
"sha512" => ["sha512", "f7kz5KVuDy+riENePDzqBjGQfbuRNpRBSQMzT2/6hrljXbYtBy3YFmxB86ofIf3zz4ZBao2QM2W7YvcwbRtK1w=="],)
|
139
139
|
def test_record
|
140
140
|
hash_type, expected = data
|
141
141
|
d = create_driver(%[
|
@@ -151,10 +151,10 @@ class ElasticsearchGenidFilterTest < Test::Unit::TestCase
|
|
151
151
|
d.filtered.map {|e| e.last}.first[d.instance.hash_id_key])
|
152
152
|
end
|
153
153
|
|
154
|
-
data("md5" => ["md5", "
|
155
|
-
"sha1" => ["sha1", "
|
156
|
-
"sha256" => ["sha256", "
|
157
|
-
"sha512" => ["sha512", "
|
154
|
+
data("md5" => ["md5", "Hb0jwxofNQP+ufQTKK1U4g=="],
|
155
|
+
"sha1" => ["sha1", "BakTtlotl/u+yOON6YcViTz6nms="],
|
156
|
+
"sha256" => ["sha256", "eLuTCsFqDlk6PfABNyD39r36+yNIBeDTHyNKfJ8fZQw="],
|
157
|
+
"sha512" => ["sha512", "PhPCNGalM4H4xT19DnCBnpwr56lbvCo8wJGyCiH9dWcyhn1nA5l1diYSZlF2fNiq1+wzMqfGvJILIjgQrlAPcg=="],)
|
158
158
|
def test_record_with_tag
|
159
159
|
hash_type, expected = data
|
160
160
|
d = create_driver(%[
|
@@ -171,10 +171,10 @@ class ElasticsearchGenidFilterTest < Test::Unit::TestCase
|
|
171
171
|
d.filtered.map {|e| e.last}.first[d.instance.hash_id_key])
|
172
172
|
end
|
173
173
|
|
174
|
-
data("md5" => ["md5", "
|
175
|
-
"sha1" => ["sha1", "
|
176
|
-
"sha256" => ["sha256", "
|
177
|
-
"sha512" => ["sha512", "
|
174
|
+
data("md5" => ["md5", "C8vfhC4kecNCNutFCuC6MA=="],
|
175
|
+
"sha1" => ["sha1", "+YWVqUEL90wpKJRrionUJwNgXHg="],
|
176
|
+
"sha256" => ["sha256", "eSqGZqjnO6Uum/4CNfJaolX49+2XKogiGMHGNHiO91Q="],
|
177
|
+
"sha512" => ["sha512", "iVmuD0D+i/WtBwNza09ZXSIW8Xg8/yrUwK/M/EZaCMjz/x5FyyCiVkb1VVKsgNnJy0SYt4w21dhHewu1aXM6HA=="],)
|
178
178
|
def test_record_with_time
|
179
179
|
hash_type, expected = data
|
180
180
|
d = create_driver(%[
|
@@ -191,10 +191,10 @@ class ElasticsearchGenidFilterTest < Test::Unit::TestCase
|
|
191
191
|
d.filtered.map {|e| e.last}.first[d.instance.hash_id_key])
|
192
192
|
end
|
193
193
|
|
194
|
-
data("md5" => ["md5", "
|
195
|
-
"sha1" => ["sha1", "
|
196
|
-
"sha256" => ["sha256", "
|
197
|
-
"sha512" => ["sha512", "
|
194
|
+
data("md5" => ["md5", "lU7d4EiF+2M1zxWcsmBbjg=="],
|
195
|
+
"sha1" => ["sha1", "nghmz1y3KTEFxalfS2/Oe4n4yfQ="],
|
196
|
+
"sha256" => ["sha256", "d0le9UOnUeuGPF/2yEBRM1YzOYeHtxYOE1UU6JgJrvU="],
|
197
|
+
"sha512" => ["sha512", "n7rhisGHUBne6c4Cs9DRMbPror8O5Y/vYajDqAtOaiUTys/Z1EKBMnZQA0iVNFw7joX33cenBW3Yyccct3xSew=="],)
|
198
198
|
def test_record_with_tag_and_time
|
199
199
|
hash_type, expected = data
|
200
200
|
d = create_driver(%[
|
@@ -20,12 +20,30 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
20
20
|
@driver = nil
|
21
21
|
log = Fluent::Engine.log
|
22
22
|
log.out.logs.slice!(0, log.out.logs.length)
|
23
|
+
@http_method = if Gem::Version.new(Elasticsearch::VERSION) >= Gem::Version.new("7.9.0")
|
24
|
+
:post
|
25
|
+
else
|
26
|
+
:get
|
27
|
+
end
|
23
28
|
end
|
24
29
|
|
25
30
|
def driver(conf='')
|
26
31
|
@driver ||= Fluent::Test::Driver::Input.new(Fluent::Plugin::ElasticsearchInput).configure(conf)
|
27
32
|
end
|
28
33
|
|
34
|
+
def elasticsearch_version
|
35
|
+
if Gem::Version.new(TRANSPORT_CLASS::VERSION) >= Gem::Version.new("7.14.0")
|
36
|
+
TRANSPORT_CLASS::VERSION
|
37
|
+
else
|
38
|
+
'7.9.0'.freeze
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def stub_elastic_info(url="http://localhost:9200/", version=elasticsearch_version)
|
43
|
+
body ="{\"version\":{\"number\":\"#{version}\", \"build_flavor\":\"default\"},\"tagline\" : \"You Know, for Search\"}"
|
44
|
+
stub_request(:get, url).to_return({:status => 200, :body => body, :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
|
45
|
+
end
|
46
|
+
|
29
47
|
def sample_response(index_name="fluentd")
|
30
48
|
{
|
31
49
|
"took"=>4,
|
@@ -313,10 +331,11 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
313
331
|
end
|
314
332
|
|
315
333
|
def test_emit
|
316
|
-
stub_request(
|
334
|
+
stub_request(@http_method, "http://localhost:9200/fluentd/_search?scroll=1m&size=1000").
|
317
335
|
with(body: "{\"sort\":[\"_doc\"]}").
|
318
336
|
to_return(status: 200, body: sample_response.to_s,
|
319
|
-
headers: {'Content-Type' => 'application/json'})
|
337
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
338
|
+
stub_elastic_info
|
320
339
|
|
321
340
|
driver(CONFIG)
|
322
341
|
driver.run(expect_emits: 1, timeout: 10)
|
@@ -328,10 +347,11 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
328
347
|
|
329
348
|
def test_emit_with_custom_index_name
|
330
349
|
index_name = "logstash"
|
331
|
-
stub_request(
|
350
|
+
stub_request(@http_method, "http://localhost:9200/#{index_name}/_search?scroll=1m&size=1000").
|
332
351
|
with(body: "{\"sort\":[\"_doc\"]}").
|
333
352
|
to_return(status: 200, body: sample_response(index_name).to_s,
|
334
|
-
headers: {'Content-Type' => 'application/json'})
|
353
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
354
|
+
stub_elastic_info
|
335
355
|
|
336
356
|
driver(CONFIG + %[index_name #{index_name}])
|
337
357
|
driver.run(expect_emits: 1, timeout: 10)
|
@@ -343,10 +363,11 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
343
363
|
|
344
364
|
def test_emit_with_parse_timestamp
|
345
365
|
index_name = "fluentd"
|
346
|
-
stub_request(
|
366
|
+
stub_request(@http_method, "http://localhost:9200/#{index_name}/_search?scroll=1m&size=1000").
|
347
367
|
with(body: "{\"sort\":[\"_doc\"]}").
|
348
368
|
to_return(status: 200, body: sample_response(index_name).to_s,
|
349
|
-
headers: {'Content-Type' => 'application/json'})
|
369
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
370
|
+
stub_elastic_info
|
350
371
|
|
351
372
|
driver(CONFIG + %[parse_timestamp])
|
352
373
|
driver.run(expect_emits: 1, timeout: 10)
|
@@ -361,10 +382,11 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
361
382
|
|
362
383
|
def test_emit_with_parse_timestamp_and_timstamp_format
|
363
384
|
index_name = "fluentd"
|
364
|
-
stub_request(
|
385
|
+
stub_request(@http_method, "http://localhost:9200/#{index_name}/_search?scroll=1m&size=1000").
|
365
386
|
with(body: "{\"sort\":[\"_doc\"]}").
|
366
387
|
to_return(status: 200, body: sample_response(index_name).to_s,
|
367
|
-
headers: {'Content-Type' => 'application/json'})
|
388
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
389
|
+
stub_elastic_info
|
368
390
|
|
369
391
|
driver(CONFIG + %[parse_timestamp true
|
370
392
|
timestamp_key_format %Y-%m-%dT%H:%M:%S.%N%z
|
@@ -380,10 +402,11 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
380
402
|
end
|
381
403
|
|
382
404
|
def test_emit_with_docinfo
|
383
|
-
stub_request(
|
405
|
+
stub_request(@http_method, "http://localhost:9200/fluentd/_search?scroll=1m&size=1000").
|
384
406
|
with(body: "{\"sort\":[\"_doc\"]}").
|
385
407
|
to_return(status: 200, body: sample_response.to_s,
|
386
|
-
headers: {'Content-Type' => 'application/json'})
|
408
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
409
|
+
stub_elastic_info
|
387
410
|
|
388
411
|
driver(CONFIG + %[docinfo true])
|
389
412
|
driver.run(expect_emits: 1, timeout: 10)
|
@@ -399,14 +422,15 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
399
422
|
end
|
400
423
|
|
401
424
|
def test_emit_with_slices
|
402
|
-
stub_request(
|
425
|
+
stub_request(@http_method, "http://localhost:9200/fluentd/_search?scroll=1m&size=1000").
|
403
426
|
with(body: "{\"sort\":[\"_doc\"],\"slice\":{\"id\":0,\"max\":2}}").
|
404
427
|
to_return(status: 200, body: sample_response.to_s,
|
405
|
-
headers: {'Content-Type' => 'application/json'})
|
406
|
-
stub_request(
|
428
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
429
|
+
stub_request(@http_method, "http://localhost:9200/fluentd/_search?scroll=1m&size=1000").
|
407
430
|
with(body: "{\"sort\":[\"_doc\"],\"slice\":{\"id\":1,\"max\":2}}").
|
408
431
|
to_return(status: 200, body: sample_response.to_s,
|
409
|
-
headers: {'Content-Type' => 'application/json'})
|
432
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
433
|
+
stub_elastic_info
|
410
434
|
|
411
435
|
driver(CONFIG + %[num_slices 2])
|
412
436
|
driver.run(expect_emits: 1, timeout: 10)
|
@@ -419,28 +443,34 @@ class ElasticsearchInputTest < Test::Unit::TestCase
|
|
419
443
|
end
|
420
444
|
|
421
445
|
def test_emit_with_size
|
422
|
-
stub_request(
|
446
|
+
stub_request(@http_method, "http://localhost:9200/fluentd/_search?scroll=1m&size=1").
|
423
447
|
with(body: "{\"sort\":[\"_doc\"]}").
|
424
448
|
to_return(status: 200, body: sample_scroll_response.to_s,
|
425
|
-
headers: {'Content-Type' => 'application/json'})
|
449
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'})
|
426
450
|
connection = 0
|
427
|
-
scroll_request = stub_request(
|
451
|
+
scroll_request = stub_request(@http_method, "http://localhost:9200/_search/scroll?scroll=1m").
|
428
452
|
with(
|
429
453
|
body: "{\"scroll_id\":\"WomkoUKG0QPB679Ulo6TqQgh3pIGRUmrl9qXXGK3EeiQh9rbYNasTkspZQcJ01uz\"}") do
|
430
454
|
connection += 1
|
431
455
|
end
|
456
|
+
stub_elastic_info
|
432
457
|
scroll_request.to_return(lambda do |req|
|
433
458
|
if connection <= 1
|
434
459
|
{status: 200, body: sample_scroll_response_2.to_s,
|
435
|
-
headers: {'Content-Type' => 'application/json'}}
|
460
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'}}
|
436
461
|
else
|
437
462
|
{status: 200, body: sample_scroll_response_terminate.to_s,
|
438
|
-
headers: {'Content-Type' => 'application/json'}}
|
463
|
+
headers: {'Content-Type' => 'application/json', 'X-elastic-product' => 'Elasticsearch'}}
|
439
464
|
end
|
440
465
|
end)
|
441
|
-
|
466
|
+
if Gem::Version.new(Elasticsearch::VERSION) >= Gem::Version.new("7.0.0")
|
467
|
+
stub_request(:delete, "http://localhost:9200/_search/scroll").
|
468
|
+
with(body: "{\"scroll_id\":\"WomkoUKG0QPB679Ulo6TqQgh3pIGRUmrl9qXXGK3EeiQh9rbYNasTkspZQcJ01uz\"}").
|
442
469
|
to_return(status: 200, body: "", headers: {})
|
443
|
-
|
470
|
+
else
|
471
|
+
stub_request(:delete, "http://localhost:9200/_search/scroll/WomkoUKG0QPB679Ulo6TqQgh3pIGRUmrl9qXXGK3EeiQh9rbYNasTkspZQcJ01uz").
|
472
|
+
to_return(status: 200, body: "", headers: {})
|
473
|
+
end
|
444
474
|
driver(CONFIG + %[size 1])
|
445
475
|
driver.run(expect_emits: 1, timeout: 10)
|
446
476
|
expected = [
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"index_patterns": "te*",
|
3
|
+
"template": {
|
4
|
+
"settings": {
|
5
|
+
"number_of_shards": 1
|
6
|
+
},
|
7
|
+
"mappings": {
|
8
|
+
"type1": {
|
9
|
+
"_source": {
|
10
|
+
"enabled": false
|
11
|
+
},
|
12
|
+
"properties": {
|
13
|
+
"host_name": {
|
14
|
+
"type": "string",
|
15
|
+
"index": "not_analyzed"
|
16
|
+
},
|
17
|
+
"created_at": {
|
18
|
+
"type": "date",
|
19
|
+
"format": "EEE MMM dd HH:mm:ss Z YYYY"
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|