Fix CCR tests that manipulate transport requests

We have some CCR tests where we use mock transport send rules to control
the behavior that we desire in these tests. Namely, we want to simulate
an exception being thrown on the leader side, or a variety of other
situations. These send rules were put in place between the data nodes on
each side. However, it might not be the case that these requests are
being sent between data nodes. For example, a request that is handled on
a non-data master node would not be sent from a data node. And it might
not be the case that the request is sent to a data node, as it could be
proxied through a non-data coordinating node. This commit addresses this
by putting these send rules in places between all nodes on each side.

Closes #39011
Closes #39201
This commit is contained in:
Jason Tedor 2019-02-21 12:19:35 -05:00
parent fc896e452c
commit 719c38a36d
No known key found for this signature in database
GPG Key ID: FA89F05560F16BC5
1 changed files with 6 additions and 8 deletions

View File

@ -190,7 +190,6 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
} }
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/39011")
public void testRetentionLeaseIsRenewedDuringRecovery() throws Exception { public void testRetentionLeaseIsRenewedDuringRecovery() throws Exception {
final String leaderIndex = "leader"; final String leaderIndex = "leader";
final int numberOfShards = randomIntBetween(1, 3); final int numberOfShards = randomIntBetween(1, 3);
@ -206,11 +205,11 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
// block the recovery from completing; this ensures the background sync is still running // block the recovery from completing; this ensures the background sync is still running
final ClusterStateResponse followerClusterState = followerClient().admin().cluster().prepareState().clear().setNodes(true).get(); final ClusterStateResponse followerClusterState = followerClient().admin().cluster().prepareState().clear().setNodes(true).get();
for (final ObjectCursor<DiscoveryNode> senderNode : followerClusterState.getState().nodes().getDataNodes().values()) { for (final ObjectCursor<DiscoveryNode> senderNode : followerClusterState.getState().nodes().getNodes().values()) {
final MockTransportService senderTransportService = final MockTransportService senderTransportService =
(MockTransportService) getFollowerCluster().getInstance(TransportService.class, senderNode.value.getName()); (MockTransportService) getFollowerCluster().getInstance(TransportService.class, senderNode.value.getName());
final ClusterStateResponse leaderClusterState = leaderClient().admin().cluster().prepareState().clear().setNodes(true).get(); final ClusterStateResponse leaderClusterState = leaderClient().admin().cluster().prepareState().clear().setNodes(true).get();
for (final ObjectCursor<DiscoveryNode> receiverNode : leaderClusterState.getState().nodes().getDataNodes().values()) { for (final ObjectCursor<DiscoveryNode> receiverNode : leaderClusterState.getState().nodes().getNodes().values()) {
final MockTransportService receiverTransportService = final MockTransportService receiverTransportService =
(MockTransportService) getLeaderCluster().getInstance(TransportService.class, receiverNode.value.getName()); (MockTransportService) getLeaderCluster().getInstance(TransportService.class, receiverNode.value.getName());
senderTransportService.addSendBehavior(receiverTransportService, senderTransportService.addSendBehavior(receiverTransportService,
@ -401,12 +400,12 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
final ClusterStateResponse followerClusterState = followerClient().admin().cluster().prepareState().clear().setNodes(true).get(); final ClusterStateResponse followerClusterState = followerClient().admin().cluster().prepareState().clear().setNodes(true).get();
try { try {
for (final ObjectCursor<DiscoveryNode> senderNode : followerClusterState.getState().nodes().getDataNodes().values()) { for (final ObjectCursor<DiscoveryNode> senderNode : followerClusterState.getState().nodes().getNodes().values()) {
final MockTransportService senderTransportService = final MockTransportService senderTransportService =
(MockTransportService) getFollowerCluster().getInstance(TransportService.class, senderNode.value.getName()); (MockTransportService) getFollowerCluster().getInstance(TransportService.class, senderNode.value.getName());
final ClusterStateResponse leaderClusterState = final ClusterStateResponse leaderClusterState =
leaderClient().admin().cluster().prepareState().clear().setNodes(true).get(); leaderClient().admin().cluster().prepareState().clear().setNodes(true).get();
for (final ObjectCursor<DiscoveryNode> receiverNode : leaderClusterState.getState().nodes().getDataNodes().values()) { for (final ObjectCursor<DiscoveryNode> receiverNode : leaderClusterState.getState().nodes().getNodes().values()) {
final MockTransportService receiverTransportService = final MockTransportService receiverTransportService =
(MockTransportService) getLeaderCluster().getInstance(TransportService.class, receiverNode.value.getName()); (MockTransportService) getLeaderCluster().getInstance(TransportService.class, receiverNode.value.getName());
senderTransportService.addSendBehavior(receiverTransportService, senderTransportService.addSendBehavior(receiverTransportService,
@ -467,7 +466,6 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
} }
} }
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/39201")
public void testUnfollowFailsToRemoveRetentionLeases() throws Exception { public void testUnfollowFailsToRemoveRetentionLeases() throws Exception {
final String leaderIndex = "leader"; final String leaderIndex = "leader";
final String followerIndex = "follower"; final String followerIndex = "follower";
@ -491,12 +489,12 @@ public class CcrRetentionLeaseIT extends CcrIntegTestCase {
final ClusterStateResponse followerClusterState = followerClient().admin().cluster().prepareState().clear().setNodes(true).get(); final ClusterStateResponse followerClusterState = followerClient().admin().cluster().prepareState().clear().setNodes(true).get();
try { try {
for (final ObjectCursor<DiscoveryNode> senderNode : followerClusterState.getState().nodes().getDataNodes().values()) { for (final ObjectCursor<DiscoveryNode> senderNode : followerClusterState.getState().nodes().getNodes().values()) {
final MockTransportService senderTransportService = final MockTransportService senderTransportService =
(MockTransportService) getFollowerCluster().getInstance(TransportService.class, senderNode.value.getName()); (MockTransportService) getFollowerCluster().getInstance(TransportService.class, senderNode.value.getName());
final ClusterStateResponse leaderClusterState = final ClusterStateResponse leaderClusterState =
leaderClient().admin().cluster().prepareState().clear().setNodes(true).get(); leaderClient().admin().cluster().prepareState().clear().setNodes(true).get();
for (final ObjectCursor<DiscoveryNode> receiverNode : leaderClusterState.getState().nodes().getDataNodes().values()) { for (final ObjectCursor<DiscoveryNode> receiverNode : leaderClusterState.getState().nodes().getNodes().values()) {
final MockTransportService receiverTransportService = final MockTransportService receiverTransportService =
(MockTransportService) getLeaderCluster().getInstance(TransportService.class, receiverNode.value.getName()); (MockTransportService) getLeaderCluster().getInstance(TransportService.class, receiverNode.value.getName());
senderTransportService.addSendBehavior(receiverTransportService, senderTransportService.addSendBehavior(receiverTransportService,