Skip to content

Commit 2f01f65

Browse files
authored
Add rudimentary logstash and beats template BWC tests (#20588)
This tests that the templates shipped with 5.0 versions of Logstash and Beats still work on an Elasticsearch 6.0+ node, so that we ensure that ES can be upgraded prior to upgrading tools dependent on it. Related to #20491 Resolves #17275
1 parent c1721c6 commit 2f01f65

File tree

6 files changed

+4347
-0
lines changed

6 files changed

+4347
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Licensed to Elasticsearch under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.elasticsearch.action.admin.indices.template;
21+
22+
import org.elasticsearch.test.ESSingleNodeTestCase;
23+
24+
import static org.elasticsearch.test.StreamsUtils.copyToStringFromClasspath;
25+
26+
/**
27+
* Rudimentary tests that the templates used by Logstash and Beats
28+
* prior to their 5.x releases work for newly created indices
29+
*/
30+
public class BWCTemplateTests extends ESSingleNodeTestCase {
31+
public void testBeatsTemplatesBWC() throws Exception {
32+
String metricBeat = copyToStringFromClasspath("/org/elasticsearch/action/admin/indices/template/metricbeat-5.0.template.json");
33+
String packetBeat = copyToStringFromClasspath("/org/elasticsearch/action/admin/indices/template/packetbeat-5.0.template.json");
34+
String fileBeat = copyToStringFromClasspath("/org/elasticsearch/action/admin/indices/template/filebeat-5.0.template.json");
35+
String winLogBeat = copyToStringFromClasspath("/org/elasticsearch/action/admin/indices/template/winlogbeat-5.0.template.json");
36+
client().admin().indices().preparePutTemplate("metricbeat").setSource(metricBeat).get();
37+
client().admin().indices().preparePutTemplate("packetbeat").setSource(packetBeat).get();
38+
client().admin().indices().preparePutTemplate("filebeat").setSource(fileBeat).get();
39+
client().admin().indices().preparePutTemplate("winlogbeat").setSource(winLogBeat).get();
40+
41+
client().prepareIndex("metricbeat-foo", "doc", "1").setSource("message", "foo").get();
42+
client().prepareIndex("packetbeat-foo", "doc", "1").setSource("message", "foo").get();
43+
client().prepareIndex("filebeat-foo", "doc", "1").setSource("message", "foo").get();
44+
client().prepareIndex("winlogbeat-foo", "doc", "1").setSource("message", "foo").get();
45+
}
46+
47+
public void testLogstashTemplatesBWC() throws Exception {
48+
String ls5x = copyToStringFromClasspath("/org/elasticsearch/action/admin/indices/template/logstash-5.0.template.json");
49+
client().admin().indices().preparePutTemplate("logstash-5x").setSource(ls5x).get();
50+
client().prepareIndex("logstash-foo", "doc", "1").setSource("message", "foo").get();
51+
}
52+
53+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"mappings": {
3+
"_default_": {
4+
"_all": {
5+
"norms": false
6+
},
7+
"_meta": {
8+
"version": "5.0.0-beta1"
9+
},
10+
"dynamic_templates": [
11+
{
12+
"fields": {
13+
"mapping": {
14+
"ignore_above": 1024,
15+
"type": "keyword"
16+
},
17+
"match_mapping_type": "string",
18+
"path_match": "fields.*"
19+
}
20+
}
21+
],
22+
"properties": {
23+
"@timestamp": {
24+
"type": "date"
25+
},
26+
"beat": {
27+
"properties": {
28+
"hostname": {
29+
"ignore_above": 1024,
30+
"type": "keyword"
31+
},
32+
"name": {
33+
"ignore_above": 1024,
34+
"type": "keyword"
35+
}
36+
}
37+
},
38+
"input_type": {
39+
"ignore_above": 1024,
40+
"type": "keyword"
41+
},
42+
"message": {
43+
"norms": false,
44+
"type": "text"
45+
},
46+
"offset": {
47+
"type": "long"
48+
},
49+
"source": {
50+
"ignore_above": 1024,
51+
"type": "keyword"
52+
},
53+
"tags": {
54+
"ignore_above": 1024,
55+
"type": "keyword"
56+
},
57+
"type": {
58+
"ignore_above": 1024,
59+
"type": "keyword"
60+
}
61+
}
62+
}
63+
},
64+
"order": 0,
65+
"settings": {
66+
"index.refresh_interval": "5s"
67+
},
68+
"template": "filebeat-*"
69+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"template" : "logstash-*",
3+
"settings" : {
4+
"index.refresh_interval" : "5s"
5+
},
6+
"mappings" : {
7+
"_default_" : {
8+
"_all" : {"enabled" : true, "norms" : false},
9+
"dynamic_templates" : [ {
10+
"message_field" : {
11+
"match" : "message",
12+
"match_mapping_type" : "string",
13+
"mapping" : {
14+
"type" : "string", "index" : "analyzed", "norms" : false,
15+
"fielddata" : { "format" : "disabled" }
16+
}
17+
}
18+
}, {
19+
"string_fields" : {
20+
"match" : "*",
21+
"match_mapping_type" : "string",
22+
"mapping" : {
23+
"type" : "text", "norms" : false,
24+
"fields" : {
25+
"keyword" : { "type": "keyword" }
26+
}
27+
}
28+
}
29+
} ],
30+
"properties" : {
31+
"@timestamp": { "type": "date", "include_in_all": false },
32+
"@version": { "type": "keyword", "include_in_all": false },
33+
"geoip" : {
34+
"dynamic": true,
35+
"properties" : {
36+
"ip": { "type": "ip" },
37+
"location" : { "type" : "geo_point" },
38+
"latitude" : { "type" : "half_float" },
39+
"longitude" : { "type" : "half_float" }
40+
}
41+
}
42+
}
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)