From 9bcc095658c63842117af6da3c01a2d7904ca184 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Fri, 1 Feb 2019 09:42:08 +0100 Subject: [PATCH] fixed tests --- .../local/LocalExporterResourceIntegTests.java | 10 +++++++--- .../xpack/monitoring/integration/MonitoringIT.java | 5 ++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterResourceIntegTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterResourceIntegTests.java index 5448521594dfe..3fd9e079f47ae 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterResourceIntegTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterResourceIntegTests.java @@ -10,6 +10,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.ingest.PipelineConfiguration; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.xpack.core.monitoring.MonitoredSystem; @@ -81,11 +82,14 @@ private static BytesReference generateTemplateSource(final String name, final In .field("index.number_of_replicas", 0) .endObject() .startObject("mappings") - .startObject("doc") + // Still need use type, RestPutIndexTemplateAction#prepareRequestSource has logic that adds type if missing + .startObject(MapperService.SINGLE_MAPPING_NAME) + .startObject("_source") + .field("enabled", false) + .endObject() .startObject("_meta") .field("test", true) .endObject() - .field("enabled", false) .endObject() .endObject(); @@ -193,7 +197,7 @@ private void assertTemplateNotUpdated() { final String name = MonitoringTemplateUtils.templateName(system.getSystem()); for (IndexTemplateMetaData template : client().admin().indices().prepareGetTemplates(name).get().getIndexTemplates()) { - final String docMapping = template.getMappings().get("doc").toString(); + final String docMapping = template.getMappings().get(MapperService.SINGLE_MAPPING_NAME).toString(); assertThat(docMapping, notNullValue()); assertThat(docMapping, containsString("test")); diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java index de3e6a8f2d60d..ec5515819c71a 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java @@ -23,10 +23,10 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.common.xcontent.XContentType; +import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.license.License; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.rest.RestStatus; -import org.elasticsearch.rest.action.document.RestBulkAction; import org.elasticsearch.search.SearchHit; import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.collapse.CollapseBuilder; @@ -178,10 +178,9 @@ public void testMonitoringBulk() throws Exception { equalTo(1L)); for (final SearchHit hit : hits.getHits()) { - assertMonitoringDoc(toMap(hit), system, "test", interval); + assertMonitoringDoc(toMap(hit), system, MapperService.SINGLE_MAPPING_NAME, interval); } }); - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } /**