diff --git a/muted-tests.yml b/muted-tests.yml index 82f146176a021..459b14c5ba1b3 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 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..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,16 +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(); - } 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 {