Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stack traces to RetentionLeasesIT failures #42425

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void testRetentionLeasesSyncedOnAdd() throws Exception {
final long retainingSequenceNumber = randomLongBetween(0, Long.MAX_VALUE);
final String source = randomAlphaOfLength(8);
final CountDownLatch latch = new CountDownLatch(1);
final ActionListener<ReplicationResponse> listener = ActionListener.wrap(r -> latch.countDown(), e -> fail(e.toString()));
final ActionListener<ReplicationResponse> listener = countDownLatchListener(latch);
// simulate a peer recovery which locks the soft deletes policy on the primary
final Closeable retentionLock = randomBoolean() ? primary.acquireRetentionLock() : () -> {};
currentRetentionLeases.put(id, primary.addRetentionLease(id, retainingSequenceNumber, source, listener));
Expand Down Expand Up @@ -155,7 +155,7 @@ public void testRetentionLeaseSyncedOnRemove() throws Exception {
final long retainingSequenceNumber = randomLongBetween(0, Long.MAX_VALUE);
final String source = randomAlphaOfLength(8);
final CountDownLatch latch = new CountDownLatch(1);
final ActionListener<ReplicationResponse> listener = ActionListener.wrap(r -> latch.countDown(), e -> fail(e.toString()));
final ActionListener<ReplicationResponse> listener = countDownLatchListener(latch);
// simulate a peer recovery which locks the soft deletes policy on the primary
final Closeable retentionLock = randomBoolean() ? primary.acquireRetentionLock() : () -> {};
currentRetentionLeases.put(id, primary.addRetentionLease(id, retainingSequenceNumber, source, listener));
Expand All @@ -166,7 +166,7 @@ public void testRetentionLeaseSyncedOnRemove() throws Exception {
for (int i = 0; i < length; i++) {
final String id = randomFrom(currentRetentionLeases.keySet());
final CountDownLatch latch = new CountDownLatch(1);
primary.removeRetentionLease(id, ActionListener.wrap(r -> latch.countDown(), e -> fail(e.toString())));
primary.removeRetentionLease(id, countDownLatchListener(latch));
// simulate a peer recovery which locks the soft deletes policy on the primary
final Closeable retentionLock = randomBoolean() ? primary.acquireRetentionLock() : () -> {};
currentRetentionLeases.remove(id);
Expand Down Expand Up @@ -228,7 +228,7 @@ public void testRetentionLeasesSyncOnExpiration() throws Exception {
final long retainingSequenceNumber = randomLongBetween(0, Long.MAX_VALUE);
final String source = randomAlphaOfLength(8);
final CountDownLatch latch = new CountDownLatch(1);
final ActionListener<ReplicationResponse> listener = ActionListener.wrap(r -> latch.countDown(), e -> fail(e.toString()));
final ActionListener<ReplicationResponse> listener = countDownLatchListener(latch);
final RetentionLease currentRetentionLease = primary.addRetentionLease(id, retainingSequenceNumber, source, listener);
final long now = System.nanoTime();
latch.await();
Expand Down Expand Up @@ -390,7 +390,7 @@ public void testRetentionLeasesSyncOnRecovery() throws Exception {
final long retainingSequenceNumber = randomLongBetween(0, Long.MAX_VALUE);
final String source = randomAlphaOfLength(8);
final CountDownLatch latch = new CountDownLatch(1);
final ActionListener<ReplicationResponse> listener = ActionListener.wrap(r -> latch.countDown(), e -> fail(e.toString()));
final ActionListener<ReplicationResponse> listener = countDownLatchListener(latch);
currentRetentionLeases.put(id, primary.addRetentionLease(id, retainingSequenceNumber, source, listener));
latch.await();
currentRetentionLeases.put(id, primary.renewRetentionLease(id, retainingSequenceNumber, source));
Expand Down Expand Up @@ -479,7 +479,7 @@ public void testCanRenewRetentionLeaseUnderBlock() throws InterruptedException {
*/
assertBusy(() -> assertThat(primary.loadRetentionLeases().leases(), contains(retentionLease.get())));
} catch (final Exception e) {
fail(e.toString());
failWithException(e);
}
});

Expand Down Expand Up @@ -516,7 +516,7 @@ private void runUnderBlockTest(

final String source = randomAlphaOfLength(8);
final CountDownLatch latch = new CountDownLatch(1);
final ActionListener<ReplicationResponse> listener = ActionListener.wrap(r -> latch.countDown(), e -> fail(e.toString()));
final ActionListener<ReplicationResponse> listener = countDownLatchListener(latch);
primary.addRetentionLease(idForInitialRetentionLease, initialRetainingSequenceNumber, source, listener);
latch.await();

Expand Down Expand Up @@ -545,7 +545,7 @@ public void onResponse(final ReplicationResponse replicationResponse) {

@Override
public void onFailure(final Exception e) {
fail(e.toString());
failWithException(e);
}

});
Expand Down Expand Up @@ -598,7 +598,7 @@ public void testCanRenewRetentionLeaseWithoutWaitingForShards() throws Interrupt
*/
assertBusy(() -> assertThat(primary.loadRetentionLeases().leases(), contains(retentionLease.get())));
} catch (final Exception e) {
fail(e.toString());
failWithException(e);
}
});

Expand Down Expand Up @@ -637,7 +637,7 @@ private void runWaitForShardsTest(

final String source = randomAlphaOfLength(8);
final CountDownLatch latch = new CountDownLatch(1);
final ActionListener<ReplicationResponse> listener = ActionListener.wrap(r -> latch.countDown(), e -> fail(e.toString()));
final ActionListener<ReplicationResponse> listener = countDownLatchListener(latch);
primary.addRetentionLease(idForInitialRetentionLease, initialRetainingSequenceNumber, source, listener);
latch.await();

Expand Down Expand Up @@ -665,7 +665,7 @@ public void onResponse(final ReplicationResponse replicationResponse) {

@Override
public void onFailure(final Exception e) {
fail(e.toString());
failWithException(e);
}

});
Expand All @@ -674,4 +674,12 @@ public void onFailure(final Exception e) {
afterSync.accept(primary);
}

private static void failWithException(Exception e) {
throw new AssertionError("unexpected", e);
}

private static ActionListener<ReplicationResponse> countDownLatchListener(CountDownLatch latch) {
return ActionListener.wrap(r -> latch.countDown(), RetentionLeaseIT::failWithException);
}

}