Skip to content

Commit

Permalink
Unwrap exception more tenaciously in testQueuedOperationsAndBrokenRep…
Browse files Browse the repository at this point in the history
…oOnMasterFailOver (elastic#102352) (elastic#102367)

There can be more than 10 layers of wrapping RTEs, see elastic#102351. As a
workaround to address the test failure, this commit just manually
unwraps them all.

Closes elastic#102348
  • Loading branch information
DaveCTurner authored Nov 20, 2023
1 parent b227427 commit 93013d5
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.disruption.NetworkDisruption;
import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.transport.RemoteTransportException;

import java.io.IOException;
import java.nio.file.Files;
Expand Down Expand Up @@ -768,7 +769,18 @@ public void testQueuedOperationsAndBrokenRepoOnMasterFailOver() throws Exception
ensureStableCluster(3);

awaitNoMoreRunningOperations();
expectThrows(RepositoryException.class, deleteFuture::actionGet);
var innerException = expectThrows(ExecutionException.class, RuntimeException.class, deleteFuture::get);

// There may be many layers of RTE to unwrap here, see https://github.com/elastic/elasticsearch/issues/102351.
// ExceptionsHelper#unwrapCause gives up at 10 layers of wrapping so we must unwrap more tenaciously by hand here:
while (true) {
if (innerException instanceof RemoteTransportException remoteTransportException) {
innerException = asInstanceOf(RuntimeException.class, remoteTransportException.getCause());
} else {
assertThat(innerException, instanceOf(RepositoryException.class));
break;
}
}
}

public void testQueuedSnapshotOperationsAndBrokenRepoOnMasterFailOver() throws Exception {
Expand Down

0 comments on commit 93013d5

Please sign in to comment.