From 36e6a2c5e148e98413dd507014d922f4e7d7c792 Mon Sep 17 00:00:00 2001 From: "user.email" Date: Sat, 24 Oct 2026 11:32:23 -0700 Subject: [PATCH] test: dump trino container state and logs when it exits before ready When the Trino container dies during startup, waitForTrino only reported the docker exec error ("container is not running"), which gives no hint whether the JVM was OOM-killed, the image broke, or the config is bad. Capture docker inspect exit state and the container logs in the failure message so runner-side flakes are diagnosable from the test output alone. --- .../catalog_trino/trino_catalog_test.go | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/test/s3tables/catalog_trino/trino_catalog_test.go b/test/s3tables/catalog_trino/trino_catalog_test.go index ddfc60fdeb..ebf9168864 100644 --- a/test/s3tables/catalog_trino/trino_catalog_test.go +++ b/test/s3tables/catalog_trino/trino_catalog_test.go @@ -484,7 +484,7 @@ func waitForTrino(t *testing.T, containerName string, timeout time.Duration) { deadline := time.Now().Add(timeout) var lastOutput []byte - retryCount := 0 + containerDead := false for time.Now().Before(deadline) { // Try system catalog query as a readiness check cmd := exec.Command("docker", "exec", containerName, @@ -498,9 +498,9 @@ func waitForTrino(t *testing.T, containerName string, timeout time.Duration) { outputStr := string(output) if strings.Contains(outputStr, "No such container") || strings.Contains(outputStr, "is not running") { + containerDead = true break } - retryCount++ } time.Sleep(1 * time.Second) } @@ -514,9 +514,25 @@ func waitForTrino(t *testing.T, containerName string, timeout time.Duration) { return } + if containerDead { + t.Fatalf("Trino container %s exited before becoming ready\n%s", containerName, trinoContainerDiagnostics(containerName)) + } t.Fatalf("Timed out waiting for Trino to be ready\nLast output:\n%s", string(lastOutput)) } +func trinoContainerDiagnostics(containerName string) string { + var b strings.Builder + if out, err := exec.Command("docker", "inspect", "-f", + "status={{.State.Status}} exitCode={{.State.ExitCode}} oomKilled={{.State.OOMKilled}} error={{.State.Error}}", + containerName).CombinedOutput(); err == nil { + fmt.Fprintf(&b, "docker inspect: %s\n", strings.TrimSpace(string(out))) + } + if out, err := exec.Command("docker", "logs", "--tail", "80", containerName).CombinedOutput(); err == nil { + fmt.Fprintf(&b, "docker logs:\n%s", string(out)) + } + return b.String() +} + func runTrinoSQL(t *testing.T, containerName, sql string) string { t.Helper()