From e0b68ecdc8b94ef830ac35b613daa497554decd7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 31 Jan 2024 16:01:09 +0000 Subject: [PATCH] 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 * Empty Commit to retry the build Signed-off-by: bansvaru --------- Signed-off-by: bansvaru (cherry picked from commit bf5e628d82adf038f618d894a309d8dd57655fcd) Signed-off-by: github-actions[bot] --- .../RemoteStoreClusterStateRestoreIT.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreClusterStateRestoreIT.java b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreClusterStateRestoreIT.java index c61e2ec6e4f6c..3f90732f1f13d 100644 --- a/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreClusterStateRestoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/remotestore/RemoteStoreClusterStateRestoreIT.java @@ -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());