Skip to content

Commit 7c2b737

Browse files
committed
Add debug log for CcrRetentionLeaseIT (#48820)
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
1 parent 0302f6e commit 7c2b737

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrRetentionLeaseIT.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.elasticsearch.plugins.Plugin;
4444
import org.elasticsearch.snapshots.RestoreInfo;
4545
import org.elasticsearch.snapshots.RestoreService;
46+
import org.elasticsearch.test.junit.annotations.TestIssueLogging;
4647
import org.elasticsearch.test.transport.MockTransportService;
4748
import org.elasticsearch.transport.ConnectTransportException;
4849
import org.elasticsearch.transport.RemoteTransportException;
@@ -86,6 +87,9 @@
8687
import static org.hamcrest.Matchers.greaterThan;
8788
import static org.hamcrest.Matchers.hasSize;
8889

90+
@TestIssueLogging(
91+
value = "org.elasticsearch.xpack.ccr:trace,org.elasticsearch.indices.recovery:trace,org.elasticsearch.index.seqno:debug",
92+
issueUrl = "https://github.com/elastic/elasticsearch/issues/45192")
8993
public class CcrRetentionLeaseIT extends CcrIntegTestCase {
9094

9195
public static final class RetentionLeaseRenewIntervalSettingPlugin extends Plugin {
@@ -779,6 +783,9 @@ public void testRetentionLeaseIsAddedIfItDisappearsWhileFollowing() throws Excep
779783
|| TransportActionProxy.getProxyAction(RetentionLeaseActions.Renew.ACTION_NAME).equals(action)) {
780784
senderTransportService.clearAllRules();
781785
final RetentionLeaseActions.RenewRequest renewRequest = (RetentionLeaseActions.RenewRequest) request;
786+
final String retentionLeaseId = getRetentionLeaseId(followerIndex, leaderIndex);
787+
assertThat(retentionLeaseId, equalTo(renewRequest.getId()));
788+
logger.info("--> intercepting renewal request for retention lease [{}]", retentionLeaseId);
782789
final String primaryShardNodeId =
783790
getLeaderCluster()
784791
.clusterService()
@@ -796,17 +803,17 @@ public void testRetentionLeaseIsAddedIfItDisappearsWhileFollowing() throws Excep
796803
.getShardOrNull(renewRequest.getShardId());
797804
final CountDownLatch innerLatch = new CountDownLatch(1);
798805
// this forces the background renewal from following to face a retention lease not found exception
799-
primary.removeRetentionLease(
800-
getRetentionLeaseId(followerIndex, leaderIndex),
806+
logger.info("--> removing retention lease [{}] on the leader", retentionLeaseId);
807+
primary.removeRetentionLease(retentionLeaseId,
801808
ActionListener.wrap(r -> innerLatch.countDown(), e -> fail(e.toString())));
802-
809+
logger.info("--> waiting for the removed retention lease [{}] to be synced on the leader", retentionLeaseId);
803810
try {
804811
innerLatch.await();
805812
} catch (final InterruptedException e) {
806813
Thread.currentThread().interrupt();
807814
fail(e.toString());
808815
}
809-
816+
logger.info("--> removed retention lease [{}] on the leader", retentionLeaseId);
810817
latch.countDown();
811818
}
812819
connection.sendRequest(requestId, action, request, options);
@@ -877,6 +884,7 @@ public void testPeriodicRenewalDoesNotAddRetentionLeaseAfterUnfollow() throws Ex
877884
if (RetentionLeaseActions.Renew.ACTION_NAME.equals(action)
878885
|| TransportActionProxy.getProxyAction(RetentionLeaseActions.Renew.ACTION_NAME).equals(action)) {
879886
final String retentionLeaseId = getRetentionLeaseId(followerIndex, leaderIndex);
887+
logger.info("--> blocking renewal request for retention lease [{}] until unfollowed", retentionLeaseId);
880888
try {
881889
removeLeaseLatch.countDown();
882890
unfollowLatch.await();

0 commit comments

Comments
 (0)