Skip to content

Commit

Permalink
Fix flaky testCorruptedTranslog test (#9139)
Browse files Browse the repository at this point in the history
* Fix flaky testCorruptedTranslog test

Signed-off-by: Daniel Widdis <[email protected]>

* Simplify by allowing different wrapped exception

Signed-off-by: Daniel Widdis <[email protected]>

* Remove unnecessary parens: || higher precedence than instanceof

Signed-off-by: Daniel Widdis <[email protected]>

---------

Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis authored Aug 14, 2023
1 parent 301c766 commit f9c728f
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.opensearch.index.IndexSettings;
import org.opensearch.index.MergePolicyConfig;
import org.opensearch.index.engine.EngineConfigFactory;
import org.opensearch.index.engine.EngineCreationFailureException;
import org.opensearch.index.engine.InternalEngineFactory;
import org.opensearch.index.seqno.RetentionLeaseSyncer;
import org.opensearch.index.store.Store;
Expand Down Expand Up @@ -292,7 +293,10 @@ public void testCorruptedTranslog() throws Exception {
allowShardFailures();
// it has to fail on start up due to index.shard.check_on_startup = checksum
final Exception exception = expectThrows(Exception.class, () -> newStartedShard(p -> corruptedShard, true));
final Throwable cause = exception.getCause() instanceof TranslogException ? exception.getCause().getCause() : exception.getCause();
// if corruption is in engine UUID in header, the TranslogCorruptedException is caught and rethrown as
// EngineCreationFailureException rather than TranslogException
final Throwable cause = exception.getCause() instanceof TranslogException
|| exception.getCause() instanceof EngineCreationFailureException ? exception.getCause().getCause() : exception.getCause();
assertThat(cause, instanceOf(TranslogCorruptedException.class));

closeShard(corruptedShard, false); // translog is corrupted already - do not check consistency
Expand Down

0 comments on commit f9c728f

Please sign in to comment.