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:
parent
a13b4bc8c5
commit
33d8738c68
|
@ -51,6 +51,7 @@ import org.elasticsearch.indices.IndicesService;
|
|||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.disruption.BlockClusterStateProcessing;
|
||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||
import org.elasticsearch.transport.TransportSettings;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -81,7 +82,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
public void testAssignmentWithJustAddedNodes() {
|
||||
internalCluster().startNode();
|
||||
internalCluster().startNode(Settings.builder().put(TransportSettings.CONNECT_TIMEOUT.getKey(), "1s"));
|
||||
final String index = "index";
|
||||
prepareCreate(index).setSettings(Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
|
||||
.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..
|
||||
client().admin().indices().prepareClose(index).get();
|
||||
|
||||
|
||||
final String masterName = internalCluster().getMasterName();
|
||||
final ClusterService clusterService = internalCluster().clusterService(masterName);
|
||||
final AllocationService allocationService = internalCluster().getInstance(AllocationService.class, masterName);
|
||||
clusterService.submitStateUpdateTask("test-inject-node-and-reroute", new ClusterStateUpdateTask() {
|
||||
@Override
|
||||
public ClusterState execute(ClusterState currentState) throws Exception {
|
||||
public ClusterState execute(ClusterState currentState) {
|
||||
// inject a node
|
||||
ClusterState.Builder builder = ClusterState.builder(currentState);
|
||||
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();
|
||||
|
||||
return allocationService.reroute(updatedState, "reroute");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String source, Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
ensureGreen(index);
|
||||
|
@ -133,12 +131,10 @@ public class RareClusterStateIT extends ESIntegTestCase {
|
|||
|
||||
currentState = builder.build();
|
||||
return allocationService.disassociateDeadNodes(currentState, true, "reroute");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String source, Exception e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue