Skip to content

Commit

Permalink
fix: 컨테이너가 종료되기 전에 값을 검증해서 테스트가 실패하는 오류 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
joon6093 committed Nov 29, 2024
1 parent 6a65e7d commit 7d09baa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -153,6 +153,8 @@ private static void sendSigtermToContainer(GenericContainer<?> container) throws
.withSignal("SIGTERM")
.exec();

Thread.sleep(1000);
while (container.isRunning()) {
Thread.sleep(1000);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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,
}
Expand All @@ -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);
});
Expand Down

0 comments on commit 7d09baa

Please sign in to comment.