|
| 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 | +} |
0 commit comments