Skip to content
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

Merged
merged 5 commits into from
Oct 8, 2019

Conversation

alpar-t
Copy link
Contributor

@alpar-t alpar-t commented Oct 4, 2019

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.

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.
@alpar-t alpar-t added :Delivery/Build Build or test infrastructure v8.0.0 v7.5.0 labels Oct 4, 2019
@alpar-t alpar-t requested review from rjernst and mark-vieira October 4, 2019 12:20
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Build)

@mark-vieira
Copy link
Contributor

The elasticsearch-hadoop project relies on ClusterFormationTasks directly. We need to ensure they are migrated to test clusters before we merge this or we'll break their builds.

Copy link
Contributor

@mark-vieira mark-vieira left a 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.

@@ -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) {
Copy link
Contributor

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;
Copy link
Contributor

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() {
Copy link
Contributor

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) {
Copy link
Contributor

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);
Copy link
Contributor

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.

Copy link
Contributor Author

@alpar-t alpar-t left a 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.

Copy link
Contributor

@mark-vieira mark-vieira left a 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() {
Copy link
Contributor

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.

Copy link
Contributor Author

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");
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@alpar-t
Copy link
Contributor Author

alpar-t commented Oct 8, 2019

run elasticsearch-ci/packaging-sample

@alpar-t alpar-t merged commit 8f78554 into elastic:master Oct 8, 2019
@alpar-t alpar-t deleted the convert-run-task branch October 8, 2019 11:40
alpar-t added a commit that referenced this pull request Oct 8, 2019
)

* Convert RunTask to use testclusers, remove ClusterFormationTasks

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.
alpar-t added a commit that referenced this pull request Oct 15, 2019
…mationTasks (#47572)"

This reverts the removal of the ClusterFormationTaks from
commit 36d018c so they are usable for a
bit longer in the hadoop build.
@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Delivery/Build Build or test infrastructure Team:Delivery Meta label for Delivery team v7.5.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants