-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert RunTask to use testclusers, remove ClusterFormationTasks #47572
Conversation
This PR adds a new RunTask and a way for it to start a testclusters cluster out of band and block on it to replace the old RunTask that used ClusterFormationTasks. With this we can now remove ClusterFormationTasks.
Pinging @elastic/es-core-infra (:Core/Infra/Build) |
The elasticsearch-hadoop project relies on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So glad to finally be removing the legacy cluster handling code.
Left some comments that I think we should address.
buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/RunTask.java
Outdated
Show resolved
Hide resolved
buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchCluster.java
Outdated
Show resolved
Hide resolved
@@ -631,7 +633,9 @@ private void runElaticsearchBinScript(String tool, String... args) { | |||
|
|||
private Map<String, String> getESEnvironment() { | |||
Map<String, String> defaultEnv = new HashMap<>(); | |||
defaultEnv.put("JAVA_HOME", getJavaHome().getAbsolutePath()); | |||
if ( getJavaHome() != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: looks like we have an extra space here
@@ -147,6 +147,9 @@ | |||
private volatile Process esProcess; | |||
private Function<String, String> nameCustomization = Function.identity(); | |||
private boolean isWorkingDirConfigured = false; | |||
private String httpPort = "0"; | |||
private String transportPort = "0"; | |||
private boolean logOnConsole = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about logToConsole
?
@@ -1273,6 +1282,16 @@ void configureHttpWait(WaitForHttpResource wait) { | |||
} | |||
} | |||
|
|||
void configureForRun() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd prefer these to just be exposed as settings which the RunTask
explicitly sets rather than coupling ElasticsearchNode
to RunTask
in this way.
public void runAndWait() { | ||
cluster.freeze(); | ||
cluster.run(debug); | ||
while (Thread.currentThread().isInterrupted() == false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this even necessary since calling run()
in turn calls Process.waitFor()
?
} | ||
|
||
public void setCluster(ElasticsearchCluster cluster) { | ||
TestClustersAware.prepareClusterForUse(getProject(), this, cluster); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could avoid this nastiness if we just had this task implement TestClustersAware
itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @mark-vieira
I did want to use the existing life-cycle management initially,
this is now possible with the introduction of beforeStart
to give the chance to the task to reconfigure the cluster right before starting it.
I'm much happier with how this came out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks much cleaner after refactoring. Couple of items though.
dependsOn(distro.getExtracted()) | ||
); | ||
getClusters().add(cluster); | ||
} | ||
|
||
default void beforeStart() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps I'm missing something but I can't find anywhere where this is actually called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, it wasn't and I didn't test all use-cases so didn't notice it. It's fixed now.
int port = 8000; | ||
for (ElasticsearchCluster cluster : getClusters()) { | ||
for (ElasticsearchNode node : cluster.getNodes()) { | ||
node.setHttpPort("9200"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this fail to bind for clusters w/ > 1 node? We seem to be incrementing the debug port, should we do the same for the HTTP and transport ports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I added port increment.
run elasticsearch-ci/packaging-sample |
This PR adds a new RunTask and a way for it to start a
testclusters cluster out of band and block on it to replace
the old RunTask that used ClusterFormationTasks.
Note that the new RunTask starts existing clusters, it doesn't have a configuration of it's own, so we can avoid duplicating the configuration in a few places.
With this we can now remove ClusterFormationTasks.
We could consider adding a Gradle convention so there's a task to run any cluster in the build.