Skip to content

Commit 3ff62da

Browse files
fix flaky test - handle IllegalStateException and throw AssertionError to use assertbusy (opensearch-project#11981) (opensearch-project#12109) (opensearch-project#12282)
* fix flaky test - handle IllegalStateException and throw AssertionError to use assertbusy * Empty Commit to retry the build --------- (cherry picked from commit bf5e628) (cherry picked from commit 2011c13) Signed-off-by: bansvaru <bansvaru@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 684dd74 commit 3ff62da

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreClusterStateRestoreIT.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,16 @@ private void validateCurrentMetadata() throws Exception {
310310
internalCluster().getClusterManagerName()
311311
);
312312
assertBusy(() -> {
313-
ClusterMetadataManifest manifest = remoteClusterStateService.getLatestClusterMetadataManifest(
314-
getClusterState().getClusterName().value(),
315-
getClusterState().metadata().clusterUUID()
316-
).get();
313+
ClusterMetadataManifest manifest;
314+
try {
315+
manifest = remoteClusterStateService.getLatestClusterMetadataManifest(
316+
getClusterState().getClusterName().value(),
317+
getClusterState().metadata().clusterUUID()
318+
).get();
319+
} catch (IllegalStateException e) {
320+
// AssertionError helps us use assertBusy and retry validation if failed due to a race condition.
321+
throw new AssertionError("Error while validating latest cluster metadata", e);
322+
}
317323
ClusterState clusterState = getClusterState();
318324
Metadata currentMetadata = clusterState.metadata();
319325
assertEquals(currentMetadata.indices().size(), manifest.getIndices().size());

0 commit comments

Comments
 (0)