Skip to content

Commit

Permalink
fix flaky test - handle IllegalStateException and throw AssertionErro…
Browse files Browse the repository at this point in the history
…r to use assertbusy (opensearch-project#11981)

* fix flaky test - handle IllegalStateException and throw AssertionError to use assertbusy

Signed-off-by: bansvaru <[email protected]>

* Empty Commit to retry the build

Signed-off-by: bansvaru <[email protected]>

---------

Signed-off-by: bansvaru <[email protected]>
  • Loading branch information
linuxpi authored Jan 31, 2024
1 parent c6cebc7 commit bf5e628
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,16 @@ private void validateCurrentMetadata() throws Exception {
internalCluster().getClusterManagerName()
);
assertBusy(() -> {
ClusterMetadataManifest manifest = remoteClusterStateService.getLatestClusterMetadataManifest(
getClusterState().getClusterName().value(),
getClusterState().metadata().clusterUUID()
).get();
ClusterMetadataManifest manifest;
try {
manifest = remoteClusterStateService.getLatestClusterMetadataManifest(
getClusterState().getClusterName().value(),
getClusterState().metadata().clusterUUID()
).get();
} catch (IllegalStateException e) {
// AssertionError helps us use assertBusy and retry validation if failed due to a race condition.
throw new AssertionError("Error while validating latest cluster metadata", e);
}
ClusterState clusterState = getClusterState();
Metadata currentMetadata = clusterState.metadata();
assertEquals(currentMetadata.indices().size(), manifest.getIndices().size());
Expand Down

0 comments on commit bf5e628

Please sign in to comment.