2626import io .opentelemetry .testing .internal .armeria .common .HttpMethod ;
2727import io .opentelemetry .testing .internal .armeria .common .RequestHeaders ;
2828import java .util .List ;
29+
30+ import org .junit .jupiter .api .AfterAll ;
2931import org .junit .jupiter .api .BeforeEach ;
3032import org .junit .jupiter .api .Test ;
3133
3234public abstract class AppServerTest {
3335 protected boolean isWindows ;
3436 protected String serverVersion ;
37+ private static SmokeTestInstrumentationExtension <AppServerImage > started ;
3538
3639 @ BeforeEach
3740 void setUp () {
41+ if (started != null ) {
42+ return ;
43+ }
44+
3845 var appServer = getClass ().getAnnotation (AppServer .class );
3946 if (appServer == null ) {
4047 throw new IllegalStateException (
@@ -49,7 +56,17 @@ void setUp() {
4956 assumeFalse (isWindows && jdk .endsWith ("-openj9" ));
5057
5158 serverVersion = appServer .version ();
52- testing ().start (new AppServerImage (jdk , serverVersion , isWindows ));
59+ testing ().startWithoutCleanup (new AppServerImage (jdk , serverVersion , isWindows ));
60+
61+ started = testing ();
62+ }
63+
64+ @ AfterAll
65+ static void afterAll () {
66+ if (started != null ) {
67+ started .stop ();
68+ started = null ;
69+ }
5370 }
5471
5572 protected abstract SmokeTestInstrumentationExtension <AppServerImage > testing ();
@@ -136,7 +153,9 @@ void testStaticFileNotFound() {
136153 trace ->
137154 trace .hasSpansSatisfyingExactly (
138155 span -> assertServerSpan (span , path ),
139- span -> span .hasName ("HttpServletResponseWrapper.sendError" ).hasKind (SpanKind .INTERNAL )));
156+ span ->
157+ span .hasName ("HttpServletResponseWrapper.sendError" )
158+ .hasKind (SpanKind .INTERNAL )));
140159 }
141160
142161 @ Test
@@ -148,9 +167,7 @@ void testRequestForWebInfWebXml() {
148167
149168 testing ()
150169 .waitAndAssertTraces (
151- trace ->
152- trace .hasSpansSatisfyingExactly (
153- span -> assertServerSpan (span , path )));
170+ trace -> trace .hasSpansSatisfyingExactly (span -> assertServerSpan (span , path )));
154171 }
155172
156173 @ Test
@@ -184,9 +201,7 @@ void testRequestOutsideDeployedApplication() {
184201
185202 testing ()
186203 .waitAndAssertTraces (
187- trace ->
188- trace .hasSpansSatisfyingExactly (
189- span -> assertServerSpan (span , path )));
204+ trace -> trace .hasSpansSatisfyingExactly (span -> assertServerSpan (span , path )));
190205 }
191206
192207 @ Test
0 commit comments