2424import eu .openanalytics .containerproxy .test .helpers .ShinyProxyClient ;
2525import eu .openanalytics .containerproxy .test .helpers .ShinyProxyInstance ;
2626import io .fabric8 .kubernetes .api .model .Pod ;
27+ import org .junit .jupiter .api .AfterEach ;
2728import org .junit .jupiter .api .Assertions ;
2829import org .junit .jupiter .api .Test ;
2930import org .junit .jupiter .params .ParameterizedTest ;
@@ -51,6 +52,11 @@ private static Stream<Arguments> provideStringsForIsBlank() {
5152 );
5253 }
5354
55+ @ AfterEach
56+ public void waitForCleanup () throws InterruptedException {
57+ Thread .sleep (20_000 );
58+ }
59+
5460 @ ParameterizedTest
5561 @ MethodSource ("provideStringsForIsBlank" )
5662 public void simple_recover_single_app_after_shutdown (String backend , String extraArgs ) throws IOException , InterruptedException {
@@ -89,8 +95,6 @@ public void simple_recover_single_app_after_shutdown(String backend, String extr
8995 // 8. stop the proxy
9096 Assertions .assertTrue (shinyProxyClient .stopProxy (id ));
9197
92- Thread .sleep (500 ); // Give ShinyProxy time to cleanup
93-
9498 // 9. stop the instance
9599 instance2 .stop ();
96100 } finally {
@@ -105,7 +109,7 @@ public void new_app_should_work_after_recovery(String backend, String extraArgs)
105109 List <ShinyProxyInstance > instances = new ArrayList <>();
106110 try {
107111 // 1. create the instance
108- ShinyProxyInstance instance1 = new ShinyProxyInstance ("1 " , String .format ("application-app-recovery_%s.yml" , backend ), extraArgs );
112+ ShinyProxyInstance instance1 = new ShinyProxyInstance ("3 " , String .format ("application-app-recovery_%s.yml" , backend ), extraArgs );
109113 instances .add (instance1 );
110114 Assertions .assertTrue (instance1 .start ());
111115
@@ -121,7 +125,7 @@ public void new_app_should_work_after_recovery(String backend, String extraArgs)
121125 instance1 .stop ();
122126
123127 // 5. start the instance again
124- ShinyProxyInstance instance2 = new ShinyProxyInstance ("2 " , String .format ("application-app-recovery_%s.yml" , backend ), extraArgs );
128+ ShinyProxyInstance instance2 = new ShinyProxyInstance ("4 " , String .format ("application-app-recovery_%s.yml" , backend ), extraArgs );
125129 instances .add (instance2 );
126130 Assertions .assertTrue (instance2 .start ());
127131
@@ -144,8 +148,6 @@ public void new_app_should_work_after_recovery(String backend, String extraArgs)
144148 Assertions .assertTrue (shinyProxyClient .stopProxy (id1 ));
145149 Assertions .assertTrue (shinyProxyClient .stopProxy (id2 ));
146150
147- Thread .sleep (1000 ); // Give ShinyProxy time to cleanup
148-
149151 // 9. stop the instance
150152 instance2 .stop ();
151153 } finally {
@@ -163,7 +165,7 @@ public void complex_recover_multiple_apps_after_shutdown(String backend, String
163165 List <ShinyProxyInstance > instances = new ArrayList <>();
164166 try {
165167 // 1. create the instance
166- ShinyProxyInstance instance1 = new ShinyProxyInstance ("1 " , String .format ("application-app-recovery_%s.yml" , backend ), extraArgs );
168+ ShinyProxyInstance instance1 = new ShinyProxyInstance ("5 " , String .format ("application-app-recovery_%s.yml" , backend ), extraArgs );
167169 instances .add (instance1 );
168170 Assertions .assertTrue (instance1 .start ());
169171
@@ -209,7 +211,7 @@ public void complex_recover_multiple_apps_after_shutdown(String backend, String
209211 instance1 .stop ();
210212
211213 // 9. start the instance again
212- ShinyProxyInstance instance2 = new ShinyProxyInstance ("2 " , String .format ("application-app-recovery_%s.yml" , backend ), extraArgs );
214+ ShinyProxyInstance instance2 = new ShinyProxyInstance ("6 " , String .format ("application-app-recovery_%s.yml" , backend ), extraArgs );
213215 instances .add (instance2 );
214216 Assertions .assertTrue (instance2 .start ());
215217
@@ -245,8 +247,6 @@ public void complex_recover_multiple_apps_after_shutdown(String backend, String
245247 Assertions .assertTrue (shinyProxyClient3 .stopProxy (id5 ));
246248 Assertions .assertTrue (shinyProxyClient3 .stopProxy (id6 ));
247249
248- Thread .sleep (2500 ); // Give ShinyProxy time to cleanup
249-
250250 // 17. stop the instance
251251 instance2 .stop ();
252252 } finally {
@@ -262,12 +262,12 @@ public void simple_recover_multiple_instances(String backend, String extraArgs)
262262 List <ShinyProxyInstance > instances = new ArrayList <>();
263263 try {
264264 // 1. create the first instance
265- ShinyProxyInstance instance1 = new ShinyProxyInstance ("1 " , String .format ("application-app-recovery_%s.yml" , backend ), 7583 , extraArgs );
265+ ShinyProxyInstance instance1 = new ShinyProxyInstance ("7 " , String .format ("application-app-recovery_%s.yml" , backend ), 7583 , extraArgs );
266266 instances .add (instance1 );
267267 Assertions .assertTrue (instance1 .start ());
268268
269269 // 1. create the second instance
270- ShinyProxyInstance instance2 = new ShinyProxyInstance ("2 " , String .format ("application-app-recovery_%s_2.yml" , backend ), 7584 , extraArgs );
270+ ShinyProxyInstance instance2 = new ShinyProxyInstance ("8 " , String .format ("application-app-recovery_%s_2.yml" , backend ), 7584 , extraArgs );
271271 instances .add (instance2 );
272272 Assertions .assertTrue (instance2 .start ());
273273
@@ -292,11 +292,11 @@ public void simple_recover_multiple_instances(String backend, String extraArgs)
292292 instance2 .stop ();
293293
294294 // 5. start both instances again
295- ShinyProxyInstance instance3 = new ShinyProxyInstance ("3 " , String .format ("application-app-recovery_%s.yml" , backend ), 7583 , extraArgs );
295+ ShinyProxyInstance instance3 = new ShinyProxyInstance ("9 " , String .format ("application-app-recovery_%s.yml" , backend ), 7583 , extraArgs );
296296 instances .add (instance3 );
297297 Assertions .assertTrue (instance3 .start ());
298298
299- ShinyProxyInstance instance4 = new ShinyProxyInstance ("4 " , String .format ("application-app-recovery_%s_2.yml" , backend ), 7584 , extraArgs );
299+ ShinyProxyInstance instance4 = new ShinyProxyInstance ("10 " , String .format ("application-app-recovery_%s_2.yml" , backend ), 7584 , extraArgs );
300300 instances .add (instance4 );
301301 Assertions .assertTrue (instance4 .start ());
302302
@@ -315,8 +315,6 @@ public void simple_recover_multiple_instances(String backend, String extraArgs)
315315 Assertions .assertTrue (shinyProxyClient1 .stopProxy (id1 ));
316316 Assertions .assertTrue (shinyProxyClient2 .stopProxy (id2 ));
317317
318- Thread .sleep (1000 ); // Give ShinyProxy time to cleanup
319-
320318 // 9. stop the instance
321319 instance3 .stop ();
322320 instance4 .stop ();
@@ -332,7 +330,7 @@ public void kubernetes_multiple_namespaces() {
332330 List <ShinyProxyInstance > instances = new ArrayList <>();
333331 try {
334332 // 1. create the instance
335- ShinyProxyInstance instance1 = new ShinyProxyInstance ("1 " , "application-app-recovery_kubernetes_multi_ns.yml" );
333+ ShinyProxyInstance instance1 = new ShinyProxyInstance ("11 " , "application-app-recovery_kubernetes_multi_ns.yml" );
336334 instances .add (instance1 );
337335 Assertions .assertTrue (instance1 .start ());
338336
@@ -351,7 +349,7 @@ public void kubernetes_multiple_namespaces() {
351349 instance1 .stop ();
352350
353351 // 5. start the instance again
354- ShinyProxyInstance instance2 = new ShinyProxyInstance ("2 " , "application-app-recovery_kubernetes_multi_ns.yml" );
352+ ShinyProxyInstance instance2 = new ShinyProxyInstance ("12 " , "application-app-recovery_kubernetes_multi_ns.yml" );
355353 instances .add (instance2 );
356354 Assertions .assertTrue (instance2 .start ());
357355
@@ -366,8 +364,6 @@ public void kubernetes_multiple_namespaces() {
366364 Assertions .assertTrue (shinyProxyClient .stopProxy (id1 ));
367365 Assertions .assertTrue (shinyProxyClient .stopProxy (id2 ));
368366
369- Thread .sleep (1000 ); // Give ShinyProxy time to cleanup
370-
371367 // 9. stop the instance
372368 instance2 .stop ();
373369 } finally {
@@ -384,7 +380,7 @@ public void shutdown_should_cleanup_by_default() {
384380 List <ShinyProxyInstance > instances = new ArrayList <>();
385381 try {
386382 // 1. create the instance
387- ShinyProxyInstance instance1 = new ShinyProxyInstance ("1 " , "application-app-recovery_kubernetes_normal_shutdown.yml" );
383+ ShinyProxyInstance instance1 = new ShinyProxyInstance ("13 " , "application-app-recovery_kubernetes_normal_shutdown.yml" );
388384 instances .add (instance1 );
389385 Assertions .assertTrue (instance1 .start ());
390386
0 commit comments