Skip to content

Commit f67ecbf

Browse files
authored
Fix flaky test RemoteClusterStateServiceTests.testReadClusterStateInParallel_ExceptionDuringRead (opensearch-project#19437)
Signed-off-by: Craig Perkins <[email protected]>
1 parent a08700c commit f67ecbf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

server/src/test/java/org/opensearch/gateway/remote/RemoteClusterStateServiceTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,8 +1344,8 @@ public void testReadClusterStateInParallel_ExceptionDuringRead() throws IOExcept
13441344
ClusterState previousClusterState = generateClusterStateWithAllAttributes().build();
13451345
ClusterMetadataManifest manifest = generateClusterMetadataManifestWithAllAttributes().build();
13461346
BlobContainer container = mockBlobStoreObjects();
1347-
Exception mockException = new IOException("mock exception");
1348-
when(container.readBlob(anyString())).thenThrow(mockException);
1347+
String exceptionMsg = "mock exception";
1348+
when(container.readBlob(anyString())).thenAnswer(inv -> { throw new IOException(exceptionMsg); });
13491349
remoteClusterStateService.start();
13501350
RemoteStateTransferException exception = expectThrows(
13511351
RemoteStateTransferException.class,
@@ -1371,7 +1371,7 @@ public void testReadClusterStateInParallel_ExceptionDuringRead() throws IOExcept
13711371
);
13721372
assertEquals("Exception during reading cluster state from remote", exception.getMessage());
13731373
assertTrue(exception.getSuppressed().length > 0);
1374-
assertEquals(mockException, exception.getSuppressed()[0].getCause());
1374+
assertEquals(exceptionMsg, exception.getSuppressed()[0].getCause().getMessage());
13751375
}
13761376

13771377
public void testReadClusterStateInParallel_UnexpectedResult() throws IOException {

0 commit comments

Comments
 (0)