Skip to content

Commit 80b2694

Browse files
aparajonsvc-squareup-copybara
authored andcommitted
Emit start-up logs in VitessTestDb after health check fails on max attempts
GitOrigin-RevId: 3283dd7745610441e1fdda3de8ec69d561dee99d
1 parent 7a1350f commit 80b2694

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

Diff for: misk-vitess/src/testFixtures/kotlin/misk/vitess/testing/internal/VitessDockerContainer.kt

+13-8
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,7 @@ internal class VitessDockerContainer(
259259
// If we are here, we likely obtained a vttestserver start-up error.
260260
if (statusCode != 0) {
261261
if (debugStartup) {
262-
val logCallback = LogContainerResultCallback()
263-
dockerClient
264-
.logContainerCmd(containerId)
265-
.withStdOut(true)
266-
.withStdErr(true)
267-
.exec(logCallback)
268-
.awaitCompletion()
269-
println("Container start up logs:\n${logCallback.getLogs()}")
262+
emitStartupLogs(containerId)
270263
throw VitessTestDbStartupException("Failed to start Docker container for `$containerName`.")
271264
}
272265
throw VitessTestDbStartupException(
@@ -286,12 +279,24 @@ internal class VitessDockerContainer(
286279
retryCount++
287280
if (retryCount == CONTAINER_START_RETRIES) {
288281
println("Failed to start Docker container for `$containerName` after max retries.")
282+
emitStartupLogs(containerId)
289283
throw VitessTestDbStartupException("Container health check failed after `$CONTAINER_START_RETRIES` attempts.")
290284
}
291285
}
292286
}
293287
}
294288

289+
private fun emitStartupLogs(containerId: String) {
290+
val logCallback = LogContainerResultCallback()
291+
dockerClient
292+
.logContainerCmd(containerId)
293+
.withStdOut(true)
294+
.withStdErr(true)
295+
.exec(logCallback)
296+
.awaitCompletion()
297+
println("Container start up logs:\n${logCallback.getLogs()}")
298+
}
299+
295300
private fun getContainerHealthStatus(containerId: String): String {
296301
val healthStatus: String
297302
try {

0 commit comments

Comments
 (0)