Skip to content

Unblock blocked repositories after test execution #61703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.elasticsearch.Version;
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse;
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchRequest;
Expand Down Expand Up @@ -101,6 +102,24 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
return Arrays.asList(MockRepository.Plugin.class);
}

@After
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of this, but I'm a little suspicious that this is the right place to put this. Many tests don't reuse the test cluster in which case the work here is unnecessary? Maybe we should make this change in the logic that cleans up the test cluster when its reused instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that @After hooks from AbstractSnapshotIntgetTestCase are executed before the hooks in ESIntegTestCase. Is there a way to determine the scope of a cluster? we could bypass this cleanup if the cluster is not reused?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can do a simpler thing and simply skip the repo consistency checks in case of test failure via wrapping in:

if (getSuiteFailureMarker().wasSuccessful()) {

}

That should fix all the cases because I think closing the repos upstream in the EsIntegTestCase cleanup logic should deal with unblocking and removing all the repos cleanly.
That would also make test failures easier to interpret since we get rid of failed repo verifications on failed tests?

public void unblockBlockedRepositories() throws Exception {
List<RepositoryMetadata> repositories = admin().cluster().prepareGetRepositories().get().repositories();
for (RepositoriesService repositoriesService : internalCluster().getDataOrMasterNodeInstances(RepositoriesService.class)) {
for (RepositoryMetadata repository : repositories) {
((MockRepository) repositoriesService.repository(repository.name())).unblock();
}
}

// Wait for all snapshots to complete so cleanup operations can complete
for (RepositoryMetadata repository : repositories) {
GetSnapshotsResponse snapshots = admin().cluster().prepareGetSnapshots(repository.name()).get();
for (SnapshotInfo snapshot : snapshots.getSnapshots(repository.name())) {
waitForCompletion(repository.name(), snapshot.snapshotId().getName(), TimeValue.timeValueSeconds(1));
}
}
}

@After
public void assertConsistentHistoryInLuceneIndex() throws Exception {
internalCluster().assertConsistentHistoryBetweenTranslogAndLuceneIndex();
Expand Down