@@ -153,6 +153,21 @@ public void assertStartedAndStop() throws Exception {
153153 runElasticsearchTests ();
154154
155155 assertCommand (serviceScript + " stop" );
156+ assertStopped ();
157+
158+ assertCommand (serviceScript + " remove" );
159+ assertCommand (
160+ "$p = Get-Service -Name \" elasticsearch-service-x64\" -ErrorAction SilentlyContinue;"
161+ + "echo \" $p\" ;"
162+ + "if ($p -eq $Null) {"
163+ + " exit 0;"
164+ + "} else {"
165+ + " exit 1;"
166+ + "}"
167+ );
168+ }
169+
170+ private void assertStopped () {
156171 assertService (DEFAULT_ID , "Stopped" );
157172 // the process is stopped async, and can become a zombie process, so we poll for the process actually being gone
158173 assertCommand (
@@ -170,17 +185,6 @@ public void assertStartedAndStop() throws Exception {
170185 + "} while ($i -lt 300);"
171186 + "exit 9;"
172187 );
173-
174- assertCommand (serviceScript + " remove" );
175- assertCommand (
176- "$p = Get-Service -Name \" elasticsearch-service-x64\" -ErrorAction SilentlyContinue;"
177- + "echo \" $p\" ;"
178- + "if ($p -eq $Null) {"
179- + " exit 0;"
180- + "} else {"
181- + " exit 1;"
182- + "}"
183- );
184188 }
185189
186190 public void test30StartStop () throws Exception {
@@ -205,17 +209,22 @@ public void test32StopNotStarted() throws IOException {
205209 public void test33JavaChanged () throws Exception {
206210 final Path alternateJdk = installation .bundledJdk .getParent ().resolve ("jdk.copy" );
207211
208- try {
209- copyDirectory (installation .bundledJdk , alternateJdk );
210- sh .getEnv ().put ("ES_JAVA_HOME" , alternateJdk .toString ());
211- assertCommand (serviceScript + " install" );
212- sh .getEnv ().remove ("ES_JAVA_HOME" );
213- assertCommand (serviceScript + " start" );
214- assertStartedAndStop ();
215- assertCommand (serviceScript + " remove" );
216- } finally {
217- FileUtils .rm (alternateJdk );
218- }
212+ copyDirectory (installation .bundledJdk , alternateJdk );
213+ sh .getEnv ().put ("ES_JAVA_HOME" , alternateJdk .toString ());
214+ assertCommand (serviceScript + " install" );
215+ sh .getEnv ().remove ("ES_JAVA_HOME" );
216+ assertCommand (serviceScript + " start" );
217+ assertStartedAndStop ();
218+ }
219+
220+ public void test34StartStopStart () throws Exception {
221+ assertCommand (serviceScript + " install" );
222+ assertCommand (serviceScript + " start" );
223+ ServerUtils .waitForElasticsearch (installation );
224+ assertCommand (serviceScript + " stop" );
225+ assertStopped ();
226+ assertCommand (serviceScript + " start" );
227+ assertStartedAndStop ();
219228 }
220229
221230 public void test80JavaOptsInEnvVar () throws Exception {
0 commit comments