From 7d09baa9f917717ee7749e5c431e027a0fbe5ae8 Mon Sep 17 00:00:00 2001 From: jeyong Date: Sat, 30 Nov 2024 08:01:19 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=BB=A8=ED=85=8C=EC=9D=B4=EB=84=88?= =?UTF-8?q?=EA=B0=80=20=EC=A2=85=EB=A3=8C=EB=90=98=EA=B8=B0=20=EC=A0=84?= =?UTF-8?q?=EC=97=90=20=EA=B0=92=EC=9D=84=20=EA=B2=80=EC=A6=9D=ED=95=B4?= =?UTF-8?q?=EC=84=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EA=B0=80=20=EC=8B=A4?= =?UTF-8?q?=ED=8C=A8=ED=95=98=EB=8A=94=20=EC=98=A4=EB=A5=98=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/jeyong/test/integration/SigtermHandlerTest.java | 10 ++++++---- .../jeyong/test/unit/SigtermHandlerPropertiesTest.java | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) 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); });