Skip to content

Commit 184ae36

Browse files
committed
Fix tests for 7.x after type removal
Fixes #826
1 parent e3fa7e8 commit 184ae36

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

spec/es_spec_helper.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ def todays_date
3232

3333
def mapping_name
3434
if ESHelper.es_version_satisfies?(">=7")
35-
"_doc"
35+
nil
3636
else
3737
"_default_"
3838
end
39+
end
3940

41+
def field_properties_from_template(template_name, field)
42+
mappings = @es.indices.get_template(name: template_name)[template_name]["mappings"]
43+
(mapping_name.nil?) ? mappings["properties"][field]["properties"] : mappings[mapping_name]["properties"][field]["properties"]
4044
end
4145

4246
def routing_field_name

spec/integration/outputs/parent_spec.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,15 @@
7676

7777
shared_examples "a join field based parent indexer" do
7878
let(:index) { 10.times.collect { rand(10).to_s }.join("") }
79-
let(:type) { 10.times.collect { rand(10).to_s }.join("") }
79+
80+
let(:type) do
81+
if ESHelper.es_version_satisfies?('<7')
82+
10.times.collect { rand(10).to_s }.join("")
83+
else
84+
"_doc"
85+
end
86+
end
87+
8088
let(:event_count) { 10000 + rand(500) }
8189
let(:parent) { "not_implemented" }
8290
let(:config) { "not_implemented" }

spec/integration/outputs/templates_5x_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
end
8383

8484
it "make [geoip][location] a geo_point" do
85-
expect(@es.indices.get_template(name: "logstash")["logstash"]["mappings"][mapping_name]["properties"]["geoip"]["properties"]["location"]["type"]).to eq("geo_point")
85+
expect(field_properties_from_template("logstash", "geoip")["location"]["type"]).to eq("geo_point")
8686
end
8787

8888
it "aggregate .keyword results correctly " do

0 commit comments

Comments
 (0)