From 2cd4b9b01092a7a24c755a5d131b677c543033a6 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 22 Jan 2019 18:59:25 -0800 Subject: [PATCH 01/16] Remove types from Monitoring plugin code --- .../xpack/monitoring/exporter/http/HttpExportBulk.java | 3 +-- .../xpack/monitoring/exporter/local/LocalBulk.java | 6 +++--- .../monitoring/watches/elasticsearch_cluster_status.json | 1 - .../resources/monitoring/watches/elasticsearch_nodes.json | 1 - .../watches/elasticsearch_version_mismatch.json | 1 - .../monitoring/watches/kibana_version_mismatch.json | 1 - .../monitoring/watches/logstash_version_mismatch.json | 1 - .../monitoring/watches/xpack_license_expiration.json | 1 - .../monitoring/action/MonitoringBulkRequestTests.java | 8 +------- .../exporter/local/LocalExporterIntegTests.java | 1 - .../exporter/local/LocalExporterResourceIntegTests.java | 8 +++----- .../xpack/monitoring/integration/MonitoringIT.java | 7 +++---- .../rest/action/RestMonitoringBulkActionTests.java | 2 +- .../monitoring/src/test/resources/monitoring-test.json | 6 ++---- 14 files changed, 14 insertions(+), 33 deletions(-) diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java index c00448c903a47..d68879c0363a4 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java @@ -142,7 +142,6 @@ private byte[] toBulkBytes(final MonitoringDoc doc) throws IOException { builder.startObject("index"); { builder.field("_index", index); - builder.field("_type", "doc"); if (id != null) { builder.field("_id", id); } @@ -162,7 +161,7 @@ private byte[] toBulkBytes(final MonitoringDoc doc) throws IOException { // Adds final bulk separator out.write(xContent.streamSeparator()); - logger.trace("added index request [index={}, type={}, id={}]", index, doc.getType(), id); + logger.trace("http exporter [{}] - added index request [index={}, id={}]", name, index, id); return BytesReference.toBytes(out.bytes()); } catch (Exception e) { diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalBulk.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalBulk.java index 05320224eded7..169eeaa757bbe 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalBulk.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalBulk.java @@ -66,7 +66,7 @@ public void doAdd(Collection docs) throws ExportException { try { final String index = MonitoringTemplateUtils.indexName(formatter, doc.getSystem(), doc.getTimestamp()); - final IndexRequest request = new IndexRequest(index, "doc"); + final IndexRequest request = new IndexRequest(index); if (Strings.hasText(doc.getId())) { request.id(doc.getId()); } @@ -82,8 +82,8 @@ public void doAdd(Collection docs) throws ExportException { requestBuilder.add(request); if (logger.isTraceEnabled()) { - logger.trace("local exporter [{}] - added index request [index={}, type={}, id={}, pipeline={}]", - name, request.index(), request.type(), request.id(), request.getPipeline()); + logger.trace("local exporter [{}] - added index request [index={}, id={}, pipeline={}]", + name, request.index(), request.id(), request.getPipeline()); } } catch (Exception e) { if (exception == null) { diff --git a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_cluster_status.json b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_cluster_status.json index 1a177a26e7cf2..fca6171b62329 100644 --- a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_cluster_status.json +++ b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_cluster_status.json @@ -152,7 +152,6 @@ "add_to_alerts_index": { "index": { "index": ".monitoring-alerts-6", - "doc_type": "doc", "doc_id": "${monitoring.watch.unique_id}" } }, diff --git a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_nodes.json b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_nodes.json index 4b45cb38f07d4..9f1e80a411d1e 100644 --- a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_nodes.json +++ b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_nodes.json @@ -158,7 +158,6 @@ "add_to_alerts_index": { "index": { "index": ".monitoring-alerts-6", - "doc_type": "doc" } }, "send_email_to_admin": { diff --git a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_version_mismatch.json b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_version_mismatch.json index 7cb494ce8e712..61d77d2b602fb 100644 --- a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_version_mismatch.json +++ b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_version_mismatch.json @@ -148,7 +148,6 @@ "add_to_alerts_index": { "index": { "index": ".monitoring-alerts-6", - "doc_type": "doc", "doc_id": "${monitoring.watch.unique_id}" } }, diff --git a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/kibana_version_mismatch.json b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/kibana_version_mismatch.json index 7ec176c57897a..95de1a1a6383e 100644 --- a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/kibana_version_mismatch.json +++ b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/kibana_version_mismatch.json @@ -168,7 +168,6 @@ "add_to_alerts_index": { "index": { "index": ".monitoring-alerts-6", - "doc_type": "doc", "doc_id": "${monitoring.watch.unique_id}" } }, diff --git a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/logstash_version_mismatch.json b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/logstash_version_mismatch.json index 69fc05f7ccee8..7448000fa8516 100644 --- a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/logstash_version_mismatch.json +++ b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/logstash_version_mismatch.json @@ -168,7 +168,6 @@ "add_to_alerts_index": { "index": { "index": ".monitoring-alerts-6", - "doc_type": "doc", "doc_id": "${monitoring.watch.unique_id}" } }, diff --git a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/xpack_license_expiration.json b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/xpack_license_expiration.json index e7c05fbcde11b..d61bb3cd952cc 100644 --- a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/xpack_license_expiration.json +++ b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/xpack_license_expiration.json @@ -141,7 +141,6 @@ "add_to_alerts_index": { "index": { "index": ".monitoring-alerts-6", - "doc_type": "doc", "doc_id": "${monitoring.watch.unique_id}" } }, diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java index a8ab2960194f2..1bfb72df99fb9 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java @@ -94,10 +94,6 @@ public void testAddRequestContent() throws IOException { if (rarely()) { builder.field("_index", ""); } - if (defaultType == null || randomBoolean()) { - types[i] = randomAlphaOfLength(5); - builder.field("_type", types[i]); - } if (randomBoolean()) { ids[i] = randomAlphaOfLength(10); builder.field("_id", ids[i]); @@ -162,7 +158,6 @@ public void testAddRequestContentWithEmptySource() throws IOException { builder.startObject("index"); { builder.field("_index", ""); - builder.field("_type", "doc"); builder.field("_id", String.valueOf(i)); } builder.endObject(); @@ -208,7 +203,6 @@ public void testAddRequestContentWithUnrecognizedIndexName() throws IOException builder.startObject("index"); { builder.field("_index", indexName); - builder.field("_type", "doc"); } builder.endObject(); } @@ -232,7 +226,7 @@ public void testAddRequestContentWithUnrecognizedIndexName() throws IOException assertThat(e.getMessage(), containsString("unrecognized index name [" + indexName + "]")); //This test's JSON contains outdated references to types assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); - + } public void testSerialization() throws IOException { diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java index 6caefe148b28a..577a7916c9efa 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java @@ -276,7 +276,6 @@ private void checkMonitoringDocs() { assertTrue("document is missing cluster_uuid field", Strings.hasText((String) source.get("cluster_uuid"))); assertTrue("document is missing timestamp field", Strings.hasText(timestamp)); assertTrue("document is missing type field", Strings.hasText(type)); - assertEquals("document _type is 'doc'", "doc", hit.getType()); @SuppressWarnings("unchecked") Map docSource = (Map) source.get("doc"); 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..2d518e9bb83f8 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 @@ -81,12 +81,10 @@ private static BytesReference generateTemplateSource(final String name, final In .field("index.number_of_replicas", 0) .endObject() .startObject("mappings") - .startObject("doc") - .startObject("_meta") - .field("test", true) - .endObject() - .field("enabled", false) + .startObject("_meta") + .field("test", true) .endObject() + .field("enabled", false) .endObject(); if (version != null) { 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 555f2659113fd..de3e6a8f2d60d 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 @@ -104,11 +104,11 @@ protected Collection> getPlugins() { } private String createBulkEntity() { - return "{\"index\":{\"_type\":\"test\"}}\n" + + return "{\"index\":{}}\n" + "{\"foo\":{\"bar\":0}}\n" + - "{\"index\":{\"_type\":\"test\"}}\n" + + "{\"index\":{}}\n" + "{\"foo\":{\"bar\":1}}\n" + - "{\"index\":{\"_type\":\"test\"}}\n" + + "{\"index\":{}}\n" + "{\"foo\":{\"bar\":2}}\n" + "\n"; } @@ -264,7 +264,6 @@ private void assertMonitoringDoc(final Map document, final String index = (String) document.get("_index"); assertThat(index, containsString(".monitoring-" + expectedSystem.getSystem() + "-" + TEMPLATE_VERSION + "-")); - assertThat(document.get("_type"), equalTo("doc")); assertThat((String) document.get("_id"), not(isEmptyOrNullString())); final Map source = (Map) document.get("_source"); diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java index 10fc10e3f973d..67ab51e4f5488 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java @@ -217,7 +217,7 @@ private static FakeRestRequest createRestRequest(final int nbDocs, if (nbDocs > 0) { final StringBuilder requestBody = new StringBuilder(); for (int n = 0; n < nbDocs; n++) { - requestBody.append("{\"index\":{\"_type\":\"_doc\"}}\n"); + requestBody.append("{\"index\":{}}\n"); requestBody.append("{\"field\":").append(n).append("}\n"); } requestBody.append("\n"); diff --git a/x-pack/plugin/monitoring/src/test/resources/monitoring-test.json b/x-pack/plugin/monitoring/src/test/resources/monitoring-test.json index e2abf9e699afe..bd85ab88cc1c9 100644 --- a/x-pack/plugin/monitoring/src/test/resources/monitoring-test.json +++ b/x-pack/plugin/monitoring/src/test/resources/monitoring-test.json @@ -1,10 +1,8 @@ { "index_patterns": ".monitoring-data-${monitoring.template.version}", "mappings": { - "doc": { - "_meta": { - "template.version": "${monitoring.template.version}" - } + "_meta": { + "template.version": "${monitoring.template.version}" } } } From d824964f7e80e29281c8d9a92eed8817a559d0ba Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 29 Jan 2019 05:44:21 -0800 Subject: [PATCH 02/16] Adding monitoring data types to trace logs --- .../xpack/monitoring/exporter/http/HttpExportBulk.java | 2 +- .../xpack/monitoring/exporter/local/LocalBulk.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java index d68879c0363a4..23d37d370d5ff 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java @@ -161,7 +161,7 @@ private byte[] toBulkBytes(final MonitoringDoc doc) throws IOException { // Adds final bulk separator out.write(xContent.streamSeparator()); - logger.trace("http exporter [{}] - added index request [index={}, id={}]", name, index, id); + logger.trace("http exporter [{}] - added index request [index={}, id={}, monitoring data type={}]", name, index, id, doc.getType()); return BytesReference.toBytes(out.bytes()); } catch (Exception e) { diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalBulk.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalBulk.java index 169eeaa757bbe..64d5627f4abce 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalBulk.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalBulk.java @@ -82,8 +82,8 @@ public void doAdd(Collection docs) throws ExportException { requestBuilder.add(request); if (logger.isTraceEnabled()) { - logger.trace("local exporter [{}] - added index request [index={}, id={}, pipeline={}]", - name, request.index(), request.id(), request.getPipeline()); + logger.trace("local exporter [{}] - added index request [index={}, id={}, pipeline={}, monitoring data type={}]", + name, request.index(), request.id(), request.getPipeline(), doc.getType()); } } catch (Exception e) { if (exception == null) { From 9d00b799d728f122e418eb453729d60c43d8c4a0 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 29 Jan 2019 05:52:58 -0800 Subject: [PATCH 03/16] Make JSON Valid Again --- .../main/resources/monitoring/watches/elasticsearch_nodes.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_nodes.json b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_nodes.json index 9f1e80a411d1e..0566d03f21f5f 100644 --- a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_nodes.json +++ b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_nodes.json @@ -157,7 +157,7 @@ "actions": { "add_to_alerts_index": { "index": { - "index": ".monitoring-alerts-6", + "index": ".monitoring-alerts-6" } }, "send_email_to_admin": { From f69158572f58f6bfc8fde24e0854d457928057c7 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Tue, 29 Jan 2019 05:58:59 -0800 Subject: [PATCH 04/16] Fixing bad field nesting --- .../exporter/local/LocalExporterResourceIntegTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2d518e9bb83f8..8ce8b15e688bf 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 @@ -83,8 +83,8 @@ private static BytesReference generateTemplateSource(final String name, final In .startObject("mappings") .startObject("_meta") .field("test", true) + .field("enabled", false) .endObject() - .field("enabled", false) .endObject(); if (version != null) { From da1a299f650b3e408820871ab9866d386dfaf3f8 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Wed, 30 Jan 2019 10:49:38 -0800 Subject: [PATCH 05/16] Fixing checkstyle violation --- .../xpack/monitoring/exporter/http/HttpExportBulk.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java index 23d37d370d5ff..780bc1e43bfa9 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExportBulk.java @@ -161,7 +161,10 @@ private byte[] toBulkBytes(final MonitoringDoc doc) throws IOException { // Adds final bulk separator out.write(xContent.streamSeparator()); - logger.trace("http exporter [{}] - added index request [index={}, id={}, monitoring data type={}]", name, index, id, doc.getType()); + logger.trace( + "http exporter [{}] - added index request [index={}, id={}, monitoring data type={}]", + name, index, id, doc.getType() + ); return BytesReference.toBytes(out.bytes()); } catch (Exception e) { From abd8699773c4935be7abf6e14a37d1c0317b3129 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 31 Jan 2019 15:15:24 -0800 Subject: [PATCH 06/16] Some unit test fixes (more coming...) --- .../monitoring/exporter/MonitoringTemplateUtilsTests.java | 6 ++---- .../rest/action/RestMonitoringBulkActionTests.java | 6 +----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java index 5c010439243a0..2237b4f1ce55d 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java @@ -59,10 +59,8 @@ public void testLoadTemplate() throws IOException { assertTemplate(source, equalTo("{\n" + " \"index_patterns\": \".monitoring-data-" + TEMPLATE_VERSION + "\",\n" + " \"mappings\": {\n" + - " \"doc\": {\n" + - " \"_meta\": {\n" + - " \"template.version\": \"" + TEMPLATE_VERSION + "\"\n" + - " }\n" + + " \"_meta\": {\n" + + " \"template.version\": \"" + TEMPLATE_VERSION + "\"\n" + " }\n" + " }\n" + "}\n")); diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java index 67ab51e4f5488..52dde987727ce 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java @@ -121,9 +121,7 @@ public void testNoErrors() throws Exception { assertThat(restResponse.status(), is(RestStatus.OK)); assertThat(restResponse.content().utf8ToString(), - is("{\"took\":" + response.getTookInMillis() + ",\"ignored\":false,\"errors\":false}")); - //This test's JSON contains outdated references to types - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); + is("{\"took\":" + response.getTookInMillis() + ",\"ignored\":false,\"errors\":false}"));//This test's JSON contains outdated references to types } public void testNoErrorsButIgnored() throws Exception { @@ -155,8 +153,6 @@ public void testWithErrors() throws Exception { assertThat(restResponse.status(), is(RestStatus.INTERNAL_SERVER_ERROR)); assertThat(restResponse.content().utf8ToString(), is("{\"took\":" + response.getTookInMillis() + ",\"ignored\":false,\"errors\":true,\"error\":" + errorJson + "}")); - //This test's JSON contains outdated references to types - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } /** From 33fe13902c49d6ab6846014ab598451d3f67d8ae Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 31 Jan 2019 15:28:41 -0800 Subject: [PATCH 07/16] More unit test fixes --- .../monitoring/rest/action/RestMonitoringBulkActionTests.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java index 52dde987727ce..a89561eae6c72 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java @@ -132,8 +132,6 @@ public void testNoErrorsButIgnored() throws Exception { assertThat(restResponse.status(), is(RestStatus.OK)); assertThat(restResponse.content().utf8ToString(), is("{\"took\":" + response.getTookInMillis() + ",\"ignored\":true,\"errors\":false}")); - //This test's JSON contains outdated references to types - assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } public void testWithErrors() throws Exception { From 669f294ea797eddeb22eed3cd80c4bf17e5c8c9f Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 31 Jan 2019 15:45:12 -0800 Subject: [PATCH 08/16] Fixing checkstyle violations --- .../monitoring/rest/action/RestMonitoringBulkActionTests.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java index a89561eae6c72..ff55c6ab90533 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java @@ -23,7 +23,6 @@ import org.elasticsearch.rest.RestResponse; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.action.RestBuilderListener; -import org.elasticsearch.rest.action.document.RestBulkAction; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.rest.FakeRestRequest; import org.elasticsearch.xpack.core.XPackClient; @@ -121,7 +120,7 @@ public void testNoErrors() throws Exception { assertThat(restResponse.status(), is(RestStatus.OK)); assertThat(restResponse.content().utf8ToString(), - is("{\"took\":" + response.getTookInMillis() + ",\"ignored\":false,\"errors\":false}"));//This test's JSON contains outdated references to types + is("{\"took\":" + response.getTookInMillis() + ",\"ignored\":false,\"errors\":false}")); } public void testNoErrorsButIgnored() throws Exception { From b7eaeb88a3e0ea723e2ed1b52d397a6e1d745244 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 31 Jan 2019 16:05:27 -0800 Subject: [PATCH 09/16] Template mapping fixes --- .../exporter/local/LocalExporterResourceIntegTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 8ce8b15e688bf..117c345e14f65 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 @@ -81,9 +81,9 @@ private static BytesReference generateTemplateSource(final String name, final In .field("index.number_of_replicas", 0) .endObject() .startObject("mappings") + .field("enabled", false) .startObject("_meta") .field("test", true) - .field("enabled", false) .endObject() .endObject(); @@ -191,7 +191,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().toString(); assertThat(docMapping, notNullValue()); assertThat(docMapping, containsString("test")); From ab9c7ae677c4fcc4b1bdf21a21ade444bd32749a Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Thu, 31 Jan 2019 18:51:57 -0800 Subject: [PATCH 10/16] Reverting change to monitoring bulk endpoint code and tests --- .../monitoring/action/MonitoringBulkRequestTests.java | 7 ++++++- .../rest/action/RestMonitoringBulkActionTests.java | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java index 1bfb72df99fb9..fc3bf633a3964 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java @@ -94,6 +94,10 @@ public void testAddRequestContent() throws IOException { if (rarely()) { builder.field("_index", ""); } + if (defaultType == null || randomBoolean()) { + types[i] = randomAlphaOfLength(5); + builder.field("_type", types[i]); + } if (randomBoolean()) { ids[i] = randomAlphaOfLength(10); builder.field("_id", ids[i]); @@ -158,6 +162,7 @@ public void testAddRequestContentWithEmptySource() throws IOException { builder.startObject("index"); { builder.field("_index", ""); + builder.field("_type", "doc"); builder.field("_id", String.valueOf(i)); } builder.endObject(); @@ -203,6 +208,7 @@ public void testAddRequestContentWithUnrecognizedIndexName() throws IOException builder.startObject("index"); { builder.field("_index", indexName); + builder.field("_type", "doc"); } builder.endObject(); } @@ -226,7 +232,6 @@ public void testAddRequestContentWithUnrecognizedIndexName() throws IOException assertThat(e.getMessage(), containsString("unrecognized index name [" + indexName + "]")); //This test's JSON contains outdated references to types assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); - } public void testSerialization() throws IOException { diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java index ff55c6ab90533..10fc10e3f973d 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/rest/action/RestMonitoringBulkActionTests.java @@ -23,6 +23,7 @@ import org.elasticsearch.rest.RestResponse; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.action.RestBuilderListener; +import org.elasticsearch.rest.action.document.RestBulkAction; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.rest.FakeRestRequest; import org.elasticsearch.xpack.core.XPackClient; @@ -121,6 +122,8 @@ public void testNoErrors() throws Exception { assertThat(restResponse.status(), is(RestStatus.OK)); assertThat(restResponse.content().utf8ToString(), is("{\"took\":" + response.getTookInMillis() + ",\"ignored\":false,\"errors\":false}")); + //This test's JSON contains outdated references to types + assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } public void testNoErrorsButIgnored() throws Exception { @@ -131,6 +134,8 @@ public void testNoErrorsButIgnored() throws Exception { assertThat(restResponse.status(), is(RestStatus.OK)); assertThat(restResponse.content().utf8ToString(), is("{\"took\":" + response.getTookInMillis() + ",\"ignored\":true,\"errors\":false}")); + //This test's JSON contains outdated references to types + assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } public void testWithErrors() throws Exception { @@ -150,6 +155,8 @@ public void testWithErrors() throws Exception { assertThat(restResponse.status(), is(RestStatus.INTERNAL_SERVER_ERROR)); assertThat(restResponse.content().utf8ToString(), is("{\"took\":" + response.getTookInMillis() + ",\"ignored\":false,\"errors\":true,\"error\":" + errorJson + "}")); + //This test's JSON contains outdated references to types + assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); } /** @@ -210,7 +217,7 @@ private static FakeRestRequest createRestRequest(final int nbDocs, if (nbDocs > 0) { final StringBuilder requestBody = new StringBuilder(); for (int n = 0; n < nbDocs; n++) { - requestBody.append("{\"index\":{}}\n"); + requestBody.append("{\"index\":{\"_type\":\"_doc\"}}\n"); requestBody.append("{\"field\":").append(n).append("}\n"); } requestBody.append("\n"); From 8876abecf7aaf94b80198565312b4a15582e30d4 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 1 Feb 2019 16:07:51 -0800 Subject: [PATCH 11/16] Adding back doc to template mappings --- .../exporter/MonitoringTemplateUtilsTests.java | 6 ++++-- .../local/LocalExporterResourceIntegTests.java | 10 ++++++---- .../monitoring/src/test/resources/monitoring-test.json | 6 ++++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java index 2237b4f1ce55d..5c010439243a0 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/MonitoringTemplateUtilsTests.java @@ -59,8 +59,10 @@ public void testLoadTemplate() throws IOException { assertTemplate(source, equalTo("{\n" + " \"index_patterns\": \".monitoring-data-" + TEMPLATE_VERSION + "\",\n" + " \"mappings\": {\n" + - " \"_meta\": {\n" + - " \"template.version\": \"" + TEMPLATE_VERSION + "\"\n" + + " \"doc\": {\n" + + " \"_meta\": {\n" + + " \"template.version\": \"" + TEMPLATE_VERSION + "\"\n" + + " }\n" + " }\n" + " }\n" + "}\n")); 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 117c345e14f65..5448521594dfe 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 @@ -81,9 +81,11 @@ private static BytesReference generateTemplateSource(final String name, final In .field("index.number_of_replicas", 0) .endObject() .startObject("mappings") - .field("enabled", false) - .startObject("_meta") - .field("test", true) + .startObject("doc") + .startObject("_meta") + .field("test", true) + .endObject() + .field("enabled", false) .endObject() .endObject(); @@ -191,7 +193,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().toString(); + final String docMapping = template.getMappings().get("doc").toString(); assertThat(docMapping, notNullValue()); assertThat(docMapping, containsString("test")); diff --git a/x-pack/plugin/monitoring/src/test/resources/monitoring-test.json b/x-pack/plugin/monitoring/src/test/resources/monitoring-test.json index bd85ab88cc1c9..e2abf9e699afe 100644 --- a/x-pack/plugin/monitoring/src/test/resources/monitoring-test.json +++ b/x-pack/plugin/monitoring/src/test/resources/monitoring-test.json @@ -1,8 +1,10 @@ { "index_patterns": ".monitoring-data-${monitoring.template.version}", "mappings": { - "_meta": { - "template.version": "${monitoring.template.version}" + "doc": { + "_meta": { + "template.version": "${monitoring.template.version}" + } } } } From 9bcc095658c63842117af6da3c01a2d7904ca184 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Fri, 1 Feb 2019 09:42:08 +0100 Subject: [PATCH 12/16] 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); } /** From df335e315c83da234b2e5d9bbe40b77e2238e0ce Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 2 Feb 2019 02:40:47 -0800 Subject: [PATCH 13/16] Clarify type in the context of this test --- .../xpack/monitoring/integration/MonitoringIT.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 ec5515819c71a..1951083ae8fe4 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,7 +23,6 @@ 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; @@ -127,7 +126,7 @@ public void testMonitoringBulk() throws Exception { final MonitoringBulkResponse bulkResponse = new MonitoringBulkRequestBuilder(client()) - .add(system, null, new BytesArray(createBulkEntity().getBytes("UTF-8")), XContentType.JSON, + .add(system, "monitoring_data_type", new BytesArray(createBulkEntity().getBytes("UTF-8")), XContentType.JSON, System.currentTimeMillis(), interval.millis()) .get(); @@ -178,7 +177,7 @@ public void testMonitoringBulk() throws Exception { equalTo(1L)); for (final SearchHit hit : hits.getHits()) { - assertMonitoringDoc(toMap(hit), system, MapperService.SINGLE_MAPPING_NAME, interval); + assertMonitoringDoc(toMap(hit), system, "monitoring_data_type", interval); } }); } From 8f41a4b0ef23091ad7bc4ee86b3fcc232935e186 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sat, 2 Feb 2019 18:27:39 -0800 Subject: [PATCH 14/16] Fixing _type --- .../exporter/local/LocalExporterResourceIntegTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 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 3fd9e079f47ae..f33befd303455 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 @@ -83,7 +83,7 @@ private static BytesReference generateTemplateSource(final String name, final In .endObject() .startObject("mappings") // Still need use type, RestPutIndexTemplateAction#prepareRequestSource has logic that adds type if missing - .startObject(MapperService.SINGLE_MAPPING_NAME) + .startObject("doc") .startObject("_source") .field("enabled", false) .endObject() @@ -197,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(MapperService.SINGLE_MAPPING_NAME).toString(); + final String docMapping = template.getMappings().get("doc").toString(); assertThat(docMapping, notNullValue()); assertThat(docMapping, containsString("test")); From 79e7eed221d00975baa31fafc2dab278ea98f3f3 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Sun, 3 Feb 2019 04:08:31 -0800 Subject: [PATCH 15/16] Removing unused import --- .../exporter/local/LocalExporterResourceIntegTests.java | 1 - 1 file changed, 1 deletion(-) 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 f33befd303455..d788219004be7 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,7 +10,6 @@ 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; From c6d1c1081146a5289c14217a7f24ac9708b8d0d7 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Mon, 4 Feb 2019 08:37:26 -0800 Subject: [PATCH 16/16] Reverting unnecessary change --- .../exporter/local/LocalExporterResourceIntegTests.java | 4 +--- 1 file changed, 1 insertion(+), 3 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 d788219004be7..16ea27488d8a4 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 @@ -83,12 +83,10 @@ private static BytesReference generateTemplateSource(final String name, final In .startObject("mappings") // Still need use type, RestPutIndexTemplateAction#prepareRequestSource has logic that adds type if missing .startObject("doc") - .startObject("_source") - .field("enabled", false) - .endObject() .startObject("_meta") .field("test", true) .endObject() + .field("enabled", false) .endObject() .endObject();