Skip to content

Commit

Permalink
Add debug log for CcrRetentionLeaseIT (#48820)
Browse files Browse the repository at this point in the history
testRetentionLeaseIsAddedIfItDisappearsWhileFollowing is still failing
although we already have several fixes. I think other tests interfere
and cause this test to fail. We can use the test scope to isolate them.
However, I prefer to add debug logs so we can find the source.

Relates #45192
  • Loading branch information
dnhatn committed Nov 2, 2019
1 parent 8792fc3 commit 39b6d2f
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.snapshots.RestoreInfo;
import org.elasticsearch.snapshots.RestoreService;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.transport.ConnectTransportException;
import org.elasticsearch.transport.RemoteTransportException;
Expand Down Expand Up @@ -86,6 +87,9 @@
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.hasSize;

@TestLogging(
// issue: https://github.com/elastic/elasticsearch/issues/45192
value = "org.elasticsearch.xpack.ccr:trace,org.elasticsearch.indices.recovery:trace,org.elasticsearch.index.seqno:debug")
public class CcrRetentionLeaseIT extends CcrIntegTestCase {

public static final class RetentionLeaseRenewIntervalSettingPlugin extends Plugin {
Expand Down Expand Up @@ -780,6 +784,9 @@ public void testRetentionLeaseIsAddedIfItDisappearsWhileFollowing() throws Excep
|| TransportActionProxy.getProxyAction(RetentionLeaseActions.Renew.ACTION_NAME).equals(action)) {
senderTransportService.clearAllRules();
final RetentionLeaseActions.RenewRequest renewRequest = (RetentionLeaseActions.RenewRequest) request;
final String retentionLeaseId = getRetentionLeaseId(followerIndex, leaderIndex);
assertThat(retentionLeaseId, equalTo(renewRequest.getId()));
logger.info("--> intercepting renewal request for retention lease [{}]", retentionLeaseId);
final String primaryShardNodeId =
getLeaderCluster()
.clusterService()
Expand All @@ -797,17 +804,17 @@ public void testRetentionLeaseIsAddedIfItDisappearsWhileFollowing() throws Excep
.getShardOrNull(renewRequest.getShardId());
final CountDownLatch innerLatch = new CountDownLatch(1);
// this forces the background renewal from following to face a retention lease not found exception
primary.removeRetentionLease(
getRetentionLeaseId(followerIndex, leaderIndex),
logger.info("--> removing retention lease [{}] on the leader", retentionLeaseId);
primary.removeRetentionLease(retentionLeaseId,
ActionListener.wrap(r -> innerLatch.countDown(), e -> fail(e.toString())));

logger.info("--> waiting for the removed retention lease [{}] to be synced on the leader", retentionLeaseId);
try {
innerLatch.await();
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
fail(e.toString());
}

logger.info("--> removed retention lease [{}] on the leader", retentionLeaseId);
latch.countDown();
}
connection.sendRequest(requestId, action, request, options);
Expand Down Expand Up @@ -878,6 +885,7 @@ public void testPeriodicRenewalDoesNotAddRetentionLeaseAfterUnfollow() throws Ex
if (RetentionLeaseActions.Renew.ACTION_NAME.equals(action)
|| TransportActionProxy.getProxyAction(RetentionLeaseActions.Renew.ACTION_NAME).equals(action)) {
final String retentionLeaseId = getRetentionLeaseId(followerIndex, leaderIndex);
logger.info("--> blocking renewal request for retention lease [{}] until unfollowed", retentionLeaseId);
try {
removeLeaseLatch.countDown();
unfollowLatch.await();
Expand Down

0 comments on commit 39b6d2f

Please sign in to comment.