Skip to content

Commit bf5e628

Browse files
authored
fix flaky test - handle IllegalStateException and throw AssertionError to use assertbusy (#11981)
* fix flaky test - handle IllegalStateException and throw AssertionError to use assertbusy Signed-off-by: bansvaru <bansvaru@amazon.com> * Empty Commit to retry the build Signed-off-by: bansvaru <bansvaru@amazon.com> --------- Signed-off-by: bansvaru <bansvaru@amazon.com>
1 parent c6cebc7 commit bf5e628

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)