Fix RareClusterStateIT on MacOS (#40203)

Today RareClusterStateIT#testAssignmentWithJustAddedNodes fails on my Mac
because it waits for the default connection timeout of 30 seconds to connect to
a fake node with IP address 0.0.0.0. This connection attempt fails much more
quickly on Linux so the test passes.

This commit fixes this by reducing the connection timeout for this test.
This commit is contained in:
David Turner 2019-03-19 17:31:07 +00:00
parent a13b4bc8c5
commit 33d8738c68
1 changed files with 3 additions and 7 deletions

View File

@ -51,6 +51,7 @@ import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.disruption.BlockClusterStateProcessing; import org.elasticsearch.test.disruption.BlockClusterStateProcessing;
import org.elasticsearch.test.junit.annotations.TestLogging; import org.elasticsearch.test.junit.annotations.TestLogging;
import org.elasticsearch.transport.TransportSettings;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -81,7 +82,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
} }
public void testAssignmentWithJustAddedNodes() { public void testAssignmentWithJustAddedNodes() {
internalCluster().startNode(); internalCluster().startNode(Settings.builder().put(TransportSettings.CONNECT_TIMEOUT.getKey(), "1s"));
final String index = "index"; final String index = "index";
prepareCreate(index).setSettings(Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) prepareCreate(index).setSettings(Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)).get(); .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)).get();
@ -90,13 +91,12 @@ public class RareClusterStateIT extends ESIntegTestCase {
// close to have some unassigned started shards shards.. // close to have some unassigned started shards shards..
client().admin().indices().prepareClose(index).get(); client().admin().indices().prepareClose(index).get();
final String masterName = internalCluster().getMasterName(); final String masterName = internalCluster().getMasterName();
final ClusterService clusterService = internalCluster().clusterService(masterName); final ClusterService clusterService = internalCluster().clusterService(masterName);
final AllocationService allocationService = internalCluster().getInstance(AllocationService.class, masterName); final AllocationService allocationService = internalCluster().getInstance(AllocationService.class, masterName);
clusterService.submitStateUpdateTask("test-inject-node-and-reroute", new ClusterStateUpdateTask() { clusterService.submitStateUpdateTask("test-inject-node-and-reroute", new ClusterStateUpdateTask() {
@Override @Override
public ClusterState execute(ClusterState currentState) throws Exception { public ClusterState execute(ClusterState currentState) {
// inject a node // inject a node
ClusterState.Builder builder = ClusterState.builder(currentState); ClusterState.Builder builder = ClusterState.builder(currentState);
builder.nodes(DiscoveryNodes.builder(currentState.nodes()).add(new DiscoveryNode("_non_existent", builder.nodes(DiscoveryNodes.builder(currentState.nodes()).add(new DiscoveryNode("_non_existent",
@ -115,12 +115,10 @@ public class RareClusterStateIT extends ESIntegTestCase {
updatedState = ClusterState.builder(updatedState).routingTable(routingTable.build()).build(); updatedState = ClusterState.builder(updatedState).routingTable(routingTable.build()).build();
return allocationService.reroute(updatedState, "reroute"); return allocationService.reroute(updatedState, "reroute");
} }
@Override @Override
public void onFailure(String source, Exception e) { public void onFailure(String source, Exception e) {
} }
}); });
ensureGreen(index); ensureGreen(index);
@ -133,12 +131,10 @@ public class RareClusterStateIT extends ESIntegTestCase {
currentState = builder.build(); currentState = builder.build();
return allocationService.disassociateDeadNodes(currentState, true, "reroute"); return allocationService.disassociateDeadNodes(currentState, true, "reroute");
} }
@Override @Override
public void onFailure(String source, Exception e) { public void onFailure(String source, Exception e) {
} }
}); });
} }