Skip to content

Commit df7d84e

Browse files
committed
chore: use separate message for empty exit code file. (#13997)
1 parent 43f964a commit df7d84e

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

airbyte-commons-worker/src/main/kotlin/io/airbyte/workers/internal/ContainerIOHandle.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ data class ContainerIOHandle(
3030
private val terminationFile: File,
3131
) {
3232
companion object {
33-
const val EXIT_CODE_CHECK_FAILURE = "No exit code found."
33+
const val EXIT_CODE_CHECK_EXISTS_FAILURE = "No exit code found."
34+
const val EXIT_CODE_CHECK_NOT_EMPTY_FAILURE = "Exit code file empty."
3435
const val TERMINATION_FILE_BODY = "TERMINATE"
3536

3637
/**
@@ -100,8 +101,8 @@ data class ContainerIOHandle(
100101
fun exitCodeExists(): Boolean = exitValueFile.exists()
101102

102103
fun getExitCode(): Int {
103-
check(exitCodeExists()) { EXIT_CODE_CHECK_FAILURE }
104-
check(exitValueFile.readText().isNotEmpty()) { EXIT_CODE_CHECK_FAILURE }
104+
check(exitCodeExists()) { EXIT_CODE_CHECK_EXISTS_FAILURE }
105+
check(exitValueFile.readText().isNotEmpty()) { EXIT_CODE_CHECK_NOT_EMPTY_FAILURE }
105106
return exitValueFile.readText().trim().toInt()
106107
}
107108

airbyte-commons-worker/src/test/kotlin/io/airbyte/workers/internal/ContainerIOHandleTest.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
package io.airbyte.workers.internal
66

7-
import io.airbyte.workers.internal.ContainerIOHandle.Companion.EXIT_CODE_CHECK_FAILURE
7+
import io.airbyte.workers.internal.ContainerIOHandle.Companion.EXIT_CODE_CHECK_EXISTS_FAILURE
8+
import io.airbyte.workers.internal.ContainerIOHandle.Companion.EXIT_CODE_CHECK_NOT_EMPTY_FAILURE
89
import io.airbyte.workers.internal.ContainerIOHandle.Companion.TERMINATION_FILE_BODY
910
import io.mockk.mockk
1011
import org.junit.jupiter.api.AfterEach
@@ -70,7 +71,7 @@ internal class ContainerIOHandleTest {
7071
internal fun testGetErrorCode() {
7172
// File exists but is empty
7273
val emptyFileError = assertThrows(IllegalStateException::class.java, containerIOHandle::getExitCode)
73-
assertEquals(EXIT_CODE_CHECK_FAILURE, emptyFileError.message)
74+
assertEquals(EXIT_CODE_CHECK_NOT_EMPTY_FAILURE, emptyFileError.message)
7475

7576
// File exists and contains an exit value
7677
val exitCode = -122
@@ -80,7 +81,7 @@ internal class ContainerIOHandleTest {
8081
// File does not exist
8182
exitValueFile.delete()
8283
val notExistError = assertThrows(IllegalStateException::class.java, containerIOHandle::getExitCode)
83-
assertEquals(EXIT_CODE_CHECK_FAILURE, notExistError.message)
84+
assertEquals(EXIT_CODE_CHECK_EXISTS_FAILURE, notExistError.message)
8485
}
8586

8687
@Test

airbyte-commons-worker/src/test/kotlin/io/airbyte/workers/internal/LocalContainerAirbyteDestinationTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package io.airbyte.workers.internal
77
import io.airbyte.config.WorkerDestinationConfig
88
import io.airbyte.protocol.models.AirbyteMessage
99
import io.airbyte.workers.exception.WorkerException
10-
import io.airbyte.workers.internal.ContainerIOHandle.Companion.EXIT_CODE_CHECK_FAILURE
10+
import io.airbyte.workers.internal.ContainerIOHandle.Companion.EXIT_CODE_CHECK_EXISTS_FAILURE
1111
import io.mockk.every
1212
import io.mockk.mockk
1313
import io.mockk.verify
@@ -251,7 +251,7 @@ internal class LocalContainerAirbyteDestinationTest {
251251

252252
exitValueFile.delete()
253253
val error = assertThrows(IllegalStateException::class.java, { destination.exitValue })
254-
assertEquals(EXIT_CODE_CHECK_FAILURE, error.message)
254+
assertEquals(EXIT_CODE_CHECK_EXISTS_FAILURE, error.message)
255255
}
256256

257257
@Test

airbyte-commons-worker/src/test/kotlin/io/airbyte/workers/internal/LocalContainerAirbyteSourceTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package io.airbyte.workers.internal
77
import io.airbyte.config.WorkerSourceConfig
88
import io.airbyte.protocol.models.AirbyteMessage
99
import io.airbyte.workers.exception.WorkerException
10-
import io.airbyte.workers.internal.ContainerIOHandle.Companion.EXIT_CODE_CHECK_FAILURE
10+
import io.airbyte.workers.internal.ContainerIOHandle.Companion.EXIT_CODE_CHECK_EXISTS_FAILURE
1111
import io.mockk.every
1212
import io.mockk.mockk
1313
import io.mockk.verify
@@ -142,7 +142,7 @@ internal class LocalContainerAirbyteSourceTest {
142142

143143
exitValueFile.delete()
144144
val error = assertThrows(IllegalStateException::class.java, { source.exitValue })
145-
assertEquals(EXIT_CODE_CHECK_FAILURE, error.message)
145+
assertEquals(EXIT_CODE_CHECK_EXISTS_FAILURE, error.message)
146146
}
147147

148148
@Test

0 commit comments

Comments
 (0)