diff --git a/test/src/test/java/io/jeyong/test/integration/SigtermHandlerTest.java b/test/src/test/java/io/jeyong/test/integration/SigtermHandlerTest.java index 9ea290d..180be55 100644 --- a/test/src/test/java/io/jeyong/test/integration/SigtermHandlerTest.java +++ b/test/src/test/java/io/jeyong/test/integration/SigtermHandlerTest.java @@ -23,7 +23,7 @@ @DisplayName("SigtermHandler Integration Test") public class SigtermHandlerTest { - private static final int EXPECTED_EXIT_CODE = 10; + private static final int EXIT_CODE = 10; private static final String TERMINATION_MESSAGE_PATH = "/app/termination-message.message"; private static final String TERMINATION_MESSAGE = "Test termination message"; @@ -54,7 +54,7 @@ void testExitCode() throws Exception { // then Long exitCode = container.getCurrentContainerInfo().getState().getExitCodeLong(); - assertThat(exitCode).isEqualTo(EXPECTED_EXIT_CODE); + assertThat(exitCode).isEqualTo(EXIT_CODE); } @Test @@ -116,7 +116,7 @@ private static void createApplicationYaml(Path resourcesDir) throws Exception { exit-code: %d termination-message-path: %s termination-message: %s - """, EXPECTED_EXIT_CODE, TERMINATION_MESSAGE_PATH, TERMINATION_MESSAGE); + """, EXIT_CODE, TERMINATION_MESSAGE_PATH, TERMINATION_MESSAGE); Files.writeString(applicationYaml, yamlContent); } @@ -153,6 +153,8 @@ private static void sendSigtermToContainer(GenericContainer container) throws .withSignal("SIGTERM") .exec(); - Thread.sleep(1000); + while (container.isRunning()) { + Thread.sleep(1000); + } } } diff --git a/test/src/test/java/io/jeyong/test/unit/SigtermHandlerPropertiesTest.java b/test/src/test/java/io/jeyong/test/unit/SigtermHandlerPropertiesTest.java index e1b0102..3cc145f 100644 --- a/test/src/test/java/io/jeyong/test/unit/SigtermHandlerPropertiesTest.java +++ b/test/src/test/java/io/jeyong/test/unit/SigtermHandlerPropertiesTest.java @@ -15,7 +15,7 @@ @DisplayName("SigtermHandlerProperties Unit Test") class SigtermHandlerPropertiesTest { - private static final int EXPECTED_EXIT_CODE = 10; + private static final int EXIT_CODE = 10; private static final String TERMINATION_MESSAGE_PATH = "/termination-message.message"; private static final String TERMINATION_MESSAGE = "Test termination message"; @@ -24,7 +24,7 @@ class SigtermHandlerPropertiesTest { classes = TestApplication.class, properties = { "kubernetes.sigterm-handler.enabled=true", - "kubernetes.sigterm-handler.exit-code=" + EXPECTED_EXIT_CODE, + "kubernetes.sigterm-handler.exit-code=" + EXIT_CODE, "kubernetes.sigterm-handler.termination-message-path=" + TERMINATION_MESSAGE_PATH, "kubernetes.sigterm-handler.termination-message=" + TERMINATION_MESSAGE, } @@ -48,7 +48,7 @@ void testRegisterConfiguration() { // then assertSoftly(softly -> { softly.assertThat(beanExists).isTrue(); - softly.assertThat(properties.getExitCode()).isEqualTo(EXPECTED_EXIT_CODE); + softly.assertThat(properties.getExitCode()).isEqualTo(EXIT_CODE); softly.assertThat(properties.getTerminationMessagePath()).isEqualTo(TERMINATION_MESSAGE_PATH); softly.assertThat(properties.getTerminationMessage()).isEqualTo(TERMINATION_MESSAGE); });