|  | 
| 21 | 21 | import org.elasticsearch.client.RestClientBuilder; | 
| 22 | 22 | import org.elasticsearch.common.Strings; | 
| 23 | 23 | import org.elasticsearch.common.logging.HeaderWarning; | 
| 24 |  | -import org.elasticsearch.common.logging.LoggerMessageFormat; | 
| 25 | 24 | import org.elasticsearch.common.settings.Setting; | 
| 26 | 25 | import org.elasticsearch.common.settings.Settings; | 
| 27 | 26 | import org.elasticsearch.core.RestApiVersion; | 
|  | 
| 55 | 54 | import static org.elasticsearch.xpack.deprecation.DeprecationSettings.TEST_NOT_DEPRECATED_SETTING; | 
| 56 | 55 | import static org.hamcrest.Matchers.allOf; | 
| 57 | 56 | import static org.hamcrest.Matchers.containsInAnyOrder; | 
| 58 |  | -import static org.hamcrest.Matchers.containsString; | 
| 59 | 57 | import static org.hamcrest.Matchers.equalTo; | 
| 60 | 58 | import static org.hamcrest.Matchers.everyItem; | 
| 61 | 59 | import static org.hamcrest.Matchers.hasEntry; | 
| @@ -176,46 +174,6 @@ private Response cleanupSettings() throws IOException { | 
| 176 | 174 |         return performScopedRequest(request, xOpaqueId() + "-cleanup"); | 
| 177 | 175 |     } | 
| 178 | 176 | 
 | 
| 179 |  | -    /** | 
| 180 |  | -     * Attempts to do a scatter/gather request that expects unique responses per sub-request. | 
| 181 |  | -     */ | 
| 182 |  | -    public void testUniqueDeprecationResponsesMergedTogether() throws IOException { | 
| 183 |  | -        final String[] indices = new String[randomIntBetween(2, 5)]; | 
| 184 |  | - | 
| 185 |  | -        // add at least one document for each index | 
| 186 |  | -        for (int i = 0; i < indices.length; ++i) { | 
| 187 |  | -            indices[i] = "test" + i; | 
| 188 |  | - | 
| 189 |  | -            // create indices with a single shard to reduce noise; the query only deprecates uniquely by index anyway | 
| 190 |  | -            createIndex(indices[i], Settings.builder().put("number_of_shards", 1).build()); | 
| 191 |  | - | 
| 192 |  | -            int randomDocCount = randomIntBetween(1, 2); | 
| 193 |  | - | 
| 194 |  | -            for (int j = 0; j < randomDocCount; j++) { | 
| 195 |  | -                final Request request = new Request("PUT", indices[i] + "/" + j); | 
| 196 |  | -                request.setJsonEntity("{ \"field\": " + j + " }"); | 
| 197 |  | -                performScopedRequest(request); | 
| 198 |  | -            } | 
| 199 |  | -        } | 
| 200 |  | - | 
| 201 |  | -        final String commaSeparatedIndices = String.join(",", indices); | 
| 202 |  | - | 
| 203 |  | -        performScopedRequest(new Request("POST", commaSeparatedIndices + "/_refresh")); | 
| 204 |  | -        // trigger all index deprecations | 
| 205 |  | -        Request request = new Request("GET", "/" + commaSeparatedIndices + "/_search"); | 
| 206 |  | -        request.setJsonEntity("{ \"query\": { \"bool\": { \"filter\": [ { \"deprecated\": {} } ] } } }"); | 
| 207 |  | -        Response response = performScopedRequest(request); | 
| 208 |  | - | 
| 209 |  | -        final List<String> deprecatedWarnings = getWarningHeaders(response.getHeaders()); | 
| 210 |  | -        final List<Matcher<? super String>> headerMatchers = new ArrayList<>(); | 
| 211 |  | - | 
| 212 |  | -        for (String index : indices) { | 
| 213 |  | -            headerMatchers.add(containsString(LoggerMessageFormat.format("[{}] index", (Object) index))); | 
| 214 |  | -        } | 
| 215 |  | - | 
| 216 |  | -        assertThat(deprecatedWarnings, containsInAnyOrder(headerMatchers)); | 
| 217 |  | -    } | 
| 218 |  | - | 
| 219 | 177 |     public void testDeprecationWarningsAppearInHeaders() throws Exception { | 
| 220 | 178 |         doTestDeprecationWarningsAppearInHeaders(xOpaqueId()); | 
| 221 | 179 |     } | 
|  | 
0 commit comments