Simplify CcrRetentionLeaseIT#testForgetFollower
This test was more complicated than necessary, where we were capturing requests to prevent removal of retention leases, so that our forget follower request could remove the retention leases instead. Instead, a pause is enough to ensure that the retention leases are not re-added after we remove them by the forget follower request. This commit simplifies this test, and should remove some spurious failures. Relates #39850
This commit is contained in:
parent
c23ff0803e
commit
6675bafc49
|
@ -937,30 +937,6 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
|
|||
pauseFollow(followerIndex);
|
||||
followerClient().admin().indices().close(new CloseIndexRequest(followerIndex)).actionGet();
|
||||
|
||||
final ClusterStateResponse followerClusterState = followerClient().admin().cluster().prepareState().clear().setNodes(true).get();
|
||||
try {
|
||||
for (final ObjectCursor<DiscoveryNode> senderNode : followerClusterState.getState().nodes().getNodes().values()) {
|
||||
final MockTransportService senderTransportService =
|
||||
(MockTransportService) getFollowerCluster().getInstance(TransportService.class, senderNode.value.getName());
|
||||
senderTransportService.addSendBehavior(
|
||||
(connection, requestId, action, request, options) -> {
|
||||
if (RetentionLeaseActions.Remove.ACTION_NAME.equals(action)
|
||||
|| TransportActionProxy.getProxyAction(RetentionLeaseActions.Remove.ACTION_NAME).equals(action)) {
|
||||
final RetentionLeaseActions.RemoveRequest removeRequest = (RetentionLeaseActions.RemoveRequest) request;
|
||||
if (randomBoolean()) {
|
||||
throw new ConnectTransportException(connection.getNode(), "connection failed");
|
||||
} else {
|
||||
throw new IndexShardClosedException(removeRequest.getShardId());
|
||||
}
|
||||
}
|
||||
connection.sendRequest(requestId, action, request, options);
|
||||
});
|
||||
}
|
||||
|
||||
expectThrows(
|
||||
ElasticsearchException.class,
|
||||
() -> followerClient().execute(UnfollowAction.INSTANCE, new UnfollowAction.Request(followerIndex)).actionGet());
|
||||
|
||||
final ClusterStateResponse followerIndexClusterState =
|
||||
followerClient().admin().cluster().prepareState().clear().setMetaData(true).setIndices(followerIndex).get();
|
||||
final String followerUUID = followerIndexClusterState.getState().metaData().index(followerIndex).getIndexUUID();
|
||||
|
@ -985,13 +961,6 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
|
|||
for (final ShardStats shardStats : afterForgetFollowerShardsStats) {
|
||||
assertThat(shardStats.getRetentionLeaseStats().retentionLeases().leases(), empty());
|
||||
}
|
||||
} finally {
|
||||
for (final ObjectCursor<DiscoveryNode> senderNode : followerClusterState.getState().nodes().getDataNodes().values()) {
|
||||
final MockTransportService senderTransportService =
|
||||
(MockTransportService) getFollowerCluster().getInstance(TransportService.class, senderNode.value.getName());
|
||||
senderTransportService.clearAllRules();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void assertRetentionLeaseRenewal(
|
||||
|
|
Loading…
Reference in New Issue