logstash-output-elasticsearch 7.4.0-java → 7.4.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +3 -0
- data/lib/logstash/outputs/elasticsearch/common.rb +6 -3
- data/lib/logstash/outputs/elasticsearch/http_client.rb +7 -9
- data/lib/logstash/outputs/elasticsearch/http_client/pool.rb +31 -12
- data/lib/logstash/outputs/elasticsearch/template_manager.rb +4 -6
- data/logstash-output-elasticsearch.gemspec +1 -1
- data/spec/es_spec_helper.rb +6 -0
- data/spec/integration/outputs/compressed_indexing_spec.rb +46 -44
- data/spec/integration/outputs/delete_spec.rb +51 -49
- data/spec/integration/outputs/groovy_update_spec.rb +131 -129
- data/spec/integration/outputs/index_version_spec.rb +82 -81
- data/spec/integration/outputs/ingest_pipeline_spec.rb +51 -49
- data/spec/integration/outputs/painless_update_spec.rb +132 -130
- data/spec/integration/outputs/parent_spec.rb +56 -54
- data/spec/integration/outputs/sniffer_spec.rb +5 -2
- data/spec/integration/outputs/templates_5x_spec.rb +81 -82
- data/spec/integration/outputs/templates_spec.rb +81 -81
- data/spec/integration/outputs/update_spec.rb +101 -99
- data/spec/unit/outputs/elasticsearch/http_client/pool_spec.rb +3 -0
- data/spec/unit/outputs/elasticsearch/http_client_spec.rb +1 -1
- data/spec/unit/outputs/elasticsearch/template_manager_spec.rb +13 -25
- metadata +4 -6
@@ -38,7 +38,10 @@ describe "pool sniffer", :integration => true do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
# We do a more thorough check on these versions because we can more reliably guess the ip
|
41
|
-
|
42
|
-
|
41
|
+
|
42
|
+
if ESHelper.es_version_satisfies?(">= 2")
|
43
|
+
describe("Complex sniff parsing ES 6x/5x/2x") do
|
44
|
+
include_examples("sniff parsing", true)
|
45
|
+
end
|
43
46
|
end
|
44
47
|
end
|
@@ -1,99 +1,98 @@
|
|
1
1
|
require_relative "../../../spec/es_spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
describe "index template expected behavior for 5.x", :integration => true
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
before :each do
|
16
|
-
# Delete all templates first.
|
17
|
-
require "elasticsearch"
|
18
|
-
|
19
|
-
# Clean ES of data before we start.
|
20
|
-
@es = get_client
|
21
|
-
@es.indices.delete_template(:name => "*")
|
22
|
-
|
23
|
-
# This can fail if there are no indexes, ignore failure.
|
24
|
-
@es.indices.delete(:index => "*") rescue nil
|
25
|
-
|
26
|
-
subject.register
|
27
|
-
|
28
|
-
subject.multi_receive([
|
29
|
-
LogStash::Event.new("message" => "sample message here"),
|
30
|
-
LogStash::Event.new("somemessage" => { "message" => "sample nested message here" }),
|
31
|
-
LogStash::Event.new("somevalue" => 100),
|
32
|
-
LogStash::Event.new("somevalue" => 10),
|
33
|
-
LogStash::Event.new("somevalue" => 1),
|
34
|
-
LogStash::Event.new("country" => "us"),
|
35
|
-
LogStash::Event.new("country" => "at"),
|
36
|
-
LogStash::Event.new("geoip" => { "location" => [ 0.0, 0.0 ] })
|
37
|
-
])
|
38
|
-
|
39
|
-
@es.indices.refresh
|
3
|
+
if ESHelper.es_version_satisfies?(">= 5")
|
4
|
+
describe "index template expected behavior for 5.x", :integration => true do
|
5
|
+
subject! do
|
6
|
+
require "logstash/outputs/elasticsearch"
|
7
|
+
settings = {
|
8
|
+
"manage_template" => true,
|
9
|
+
"template_overwrite" => true,
|
10
|
+
"hosts" => "#{get_host_port()}"
|
11
|
+
}
|
12
|
+
next LogStash::Outputs::ElasticSearch.new(settings)
|
13
|
+
end
|
40
14
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
15
|
+
before :each do
|
16
|
+
# Delete all templates first.
|
17
|
+
require "elasticsearch"
|
18
|
+
|
19
|
+
# Clean ES of data before we start.
|
20
|
+
@es = get_client
|
21
|
+
@es.indices.delete_template(:name => "*")
|
22
|
+
|
23
|
+
# This can fail if there are no indexes, ignore failure.
|
24
|
+
@es.indices.delete(:index => "*") rescue nil
|
25
|
+
|
26
|
+
subject.register
|
27
|
+
|
28
|
+
subject.multi_receive([
|
29
|
+
LogStash::Event.new("message" => "sample message here"),
|
30
|
+
LogStash::Event.new("somemessage" => { "message" => "sample nested message here" }),
|
31
|
+
LogStash::Event.new("somevalue" => 100),
|
32
|
+
LogStash::Event.new("somevalue" => 10),
|
33
|
+
LogStash::Event.new("somevalue" => 1),
|
34
|
+
LogStash::Event.new("country" => "us"),
|
35
|
+
LogStash::Event.new("country" => "at"),
|
36
|
+
LogStash::Event.new("geoip" => { "location" => [ 0.0, 0.0 ] })
|
37
|
+
])
|
38
|
+
|
39
|
+
@es.indices.refresh
|
40
|
+
|
41
|
+
# Wait or fail until everything's indexed.
|
42
|
+
Stud::try(20.times) do
|
43
|
+
r = @es.search
|
44
|
+
insist { r["hits"]["total"] } == 8
|
45
|
+
end
|
45
46
|
end
|
46
|
-
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
it "permits phrase searching on string fields" do
|
49
|
+
results = @es.search(:q => "message:\"sample message\"")
|
50
|
+
insist { results["hits"]["total"] } == 1
|
51
|
+
insist { results["hits"]["hits"][0]["_source"]["message"] } == "sample message here"
|
52
|
+
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
it "numbers dynamically map to a numeric type and permit range queries" do
|
55
|
+
results = @es.search(:q => "somevalue:[5 TO 105]")
|
56
|
+
insist { results["hits"]["total"] } == 2
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
values = results["hits"]["hits"].collect { |r| r["_source"]["somevalue"] }
|
59
|
+
insist { values }.include?(10)
|
60
|
+
insist { values }.include?(100)
|
61
|
+
reject { values }.include?(1)
|
62
|
+
end
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
it "does not create .keyword field for top-level message field" do
|
65
|
+
results = @es.search(:q => "message.keyword:\"sample message here\"")
|
66
|
+
insist { results["hits"]["total"] } == 0
|
67
|
+
end
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
it "creates .keyword field for nested message fields" do
|
70
|
+
results = @es.search(:q => "somemessage.message.keyword:\"sample nested message here\"")
|
71
|
+
insist { results["hits"]["total"] } == 1
|
72
|
+
end
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
it "creates .keyword field from any string field which is not_analyzed" do
|
75
|
+
results = @es.search(:q => "country.keyword:\"us\"")
|
76
|
+
insist { results["hits"]["total"] } == 1
|
77
|
+
insist { results["hits"]["hits"][0]["_source"]["country"] } == "us"
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
# partial or terms should not work.
|
80
|
+
results = @es.search(:q => "country.keyword:\"u\"")
|
81
|
+
insist { results["hits"]["total"] } == 0
|
82
|
+
end
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
it "make [geoip][location] a geo_point" do
|
85
|
+
expect(@es.indices.get_template(name: "logstash")["logstash"]["mappings"]["_default_"]["properties"]["geoip"]["properties"]["location"]["type"]).to eq("geo_point")
|
86
|
+
end
|
87
87
|
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
it "aggregate .keyword results correctly " do
|
89
|
+
results = @es.search(:body => { "aggregations" => { "my_agg" => { "terms" => { "field" => "country.keyword" } } } })["aggregations"]["my_agg"]
|
90
|
+
terms = results["buckets"].collect { |b| b["key"] }
|
91
91
|
|
92
|
-
|
92
|
+
insist { terms }.include?("us")
|
93
93
|
|
94
|
-
|
95
|
-
|
94
|
+
# 'at' is a stopword, make sure stopwords are not ignored.
|
95
|
+
insist { terms }.include?("at")
|
96
|
+
end
|
96
97
|
end
|
97
98
|
end
|
98
|
-
|
99
|
-
|
@@ -1,98 +1,98 @@
|
|
1
1
|
require_relative "../../../spec/es_spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
before :each do
|
15
|
-
# Delete all templates first.
|
16
|
-
require "elasticsearch"
|
17
|
-
|
18
|
-
# Clean ES of data before we start.
|
19
|
-
@es = get_client
|
20
|
-
@es.indices.delete_template(:name => "*")
|
21
|
-
|
22
|
-
# This can fail if there are no indexes, ignore failure.
|
23
|
-
@es.indices.delete(:index => "*") rescue nil
|
24
|
-
|
25
|
-
subject.register
|
26
|
-
|
27
|
-
subject.multi_receive([
|
28
|
-
LogStash::Event.new("message" => "sample message here"),
|
29
|
-
LogStash::Event.new("somemessage" => { "message" => "sample nested message here" }),
|
30
|
-
LogStash::Event.new("somevalue" => 100),
|
31
|
-
LogStash::Event.new("somevalue" => 10),
|
32
|
-
LogStash::Event.new("somevalue" => 1),
|
33
|
-
LogStash::Event.new("country" => "us"),
|
34
|
-
LogStash::Event.new("country" => "at"),
|
35
|
-
LogStash::Event.new("geoip" => { "location" => [ 0.0, 0.0 ] })
|
36
|
-
])
|
37
|
-
|
38
|
-
@es.indices.refresh
|
3
|
+
if ESHelper.es_version_satisfies?("< 5")
|
4
|
+
describe "index template expected behavior", :integration => true do
|
5
|
+
subject! do
|
6
|
+
require "logstash/outputs/elasticsearch"
|
7
|
+
settings = {
|
8
|
+
"manage_template" => true,
|
9
|
+
"template_overwrite" => true,
|
10
|
+
"hosts" => "#{get_host_port()}"
|
11
|
+
}
|
12
|
+
next LogStash::Outputs::ElasticSearch.new(settings)
|
13
|
+
end
|
39
14
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
15
|
+
before :each do
|
16
|
+
# Delete all templates first.
|
17
|
+
require "elasticsearch"
|
18
|
+
|
19
|
+
# Clean ES of data before we start.
|
20
|
+
@es = get_client
|
21
|
+
@es.indices.delete_template(:name => "*")
|
22
|
+
|
23
|
+
# This can fail if there are no indexes, ignore failure.
|
24
|
+
@es.indices.delete(:index => "*") rescue nil
|
25
|
+
|
26
|
+
subject.register
|
27
|
+
|
28
|
+
subject.multi_receive([
|
29
|
+
LogStash::Event.new("message" => "sample message here"),
|
30
|
+
LogStash::Event.new("somemessage" => { "message" => "sample nested message here" }),
|
31
|
+
LogStash::Event.new("somevalue" => 100),
|
32
|
+
LogStash::Event.new("somevalue" => 10),
|
33
|
+
LogStash::Event.new("somevalue" => 1),
|
34
|
+
LogStash::Event.new("country" => "us"),
|
35
|
+
LogStash::Event.new("country" => "at"),
|
36
|
+
LogStash::Event.new("geoip" => { "location" => [ 0.0, 0.0 ] })
|
37
|
+
])
|
38
|
+
|
39
|
+
@es.indices.refresh
|
40
|
+
|
41
|
+
# Wait or fail until everything's indexed.
|
42
|
+
Stud::try(20.times) do
|
43
|
+
r = @es.search
|
44
|
+
insist { r["hits"]["total"] } == 8
|
45
|
+
end
|
44
46
|
end
|
45
|
-
end
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
it "permits phrase searching on string fields" do
|
49
|
+
results = @es.search(:q => "message:\"sample message\"")
|
50
|
+
insist { results["hits"]["total"] } == 1
|
51
|
+
insist { results["hits"]["hits"][0]["_source"]["message"] } == "sample message here"
|
52
|
+
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
it "numbers dynamically map to a numeric type and permit range queries" do
|
55
|
+
results = @es.search(:q => "somevalue:[5 TO 105]")
|
56
|
+
insist { results["hits"]["total"] } == 2
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
values = results["hits"]["hits"].collect { |r| r["_source"]["somevalue"] }
|
59
|
+
insist { values }.include?(10)
|
60
|
+
insist { values }.include?(100)
|
61
|
+
reject { values }.include?(1)
|
62
|
+
end
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
it "does not create .raw field for the message field" do
|
65
|
+
results = @es.search(:q => "message.raw:\"sample message here\"")
|
66
|
+
insist { results["hits"]["total"] } == 0
|
67
|
+
end
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
69
|
+
it "creates .raw field for nested message fields" do
|
70
|
+
results = @es.search(:q => "somemessage.message.raw:\"sample nested message here\"")
|
71
|
+
insist { results["hits"]["total"] } == 1
|
72
|
+
end
|
72
73
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
it "creates .raw field from any string field which is not_analyzed" do
|
75
|
+
results = @es.search(:q => "country.raw:\"us\"")
|
76
|
+
insist { results["hits"]["total"] } == 1
|
77
|
+
insist { results["hits"]["hits"][0]["_source"]["country"] } == "us"
|
77
78
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
# partial or terms should not work.
|
80
|
+
results = @es.search(:q => "country.raw:\"u\"")
|
81
|
+
insist { results["hits"]["total"] } == 0
|
82
|
+
end
|
82
83
|
|
83
|
-
|
84
|
-
|
85
|
-
|
84
|
+
it "make [geoip][location] a geo_point" do
|
85
|
+
expect(@es.indices.get_template(name: "logstash")["logstash"]["mappings"]["_default_"]["properties"]["geoip"]["properties"]["location"]["type"]).to eq("geo_point")
|
86
|
+
end
|
86
87
|
|
87
|
-
|
88
|
-
|
89
|
-
|
88
|
+
it "aggregate .raw results correctly " do
|
89
|
+
results = @es.search(:body => { "aggregations" => { "my_agg" => { "terms" => { "field" => "country.raw" } } } })["aggregations"]["my_agg"]
|
90
|
+
terms = results["buckets"].collect { |b| b["key"] }
|
90
91
|
|
91
|
-
|
92
|
+
insist { terms }.include?("us")
|
92
93
|
|
93
|
-
|
94
|
-
|
94
|
+
# 'at' is a stopword, make sure stopwords are not ignored.
|
95
|
+
insist { terms }.include?("at")
|
96
|
+
end
|
95
97
|
end
|
96
98
|
end
|
97
|
-
|
98
|
-
|
@@ -1,114 +1,116 @@
|
|
1
1
|
require_relative "../../../spec/es_spec_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
before :each do
|
18
|
-
@es = get_client
|
19
|
-
# Delete all templates first.
|
20
|
-
# Clean ES of data before we start.
|
21
|
-
@es.indices.delete_template(:name => "*")
|
22
|
-
# This can fail if there are no indexes, ignore failure.
|
23
|
-
@es.indices.delete(:index => "*") rescue nil
|
24
|
-
@es.index(
|
25
|
-
:index => 'logstash-update',
|
26
|
-
:type => 'logs',
|
27
|
-
:id => "123",
|
28
|
-
:body => { :message => 'Test', :counter => 1 }
|
29
|
-
)
|
30
|
-
@es.indices.refresh
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should fail without a document_id" do
|
34
|
-
subject = get_es_output
|
35
|
-
expect { subject.register }.to raise_error(LogStash::ConfigurationError)
|
36
|
-
end
|
37
|
-
|
38
|
-
context "when update only" do
|
39
|
-
it "should not create new document" do
|
40
|
-
subject = get_es_output({ 'document_id' => "456" } )
|
41
|
-
subject.register
|
42
|
-
subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
|
43
|
-
expect {@es.get(:index => 'logstash-update', :type => 'logs', :id => "456", :refresh => true)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should update existing document" do
|
47
|
-
subject = get_es_output({ 'document_id' => "123" })
|
48
|
-
subject.register
|
49
|
-
subject.multi_receive([LogStash::Event.new("message" => "updated message here")])
|
50
|
-
r = @es.get(:index => 'logstash-update', :type => 'logs', :id => "123", :refresh => true)
|
51
|
-
insist { r["_source"]["message"] } == 'updated message here'
|
52
|
-
end
|
53
|
-
|
54
|
-
# The es ruby client treats the data field differently. Make sure this doesn't
|
55
|
-
# raise an exception
|
56
|
-
it "should update an existing document that has a 'data' field" do
|
57
|
-
subject = get_es_output({ 'document_id' => "123" })
|
58
|
-
subject.register
|
59
|
-
subject.multi_receive([LogStash::Event.new("data" => "updated message here", "message" => "foo")])
|
60
|
-
r = @es.get(:index => 'logstash-update', :type => 'logs', :id => "123", :refresh => true)
|
61
|
-
insist { r["_source"]["data"] } == 'updated message here'
|
62
|
-
insist { r["_source"]["message"] } == 'foo'
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should allow default (internal) version" do
|
66
|
-
subject = get_es_output({ 'document_id' => "123", "version" => "99" })
|
67
|
-
subject.register
|
3
|
+
if ESHelper.es_version_satisfies?(">= 2")
|
4
|
+
describe "Update actions without scripts", :integration => true do
|
5
|
+
require "logstash/outputs/elasticsearch"
|
6
|
+
|
7
|
+
def get_es_output( options={} )
|
8
|
+
settings = {
|
9
|
+
"manage_template" => true,
|
10
|
+
"index" => "logstash-update",
|
11
|
+
"template_overwrite" => true,
|
12
|
+
"hosts" => get_host_port(),
|
13
|
+
"action" => "update"
|
14
|
+
}
|
15
|
+
LogStash::Outputs::ElasticSearch.new(settings.merge!(options))
|
68
16
|
end
|
69
17
|
|
70
|
-
|
71
|
-
|
72
|
-
|
18
|
+
before :each do
|
19
|
+
@es = get_client
|
20
|
+
# Delete all templates first.
|
21
|
+
# Clean ES of data before we start.
|
22
|
+
@es.indices.delete_template(:name => "*")
|
23
|
+
# This can fail if there are no indexes, ignore failure.
|
24
|
+
@es.indices.delete(:index => "*") rescue nil
|
25
|
+
@es.index(
|
26
|
+
:index => 'logstash-update',
|
27
|
+
:type => 'logs',
|
28
|
+
:id => "123",
|
29
|
+
:body => { :message => 'Test', :counter => 1 }
|
30
|
+
)
|
31
|
+
@es.indices.refresh
|
73
32
|
end
|
74
33
|
|
75
|
-
it "should
|
76
|
-
subject = get_es_output
|
34
|
+
it "should fail without a document_id" do
|
35
|
+
subject = get_es_output
|
77
36
|
expect { subject.register }.to raise_error(LogStash::ConfigurationError)
|
78
37
|
end
|
79
38
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
39
|
+
context "when update only" do
|
40
|
+
it "should not create new document" do
|
41
|
+
subject = get_es_output({ 'document_id' => "456" } )
|
42
|
+
subject.register
|
43
|
+
subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
|
44
|
+
expect {@es.get(:index => 'logstash-update', :type => 'logs', :id => "456", :refresh => true)}.to raise_error(Elasticsearch::Transport::Transport::Errors::NotFound)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should update existing document" do
|
48
|
+
subject = get_es_output({ 'document_id' => "123" })
|
49
|
+
subject.register
|
50
|
+
subject.multi_receive([LogStash::Event.new("message" => "updated message here")])
|
51
|
+
r = @es.get(:index => 'logstash-update', :type => 'logs', :id => "123", :refresh => true)
|
52
|
+
insist { r["_source"]["message"] } == 'updated message here'
|
53
|
+
end
|
54
|
+
|
55
|
+
# The es ruby client treats the data field differently. Make sure this doesn't
|
56
|
+
# raise an exception
|
57
|
+
it "should update an existing document that has a 'data' field" do
|
58
|
+
subject = get_es_output({ 'document_id' => "123" })
|
59
|
+
subject.register
|
60
|
+
subject.multi_receive([LogStash::Event.new("data" => "updated message here", "message" => "foo")])
|
61
|
+
r = @es.get(:index => 'logstash-update', :type => 'logs', :id => "123", :refresh => true)
|
62
|
+
insist { r["_source"]["data"] } == 'updated message here'
|
63
|
+
insist { r["_source"]["message"] } == 'foo'
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should allow default (internal) version" do
|
67
|
+
subject = get_es_output({ 'document_id' => "123", "version" => "99" })
|
68
|
+
subject.register
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should allow internal version" do
|
72
|
+
subject = get_es_output({ 'document_id' => "123", "version" => "99", "version_type" => "internal" })
|
73
|
+
subject.register
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should not allow external version" do
|
77
|
+
subject = get_es_output({ 'document_id' => "123", "version" => "99", "version_type" => "external" })
|
78
|
+
expect { subject.register }.to raise_error(LogStash::ConfigurationError)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should not allow external_gt version" do
|
82
|
+
subject = get_es_output({ 'document_id' => "123", "version" => "99", "version_type" => "external_gt" })
|
83
|
+
expect { subject.register }.to raise_error(LogStash::ConfigurationError)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should not allow external_gte version" do
|
87
|
+
subject = get_es_output({ 'document_id' => "123", "version" => "99", "version_type" => "external_gte" })
|
88
|
+
expect { subject.register }.to raise_error(LogStash::ConfigurationError)
|
89
|
+
end
|
84
90
|
|
85
|
-
it "should not allow external_gte version" do
|
86
|
-
subject = get_es_output({ 'document_id' => "123", "version" => "99", "version_type" => "external_gte" })
|
87
|
-
expect { subject.register }.to raise_error(LogStash::ConfigurationError)
|
88
91
|
end
|
89
92
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
expect { subject.register }.to raise_error(LogStash::ConfigurationError)
|
93
|
+
context "when update with upsert" do
|
94
|
+
it "should create new documents with provided upsert" do
|
95
|
+
subject = get_es_output({ 'document_id' => "456", 'upsert' => '{"message": "upsert message"}' })
|
96
|
+
subject.register
|
97
|
+
subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
|
98
|
+
r = @es.get(:index => 'logstash-update', :type => 'logs', :id => "456", :refresh => true)
|
99
|
+
insist { r["_source"]["message"] } == 'upsert message'
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should create new documents with event/doc as upsert" do
|
103
|
+
subject = get_es_output({ 'document_id' => "456", 'doc_as_upsert' => true })
|
104
|
+
subject.register
|
105
|
+
subject.multi_receive([LogStash::Event.new("message" => "sample message here")])
|
106
|
+
r = @es.get(:index => 'logstash-update', :type => 'logs', :id => "456", :refresh => true)
|
107
|
+
insist { r["_source"]["message"] } == 'sample message here'
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should fail on documents with event/doc as upsert at external version" do
|
111
|
+
subject = get_es_output({ 'document_id' => "456", 'doc_as_upsert' => true, 'version' => 999, "version_type" => "external" })
|
112
|
+
expect { subject.register }.to raise_error(LogStash::ConfigurationError)
|
113
|
+
end
|
112
114
|
end
|
113
115
|
end
|
114
116
|
end
|