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
This commit is contained in:
Nhat Nguyen 2019-11-01 13:58:58 -04:00
parent c24595e2ec
commit 4c70770877
1 changed files with 12 additions and 4 deletions

View File

@ -43,6 +43,7 @@ import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.plugins.Plugin; import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.snapshots.RestoreInfo; import org.elasticsearch.snapshots.RestoreInfo;
import org.elasticsearch.snapshots.RestoreService; import org.elasticsearch.snapshots.RestoreService;
import org.elasticsearch.test.junit.annotations.TestIssueLogging;
import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.test.transport.MockTransportService;
import org.elasticsearch.transport.ConnectTransportException; import org.elasticsearch.transport.ConnectTransportException;
import org.elasticsearch.transport.RemoteTransportException; import org.elasticsearch.transport.RemoteTransportException;
@ -86,6 +87,9 @@ import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.hasSize;
@TestIssueLogging(
value = "org.elasticsearch.xpack.ccr:trace,org.elasticsearch.indices.recovery:trace,org.elasticsearch.index.seqno:debug",
issueUrl = "https://github.com/elastic/elasticsearch/issues/45192")
public class CcrRetentionLeaseIT extends CcrIntegTestCase { public class CcrRetentionLeaseIT extends CcrIntegTestCase {
public static final class RetentionLeaseRenewIntervalSettingPlugin extends Plugin { public static final class RetentionLeaseRenewIntervalSettingPlugin extends Plugin {
@ -779,6 +783,9 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
|| TransportActionProxy.getProxyAction(RetentionLeaseActions.Renew.ACTION_NAME).equals(action)) { || TransportActionProxy.getProxyAction(RetentionLeaseActions.Renew.ACTION_NAME).equals(action)) {
senderTransportService.clearAllRules(); senderTransportService.clearAllRules();
final RetentionLeaseActions.RenewRequest renewRequest = (RetentionLeaseActions.RenewRequest) request; 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 = final String primaryShardNodeId =
getLeaderCluster() getLeaderCluster()
.clusterService() .clusterService()
@ -796,17 +803,17 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
.getShardOrNull(renewRequest.getShardId()); .getShardOrNull(renewRequest.getShardId());
final CountDownLatch innerLatch = new CountDownLatch(1); final CountDownLatch innerLatch = new CountDownLatch(1);
// this forces the background renewal from following to face a retention lease not found exception // this forces the background renewal from following to face a retention lease not found exception
primary.removeRetentionLease( logger.info("--> removing retention lease [{}] on the leader", retentionLeaseId);
getRetentionLeaseId(followerIndex, leaderIndex), primary.removeRetentionLease(retentionLeaseId,
ActionListener.wrap(r -> innerLatch.countDown(), e -> fail(e.toString()))); 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 { try {
innerLatch.await(); innerLatch.await();
} catch (final InterruptedException e) { } catch (final InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
fail(e.toString()); fail(e.toString());
} }
logger.info("--> removed retention lease [{}] on the leader", retentionLeaseId);
latch.countDown(); latch.countDown();
} }
connection.sendRequest(requestId, action, request, options); connection.sendRequest(requestId, action, request, options);
@ -877,6 +884,7 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
if (RetentionLeaseActions.Renew.ACTION_NAME.equals(action) if (RetentionLeaseActions.Renew.ACTION_NAME.equals(action)
|| TransportActionProxy.getProxyAction(RetentionLeaseActions.Renew.ACTION_NAME).equals(action)) { || TransportActionProxy.getProxyAction(RetentionLeaseActions.Renew.ACTION_NAME).equals(action)) {
final String retentionLeaseId = getRetentionLeaseId(followerIndex, leaderIndex); final String retentionLeaseId = getRetentionLeaseId(followerIndex, leaderIndex);
logger.info("--> blocking renewal request for retention lease [{}] until unfollowed", retentionLeaseId);
try { try {
removeLeaseLatch.countDown(); removeLeaseLatch.countDown();
unfollowLatch.await(); unfollowLatch.await();