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 (#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]>
(cherry picked from commit bf5e628)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Jan 31, 2024
1 parent de636c1 commit e0b68ec
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 e0b68ec

Please sign in to comment.