diff --git a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java index 7eaf4709a8b2a..6d226531d7538 100644 --- a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java @@ -22,11 +22,11 @@ import org.apache.http.util.EntityUtils; import org.elasticsearch.Version; import org.elasticsearch.client.Request; -import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.RestClient; -import org.elasticsearch.test.rest.TypesRemovalWarningsHandler; +import org.elasticsearch.rest.action.document.RestGetAction; +import org.elasticsearch.rest.action.search.RestExplainAction; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.Booleans; import org.elasticsearch.common.CheckedFunction; @@ -82,7 +82,6 @@ public void setIndex() throws IOException { index = getTestName().toLowerCase(Locale.ROOT); } - public void testSearch() throws Exception { int count; if (isRunningAgainstOldCluster()) { @@ -96,7 +95,7 @@ public void testSearch() throws Exception { } { mappingsAndSettings.startObject("mappings"); - mappingsAndSettings.startObject("_doc"); + mappingsAndSettings.startObject("doc"); mappingsAndSettings.startObject("properties"); { mappingsAndSettings.startObject("string"); @@ -162,7 +161,7 @@ public void testNewReplicasWork() throws Exception { } { mappingsAndSettings.startObject("mappings"); - mappingsAndSettings.startObject("_doc"); + mappingsAndSettings.startObject("doc"); mappingsAndSettings.startObject("properties"); { mappingsAndSettings.startObject("field"); @@ -233,7 +232,7 @@ public void testAliasWithBadName() throws Exception { } { mappingsAndSettings.startObject("mappings"); - mappingsAndSettings.startObject("_doc"); + mappingsAndSettings.startObject("doc"); mappingsAndSettings.startObject("properties"); { mappingsAndSettings.startObject("key"); @@ -336,7 +335,7 @@ public void testShrink() throws IOException { mappingsAndSettings.startObject(); { mappingsAndSettings.startObject("mappings"); - mappingsAndSettings.startObject("_doc"); + mappingsAndSettings.startObject("doc"); mappingsAndSettings.startObject("properties"); { mappingsAndSettings.startObject("field"); @@ -404,7 +403,7 @@ public void testShrinkAfterUpgrade() throws IOException { mappingsAndSettings.startObject(); { mappingsAndSettings.startObject("mappings"); - mappingsAndSettings.startObject("_doc"); + mappingsAndSettings.startObject("doc"); mappingsAndSettings.startObject("properties"); { mappingsAndSettings.startObject("field"); @@ -492,7 +491,7 @@ public void testRollover() throws IOException { bulk.append("{\"index\":{}}\n"); bulk.append("{\"test\":\"test\"}\n"); } - Request bulkRequest = new Request("POST", "/" + index + "_write/_doc/_bulk"); + Request bulkRequest = new Request("POST", "/" + index + "_write/doc/_bulk"); bulkRequest.setJsonEntity(bulk.toString()); bulkRequest.addParameter("refresh", ""); assertThat(EntityUtils.toString(client().performRequest(bulkRequest).getEntity()), containsString("\"errors\":false")); @@ -571,19 +570,15 @@ void assertAllSearchWorks(int count) throws IOException { String type = (String) bestHit.get("_type"); String id = (String) bestHit.get("_id"); - Request explanationRequest = new Request("GET", "/" + index + "/" + type + "/" + id + "/_explain"); - explanationRequest.setJsonEntity("{ \"query\": { \"match_all\" : {} }}"); - - RequestOptions.Builder explanationOptions = RequestOptions.DEFAULT.toBuilder(); - explanationOptions.setWarningsHandler(TypesRemovalWarningsHandler.INSTANCE); - explanationRequest.setOptions(explanationOptions); - - String explanation = toStr(client().performRequest(explanationRequest)); + Request explainRequest = new Request("GET", "/" + index + "/" + type + "/" + id + "/_explain"); + explainRequest.setJsonEntity("{ \"query\": { \"match_all\" : {} }}"); + explainRequest.setOptions(expectWarnings(RestExplainAction.TYPES_DEPRECATION_MESSAGE)); + String explanation = toStr(client().performRequest(explainRequest)); assertFalse("Could not find payload boost in explanation\n" + explanation, explanation.contains("payloadBoost")); // Make sure the query can run on the whole index Request searchRequest = new Request("GET", "/" + index + "/_search"); - searchRequest.setEntity(explanationRequest.getEntity()); + searchRequest.setEntity(explainRequest.getEntity()); searchRequest.addParameter("explain", "true"); Map matchAllResponse = entityAsMap(client().performRequest(searchRequest)); assertNoFailures(matchAllResponse); @@ -628,11 +623,13 @@ void assertRealtimeGetWorks() throws IOException { Map hit = (Map) ((List)(XContentMapValues.extractValue("hits.hits", searchResponse))).get(0); String docId = (String) hit.get("_id"); - Request updateRequest = new Request("POST", "/" + index + "/_doc/" + docId + "/_update"); + Request updateRequest = new Request("POST", "/" + index + "/doc/" + docId + "/_update"); updateRequest.setJsonEntity("{ \"doc\" : { \"foo\": \"bar\"}}"); client().performRequest(updateRequest); - Map getRsp = entityAsMap(client().performRequest(new Request("GET", "/" + index + "/_doc/" + docId))); + Request getRequest = new Request("GET", "/" + index + "/doc/" + docId); + getRequest.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); + Map getRsp = entityAsMap(client().performRequest(getRequest)); Map source = (Map) getRsp.get("_source"); assertTrue("doc does not contain 'foo' key: " + source, source.containsKey("foo")); @@ -685,7 +682,7 @@ int extractTotalHits(Map response) { * Tests that a single document survives. Super basic smoke test. */ public void testSingleDoc() throws IOException { - String docLocation = "/" + index + "/_doc/1"; + String docLocation = "/" + index + "/doc/1"; String doc = "{\"test\": \"test\"}"; if (isRunningAgainstOldCluster()) { @@ -694,7 +691,10 @@ public void testSingleDoc() throws IOException { client().performRequest(createDoc); } - assertThat(toStr(client().performRequest(new Request("GET", docLocation))), containsString(doc)); + + Request request = new Request("GET", docLocation); + request.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); + assertThat(toStr(client().performRequest(request)), containsString(doc)); } /** @@ -872,7 +872,7 @@ public void testSnapshotRestore() throws IOException { } templateBuilder.endObject(); templateBuilder.startObject("mappings"); { - templateBuilder.startObject("_doc"); { + templateBuilder.startObject("doc"); { templateBuilder.startObject("_source"); { templateBuilder.field("enabled", true); } @@ -982,7 +982,7 @@ public void testSoftDeletes() throws Exception { int numDocs = between(10, 100); for (int i = 0; i < numDocs; i++) { String doc = Strings.toString(JsonXContent.contentBuilder().startObject().field("field", "v1").endObject()); - Request request = new Request("POST", "/" + index + "/_doc/" + i); + Request request = new Request("POST", "/" + index + "/doc/" + i); request.setJsonEntity(doc); client().performRequest(request); if (rarely()) { @@ -995,11 +995,11 @@ public void testSoftDeletes() throws Exception { for (int i = 0; i < numDocs; i++) { if (randomBoolean()) { String doc = Strings.toString(JsonXContent.contentBuilder().startObject().field("field", "v2").endObject()); - Request request = new Request("POST", "/" + index + "/_doc/" + i); + Request request = new Request("POST", "/" + index + "/doc/" + i); request.setJsonEntity(doc); client().performRequest(request); } else if (randomBoolean()) { - client().performRequest(new Request("DELETE", "/" + index + "/_doc/" + i)); + client().performRequest(new Request("DELETE", "/" + index + "/doc/" + i)); liveDocs--; } } @@ -1065,7 +1065,7 @@ private void checkSnapshot(String snapshotName, int count, Version tookOnVersion bulk.append("{\"index\":{\"_id\":\"").append(count + i).append("\"}}\n"); bulk.append("{\"test\":\"test\"}\n"); } - Request writeToRestoredRequest = new Request("POST", "/restored_" + index + "/_doc/_bulk"); + Request writeToRestoredRequest = new Request("POST", "/restored_" + index + "/doc/_bulk"); writeToRestoredRequest.addParameter("refresh", "true"); writeToRestoredRequest.setJsonEntity(bulk.toString()); assertThat(EntityUtils.toString(client().performRequest(writeToRestoredRequest).getEntity()), containsString("\"errors\":false")); @@ -1097,7 +1097,7 @@ private void checkSnapshot(String snapshotName, int count, Version tookOnVersion expectedTemplate.put("index_patterns", singletonList("evil_*")); } expectedTemplate.put("settings", singletonMap("index", singletonMap("number_of_shards", "1"))); - expectedTemplate.put("mappings", singletonMap("_doc", singletonMap("_source", singletonMap("enabled", true)))); + expectedTemplate.put("mappings", singletonMap("doc", singletonMap("_source", singletonMap("enabled", true)))); expectedTemplate.put("order", 0); Map aliases = new HashMap<>(); aliases.put("alias1", emptyMap()); @@ -1118,7 +1118,7 @@ private void indexRandomDocuments(int count, boolean flushAllowed, boolean saveI logger.info("Indexing {} random documents", count); for (int i = 0; i < count; i++) { logger.debug("Indexing document [{}]", i); - Request createDocument = new Request("POST", "/" + index + "/_doc/" + i); + Request createDocument = new Request("POST", "/" + index + "/doc/" + i); createDocument.setJsonEntity(Strings.toString(docSupplier.apply(i))); client().performRequest(createDocument); if (rarely()) { @@ -1143,15 +1143,16 @@ private void saveInfoDocument(String type, String value) throws IOException { infoDoc.field("value", value); infoDoc.endObject(); // Only create the first version so we know how many documents are created when the index is first created - Request request = new Request("PUT", "/info/_doc/" + index + "_" + type); + Request request = new Request("PUT", "/info/doc/" + index + "_" + type); request.addParameter("op_type", "create"); request.setJsonEntity(Strings.toString(infoDoc)); client().performRequest(request); } private String loadInfoDocument(String type) throws IOException { - Request request = new Request("GET", "/info/_doc/" + index + "_" + type); + Request request = new Request("GET", "/info/doc/" + index + "_" + type); request.addParameter("filter_path", "_source"); + request.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); String doc = toStr(client().performRequest(request)); Matcher m = Pattern.compile("\"value\":\"(.+)\"").matcher(doc); assertTrue(doc, m.find()); diff --git a/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/IndexingIT.java b/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/IndexingIT.java index 380235b5476fb..9da2dafc40b81 100644 --- a/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/IndexingIT.java +++ b/qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/IndexingIT.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.index.seqno.SeqNoStats; +import org.elasticsearch.rest.action.document.RestGetAction; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.yaml.ObjectPath; @@ -45,7 +46,7 @@ public class IndexingIT extends ESRestTestCase { private int indexDocs(String index, final int idStart, final int numDocs) throws IOException { for (int i = 0; i < numDocs; i++) { final int id = idStart + i; - Request request = new Request("PUT", index + "/_doc/" + id); + Request request = new Request("PUT", index + "/doc/" + id); request.setJsonEntity("{\"test\": \"test_" + randomAlphaOfLength(2) + "\"}"); assertOK(client().performRequest(request)); } @@ -284,8 +285,10 @@ private void assertCount(final String index, final String preference, final int } private void assertVersion(final String index, final int docId, final String preference, final int expectedVersion) throws IOException { - Request request = new Request("GET", index + "/_doc/" + docId); + Request request = new Request("GET", index + "/doc/" + docId); request.addParameter("preference", preference); + request.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); + final Response response = client().performRequest(request); assertOK(response); final int actualVersion = Integer.parseInt(ObjectPath.createFromResponse(response).evaluate("_version").toString()); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java index bbf4d5b860112..57c7a99f65196 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java @@ -46,7 +46,7 @@ public class RestGetAction extends BaseRestHandler { private static final DeprecationLogger deprecationLogger = new DeprecationLogger( LogManager.getLogger(RestGetAction.class)); - static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in " + + public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in " + "document get requests is deprecated, use the /{index}/_doc/{id} endpoint instead."; public RestGetAction(final Settings settings, final RestController controller) { diff --git a/server/src/main/java/org/elasticsearch/rest/action/search/RestExplainAction.java b/server/src/main/java/org/elasticsearch/rest/action/search/RestExplainAction.java index 6bac017c04c81..d5ff432ebb6f9 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/search/RestExplainAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/search/RestExplainAction.java @@ -44,7 +44,7 @@ public class RestExplainAction extends BaseRestHandler { private static final DeprecationLogger deprecationLogger = new DeprecationLogger( LogManager.getLogger(RestExplainAction.class)); - static final String TYPES_DEPRECATION_MESSAGE = "[types removal] " + + public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] " + "Specifying a type in explain requests is deprecated."; public RestExplainAction(Settings settings, RestController controller) { diff --git a/server/src/test/java/org/elasticsearch/index/mapper/TypeFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/TypeFieldTypeTests.java index 63c3e2c71c047..2ff106f855806 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/TypeFieldTypeTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/TypeFieldTypeTests.java @@ -83,7 +83,6 @@ public void testTermsQuery() throws Exception { assertEquals(new MatchNoDocsQuery(), query); } - static DirectoryReader openReaderWithNewType(String type, IndexWriter writer) throws IOException { Document doc = new Document(); StringField typeField = new StringField(TypeFieldMapper.NAME, type, Store.NO); diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java index 94f5091fee4ed..02918ea78714e 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java @@ -245,7 +245,18 @@ public static RequestOptions expectVersionSpecificWarnings(Consumer consumer.current(warnings)); + } /** * Construct an HttpHost from the given host and port diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/TypesRemovalWarningsHandler.java b/test/framework/src/main/java/org/elasticsearch/test/rest/TypesRemovalWarningsHandler.java deleted file mode 100644 index c4d0a7911b45c..0000000000000 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/TypesRemovalWarningsHandler.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.test.rest; - -import org.elasticsearch.client.WarningsHandler; - -import java.util.List; - -/** - * An implementation of {@link WarningsHandler} that ignores warnings related to types removal, - * but fails the request on all other warnings. - */ -public class TypesRemovalWarningsHandler implements WarningsHandler { - - public static final TypesRemovalWarningsHandler INSTANCE = new TypesRemovalWarningsHandler(); - - private TypesRemovalWarningsHandler() { - // Prevent instantiation. - } - - @Override - public boolean warningsShouldFailRequest(List warnings) { - for (String warning : warnings) { - if (warning.startsWith("[types removal]") == false) { - return true; - } - } - return false; - } -} diff --git a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java index 4bbb667fd7257..595edb76b7cb0 100644 --- a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java +++ b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java @@ -12,15 +12,16 @@ import org.elasticsearch.client.ResponseException; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.common.xcontent.ObjectPath; import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.rest.RestStatus; +import org.elasticsearch.rest.action.document.RestGetAction; import org.elasticsearch.rest.action.search.RestSearchAction; import org.elasticsearch.test.StreamsUtils; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.upgrades.AbstractFullClusterRestartTestCase; import org.elasticsearch.xpack.core.watcher.client.WatchSourceBuilder; -import org.elasticsearch.common.xcontent.ObjectPath; import org.elasticsearch.xpack.security.support.SecurityIndexManager; import org.elasticsearch.xpack.test.rest.XPackRestTestHelper; import org.elasticsearch.xpack.watcher.actions.logging.LoggingAction; @@ -80,7 +81,7 @@ protected Settings restClientSettings() { * Tests that a single document survives. Super basic smoke test. */ public void testSingleDoc() throws IOException { - String docLocation = "/testsingledoc/_doc/1"; + String docLocation = "/testsingledoc/doc/1"; String doc = "{\"test\": \"test\"}"; if (isRunningAgainstOldCluster()) { @@ -90,7 +91,9 @@ public void testSingleDoc() throws IOException { client().performRequest(createDoc); } - assertThat(toStr(client().performRequest(new Request("GET", docLocation))), containsString(doc)); + Request getRequest = new Request("GET", docLocation); + getRequest.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); + assertThat(toStr(client().performRequest(getRequest)), containsString(doc)); } @SuppressWarnings("unchecked") @@ -248,7 +251,7 @@ public void testRollupAfterRestart() throws Exception { // index documents for the rollup job final StringBuilder bulk = new StringBuilder(); for (int i = 0; i < numDocs; i++) { - bulk.append("{\"index\":{\"_index\":\"rollup-docs\",\"_type\":\"_doc\"}}\n"); + bulk.append("{\"index\":{\"_index\":\"rollup-docs\",\"_type\":\"doc\"}}\n"); String date = String.format(Locale.ROOT, "%04d-01-01T00:%02d:00Z", year, i); bulk.append("{\"timestamp\":\"").append(date).append("\",\"value\":").append(i).append("}\n"); } @@ -306,7 +309,7 @@ public void testRollupIDSchemeAfterRestart() throws Exception { assumeTrue("Rollup ID scheme changed in 6.4", getOldClusterVersion().before(Version.V_6_4_0)); if (isRunningAgainstOldCluster()) { - final Request indexRequest = new Request("POST", "/id-test-rollup/_doc/1"); + final Request indexRequest = new Request("POST", "/id-test-rollup/doc/1"); indexRequest.setJsonEntity("{\"timestamp\":\"2018-01-01T00:00:01\",\"value\":123}"); client().performRequest(indexRequest); @@ -367,7 +370,7 @@ public void testRollupIDSchemeAfterRestart() throws Exception { } else { - final Request indexRequest = new Request("POST", "/id-test-rollup/_doc/2"); + final Request indexRequest = new Request("POST", "/id-test-rollup/doc/2"); indexRequest.setJsonEntity("{\"timestamp\":\"2018-01-02T00:00:01\",\"value\":345}"); client().performRequest(indexRequest); diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java index d959cf2daaee7..1f0b8cffe20b0 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java @@ -15,6 +15,7 @@ import org.elasticsearch.client.RestClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.rest.action.document.RestGetAction; import org.elasticsearch.test.rest.yaml.ObjectPath; import java.io.IOException; @@ -63,7 +64,7 @@ public void testGeneratingTokenInOldCluster() throws Exception { assertNotNull(token); assertTokenWorks(token); - Request indexRequest1 = new Request("PUT", "token_backwards_compatibility_it/_doc/old_cluster_token1"); + Request indexRequest1 = new Request("PUT", "token_backwards_compatibility_it/doc/old_cluster_token1"); indexRequest1.setJsonEntity( "{\n" + " \"token\": \"" + token + "\"\n" + @@ -77,7 +78,7 @@ public void testGeneratingTokenInOldCluster() throws Exception { token = (String) responseMap.get("access_token"); assertNotNull(token); assertTokenWorks(token); - Request indexRequest2 = new Request("PUT", "token_backwards_compatibility_it/_doc/old_cluster_token2"); + Request indexRequest2 = new Request("PUT", "token_backwards_compatibility_it/doc/old_cluster_token2"); indexRequest2.setJsonEntity( "{\n" + " \"token\": \"" + token + "\"\n" + @@ -88,7 +89,9 @@ public void testGeneratingTokenInOldCluster() throws Exception { public void testTokenWorksInMixedOrUpgradedCluster() throws Exception { assumeTrue("this test should only run against the mixed or upgraded cluster", CLUSTER_TYPE == ClusterType.MIXED || CLUSTER_TYPE == ClusterType.UPGRADED); - Response getResponse = client().performRequest(new Request("GET", "token_backwards_compatibility_it/_doc/old_cluster_token1")); + Request getRequest = new Request("GET", "token_backwards_compatibility_it/doc/old_cluster_token1"); + getRequest.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); + Response getResponse = client().performRequest(getRequest); assertOK(getResponse); Map source = (Map) entityAsMap(getResponse).get("_source"); assertTokenWorks((String) source.get("token")); @@ -97,7 +100,10 @@ public void testTokenWorksInMixedOrUpgradedCluster() throws Exception { public void testMixedCluster() throws Exception { assumeTrue("this test should only run against the mixed cluster", CLUSTER_TYPE == ClusterType.MIXED); assumeTrue("the master must be on the latest version before we can write", isMasterOnLatestVersion()); - Response getResponse = client().performRequest(new Request("GET", "token_backwards_compatibility_it/_doc/old_cluster_token2")); + Request getRequest = new Request("GET", "token_backwards_compatibility_it/doc/old_cluster_token2"); + getRequest.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); + + Response getResponse = client().performRequest(getRequest); Map source = (Map) entityAsMap(getResponse).get("_source"); final String token = (String) source.get("token"); assertTokenWorks(token); @@ -146,7 +152,10 @@ public void testMixedCluster() throws Exception { public void testUpgradedCluster() throws Exception { assumeTrue("this test should only run against the mixed cluster", CLUSTER_TYPE == ClusterType.UPGRADED); - Response getResponse = client().performRequest(new Request("GET", "token_backwards_compatibility_it/_doc/old_cluster_token2")); + Request getRequest = new Request("GET", "token_backwards_compatibility_it/doc/old_cluster_token2"); + getRequest.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); + + Response getResponse = client().performRequest(getRequest); assertOK(getResponse); Map source = (Map) entityAsMap(getResponse).get("_source"); final String token = (String) source.get("token"); @@ -159,7 +168,10 @@ public void testUpgradedCluster() throws Exception { assertOK(invalidationResponse); assertTokenDoesNotWork(token); - getResponse = client().performRequest(new Request("GET", "token_backwards_compatibility_it/_doc/old_cluster_token1")); + getRequest = new Request("GET", "token_backwards_compatibility_it/doc/old_cluster_token1"); + getRequest.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); + + getResponse = client().performRequest(getRequest); source = (Map) entityAsMap(getResponse).get("_source"); final String workingToken = (String) source.get("token"); assertTokenWorks(workingToken);