Test: Write node ports file before starting tribe service (#24351)

The tribe service can take a while to initialize, depending on how many cluster it needs to connect to. This change moves writing the ports file used by tests to before the tribe service is started.
This commit is contained in:
Ryan Ernst 2017-04-27 00:59:54 -07:00 committed by Yannick Welsch
parent 1be2800120
commit 4a5c3c5a4a
4 changed files with 20 additions and 11 deletions

View File

@ -61,7 +61,6 @@ import org.elasticsearch.discovery.zen.ZenDiscovery;
import org.elasticsearch.env.Environment; import org.elasticsearch.env.Environment;
import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.gateway.GatewayService; import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.gateway.PrimaryShardAllocator;
import org.elasticsearch.http.HttpTransportSettings; import org.elasticsearch.http.HttpTransportSettings;
import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.indices.IndexingMemoryController; import org.elasticsearch.indices.IndexingMemoryController;
@ -345,7 +344,7 @@ public final class ClusterSettings extends AbstractScopedSettings {
SearchService.DEFAULT_KEEPALIVE_SETTING, SearchService.DEFAULT_KEEPALIVE_SETTING,
SearchService.KEEPALIVE_INTERVAL_SETTING, SearchService.KEEPALIVE_INTERVAL_SETTING,
SearchService.LOW_LEVEL_CANCELLATION_SETTING, SearchService.LOW_LEVEL_CANCELLATION_SETTING,
Node.WRITE_PORTS_FIELD_SETTING, Node.WRITE_PORTS_FILE_SETTING,
Node.NODE_NAME_SETTING, Node.NODE_NAME_SETTING,
Node.NODE_DATA_SETTING, Node.NODE_DATA_SETTING,
Node.NODE_MASTER_SETTING, Node.NODE_MASTER_SETTING,

View File

@ -168,7 +168,7 @@ import static java.util.stream.Collectors.toList;
public class Node implements Closeable { public class Node implements Closeable {
public static final Setting<Boolean> WRITE_PORTS_FIELD_SETTING = public static final Setting<Boolean> WRITE_PORTS_FILE_SETTING =
Setting.boolSetting("node.portsfile", false, Property.NodeScope); Setting.boolSetting("node.portsfile", false, Property.NodeScope);
public static final Setting<Boolean> NODE_DATA_SETTING = Setting.boolSetting("node.data", true, Property.NodeScope); public static final Setting<Boolean> NODE_DATA_SETTING = Setting.boolSetting("node.data", true, Property.NodeScope);
public static final Setting<Boolean> NODE_MASTER_SETTING = public static final Setting<Boolean> NODE_MASTER_SETTING =
@ -727,13 +727,7 @@ public class Node implements Closeable {
injector.getInstance(HttpServerTransport.class).start(); injector.getInstance(HttpServerTransport.class).start();
} }
// start nodes now, after the http server, because it may take some time if (WRITE_PORTS_FILE_SETTING.get(settings)) {
tribeService.startNodes();
// starts connecting to remote clusters if any cluster is configured
SearchTransportService searchTransportService = injector.getInstance(SearchTransportService.class);
searchTransportService.start();
if (WRITE_PORTS_FIELD_SETTING.get(settings)) {
if (NetworkModule.HTTP_ENABLED.get(settings)) { if (NetworkModule.HTTP_ENABLED.get(settings)) {
HttpServerTransport http = injector.getInstance(HttpServerTransport.class); HttpServerTransport http = injector.getInstance(HttpServerTransport.class);
writePortsFile("http", http.boundAddress()); writePortsFile("http", http.boundAddress());
@ -742,6 +736,12 @@ public class Node implements Closeable {
writePortsFile("transport", transport.boundAddress()); writePortsFile("transport", transport.boundAddress());
} }
// start nodes now, after the http server, because it may take some time
tribeService.startNodes();
// starts connecting to remote clusters if any cluster is configured
SearchTransportService searchTransportService = injector.getInstance(SearchTransportService.class);
searchTransportService.start();
logger.info("started"); logger.info("started");
return this; return this;

View File

@ -109,7 +109,7 @@ public class AzureDiscoveryClusterFormationTests extends ESIntegTestCase {
.put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), AzureDiscoveryPlugin.AZURE) .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), AzureDiscoveryPlugin.AZURE)
.put(Environment.PATH_LOGS_SETTING.getKey(), resolve) .put(Environment.PATH_LOGS_SETTING.getKey(), resolve)
.put(TransportSettings.PORT.getKey(), 0) .put(TransportSettings.PORT.getKey(), 0)
.put(Node.WRITE_PORTS_FIELD_SETTING.getKey(), "true") .put(Node.WRITE_PORTS_FILE_SETTING.getKey(), "true")
.put(AzureComputeService.Management.ENDPOINT_SETTING.getKey(), "https://" + InetAddress.getLoopbackAddress().getHostAddress() + .put(AzureComputeService.Management.ENDPOINT_SETTING.getKey(), "https://" + InetAddress.getLoopbackAddress().getHostAddress() +
":" + httpsServer.getAddress().getPort()) ":" + httpsServer.getAddress().getPort())
.put(Environment.PATH_CONF_SETTING.getKey(), keyStoreFile.getParent().toAbsolutePath()) .put(Environment.PATH_CONF_SETTING.getKey(), keyStoreFile.getParent().toAbsolutePath())

View File

@ -52,4 +52,14 @@ integTestCluster {
setting 'tribe.two.http.enabled', 'true' setting 'tribe.two.http.enabled', 'true'
setting 'tribe.two.http.port', '40250-40299' setting 'tribe.two.http.port', '40250-40299'
setting 'tribe.two.transport.tcp.port', '40250-40399' setting 'tribe.two.transport.tcp.port', '40250-40399'
waitCondition = { node, ant ->
File tmpFile = new File(node.cwd, 'wait.success')
// 5 nodes: tribe + clusterOne (1 node + tribe internal node) + clusterTwo (1 node + tribe internal node)
ant.get(src: "http://${node.httpUri()}/_cluster/health?wait_for_nodes=>=5&wait_for_status=yellow",
dest: tmpFile.toString(),
ignoreerrors: true,
retries: 10)
return tmpFile.exists()
}
} }