From 5ef6fe802cd89b4d775ca49b5f18f7f87e5d35bd Mon Sep 17 00:00:00 2001 From: Lorenzo Dematte Date: Fri, 3 Oct 2025 08:40:53 +0200 Subject: [PATCH 1/3] Unmute test33JavaChanged --- muted-tests.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index f1debcdad8701..b36c43615dbaf 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -32,9 +32,6 @@ tests: - class: org.elasticsearch.packaging.test.WindowsServiceTests method: test30StartStop issue: https://github.com/elastic/elasticsearch/issues/113160 -- class: org.elasticsearch.packaging.test.WindowsServiceTests - method: test33JavaChanged - issue: https://github.com/elastic/elasticsearch/issues/113177 - class: org.elasticsearch.packaging.test.WindowsServiceTests method: test80JavaOptsInEnvVar issue: https://github.com/elastic/elasticsearch/issues/113219 From 523e05a2332999a6e1ac6b82f00b80a6494ca277 Mon Sep 17 00:00:00 2001 From: Lorenzo Dematte Date: Mon, 6 Oct 2025 16:46:35 +0200 Subject: [PATCH 2/3] Add remove before finally --- .../org/elasticsearch/packaging/test/WindowsServiceTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/qa/packaging/src/test/java/org/elasticsearch/packaging/test/WindowsServiceTests.java b/qa/packaging/src/test/java/org/elasticsearch/packaging/test/WindowsServiceTests.java index 36325bb156374..46691d3ab770a 100644 --- a/qa/packaging/src/test/java/org/elasticsearch/packaging/test/WindowsServiceTests.java +++ b/qa/packaging/src/test/java/org/elasticsearch/packaging/test/WindowsServiceTests.java @@ -212,6 +212,7 @@ public void test33JavaChanged() throws Exception { sh.getEnv().remove("ES_JAVA_HOME"); assertCommand(serviceScript + " start"); assertStartedAndStop(); + assertCommand(serviceScript + " remove"); } finally { FileUtils.rm(alternateJdk); } From 2a3e01d764be4c87e3c0a2e304ea59ee8a484fc1 Mon Sep 17 00:00:00 2001 From: Lorenzo Dematte Date: Wed, 8 Oct 2025 08:44:58 +0200 Subject: [PATCH 3/3] Avoid removing JDK at the end, add start-stop-start test --- .../packaging/test/WindowsServiceTests.java | 53 +++++++++++-------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/qa/packaging/src/test/java/org/elasticsearch/packaging/test/WindowsServiceTests.java b/qa/packaging/src/test/java/org/elasticsearch/packaging/test/WindowsServiceTests.java index 46691d3ab770a..3c4c5c305b29b 100644 --- a/qa/packaging/src/test/java/org/elasticsearch/packaging/test/WindowsServiceTests.java +++ b/qa/packaging/src/test/java/org/elasticsearch/packaging/test/WindowsServiceTests.java @@ -153,6 +153,21 @@ public void assertStartedAndStop() throws Exception { runElasticsearchTests(); assertCommand(serviceScript + " stop"); + assertStopped(); + + assertCommand(serviceScript + " remove"); + assertCommand( + "$p = Get-Service -Name \"elasticsearch-service-x64\" -ErrorAction SilentlyContinue;" + + "echo \"$p\";" + + "if ($p -eq $Null) {" + + " exit 0;" + + "} else {" + + " exit 1;" + + "}" + ); + } + + private void assertStopped() { assertService(DEFAULT_ID, "Stopped"); // the process is stopped async, and can become a zombie process, so we poll for the process actually being gone assertCommand( @@ -170,17 +185,6 @@ public void assertStartedAndStop() throws Exception { + "} while ($i -lt 300);" + "exit 9;" ); - - assertCommand(serviceScript + " remove"); - assertCommand( - "$p = Get-Service -Name \"elasticsearch-service-x64\" -ErrorAction SilentlyContinue;" - + "echo \"$p\";" - + "if ($p -eq $Null) {" - + " exit 0;" - + "} else {" - + " exit 1;" - + "}" - ); } public void test30StartStop() throws Exception { @@ -205,17 +209,22 @@ public void test32StopNotStarted() throws IOException { public void test33JavaChanged() throws Exception { final Path alternateJdk = installation.bundledJdk.getParent().resolve("jdk.copy"); - try { - copyDirectory(installation.bundledJdk, alternateJdk); - sh.getEnv().put("ES_JAVA_HOME", alternateJdk.toString()); - assertCommand(serviceScript + " install"); - sh.getEnv().remove("ES_JAVA_HOME"); - assertCommand(serviceScript + " start"); - assertStartedAndStop(); - assertCommand(serviceScript + " remove"); - } finally { - FileUtils.rm(alternateJdk); - } + copyDirectory(installation.bundledJdk, alternateJdk); + sh.getEnv().put("ES_JAVA_HOME", alternateJdk.toString()); + assertCommand(serviceScript + " install"); + sh.getEnv().remove("ES_JAVA_HOME"); + assertCommand(serviceScript + " start"); + assertStartedAndStop(); + } + + public void test34StartStopStart() throws Exception { + assertCommand(serviceScript + " install"); + assertCommand(serviceScript + " start"); + ServerUtils.waitForElasticsearch(installation); + assertCommand(serviceScript + " stop"); + assertStopped(); + assertCommand(serviceScript + " start"); + assertStartedAndStop(); } public void test80JavaOptsInEnvVar() throws Exception {