Skip to content

Commit

Permalink
Improve DeprecationHttpIT robustness (#85235) (#85262)
Browse files Browse the repository at this point in the history
Backports the following commits to 8.1:

Improve DeprecationHttpIT robustness (Improve DeprecationHttpIT robustness #85235)
  • Loading branch information
pgomulka committed Mar 23, 2022
1 parent fff4c22 commit 85435a1
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public void testDeprecationHeadersDoNotGetStuck() throws Exception {
* <p>
* Re-running this back-to-back helps to ensure that warnings are not being maintained across requests.
*/
private void doTestDeprecationWarningsAppearInHeaders() throws IOException {
private void doTestDeprecationWarningsAppearInHeaders() throws Exception {
final boolean useDeprecatedField = randomBoolean();
final boolean useNonDeprecatedSetting = randomBoolean();

Expand All @@ -280,10 +280,8 @@ private void doTestDeprecationWarningsAppearInHeaders() throws IOException {
// trigger all deprecations
Request request = new Request("GET", "/_test_cluster/deprecated_settings");
request.setEntity(buildSettingsRequest(settings, useDeprecatedField ? "deprecated_settings" : "settings"));
final RequestOptions options = request.getOptions()
.toBuilder()
.addHeader("X-Opaque-Id", "XOpaqueId-doTestDeprecationWarningsAppearInHeaders")
.build();
String xOpaqueId = "XOpaqueId-doTestDeprecationWarningsAppearInHeaders" + randomInt();
final RequestOptions options = request.getOptions().toBuilder().addHeader("X-Opaque-Id", xOpaqueId).build();
request.setOptions(options);
Response response = client().performRequest(request);
assertOK(response);
Expand All @@ -306,6 +304,13 @@ private void doTestDeprecationWarningsAppearInHeaders() throws IOException {
for (Matcher<String> headerMatcher : headerMatchers) {
assertThat(actualWarningValues, hasItem(headerMatcher));
}
// expect to index same number of new deprecations as the number of header warnings in the response
assertBusy(() -> {
List<Map<String, Object>> documents = DeprecationTestUtils.getIndexedDeprecations(client());
long indexedDeprecations = documents.stream().filter(m -> xOpaqueId.equals(m.get(X_OPAQUE_ID_FIELD_NAME))).count();
assertThat(documents.toString(), indexedDeprecations, equalTo((long) headerMatchers.size()));
});

}

public void testDeprecationRouteThrottling() throws Exception {
Expand Down

0 comments on commit 85435a1

Please sign in to comment.