Skip to content

Commit

Permalink
Enable DeprecationHttpIT and resetFeatures in MlDeprecationIT (#79071)
Browse files Browse the repository at this point in the history
closes #79038
  • Loading branch information
pgomulka authored Oct 14, 2021
1 parent c375013 commit 737704e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
/**
* Tests that deprecation message are returned via response headers, and can be indexed into a data stream.
*/
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/79038")
public class DeprecationHttpIT extends ESRestTestCase {

/**
Expand Down Expand Up @@ -90,12 +89,22 @@ public void assertIndexingIsEnabled() throws Exception {
}
List<Map<String, Object>> documents = getIndexedDeprecations();
logger.warn(documents);
// if data stream is still present, that means that previous test (could be different class) created a deprecation
// hence resetting again
resetDeprecationIndexAndCache();
fail("Index should be removed on startup");
}, 30, TimeUnit.SECONDS);
}

@After
public void cleanUp() throws Exception {
resetDeprecationIndexAndCache();

// switch logging setting to default
configureWriteDeprecationLogsToIndex(null);
}

private void resetDeprecationIndexAndCache() throws Exception {
// making sure the deprecation indexing cache is reset and index is deleted
assertBusy(() -> {
try {
Expand All @@ -106,9 +115,6 @@ public void cleanUp() throws Exception {
}

}, 30, TimeUnit.SECONDS);

// switch logging setting to default
configureWriteDeprecationLogsToIndex(null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.WarningsHandler;
Expand All @@ -25,7 +27,9 @@
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.xcontent.NamedXContentRegistry;
import org.elasticsearch.xcontent.XContentType;
import org.junit.After;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Map;
Expand All @@ -46,6 +50,12 @@ private static class HLRC extends RestHighLevelClient {
}
}

@After
public void resetFeatures() throws IOException {
Response response = adminClient().performRequest(new Request("POST", "/_features/_reset"));
assertOK(response);
}

@Override
protected NamedXContentRegistry xContentRegistry() {
SearchModule searchModule = new SearchModule(Settings.EMPTY, Collections.emptyList());
Expand Down Expand Up @@ -97,7 +107,6 @@ public void testMlDeprecationChecks() throws Exception {
containsString("model snapshot [1] for job [deprecation_check_job] needs to be deleted or upgraded")
);
assertThat(response.getMlSettingsIssues().get(0).getMeta(), equalTo(Map.of("job_id", jobId, "snapshot_id", "1")));
hlrc.close();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.elasticsearch.xpack.core.ClientHelper;

import java.util.Arrays;
import java.util.Map;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -139,9 +139,10 @@ public void afterBulk(long executionId, BulkRequest request, BulkResponse respon
}

if (response.hasFailures()) {
Map<String, String> failures = Arrays.stream(response.getItems())
List<String> failures = Arrays.stream(response.getItems())
.filter(BulkItemResponse::isFailed)
.collect(Collectors.toMap(BulkItemResponse::getId, BulkItemResponse::getFailureMessage));
.map(r -> r.getId() + " " + r.getFailureMessage() )
.collect(Collectors.toList());
logger.error("Bulk write of deprecation logs encountered some failures: [{}]", failures);
}
}
Expand Down

0 comments on commit 737704e

Please sign in to comment.