From a12e0c5d9b9fcd84d9d3cee1c2f371c6dd9c1e0c Mon Sep 17 00:00:00 2001 From: Swagat Bora Date: Wed, 25 Sep 2024 22:18:57 +0000 Subject: [PATCH] add logs to debug flaky test Signed-off-by: Swagat Bora --- runtime/service_integ_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/runtime/service_integ_test.go b/runtime/service_integ_test.go index 122d9c9a..ee18dc59 100644 --- a/runtime/service_integ_test.go +++ b/runtime/service_integ_test.go @@ -946,13 +946,17 @@ func startAndWaitTask(ctx context.Context, t testing.TB, c containerd.Container) assert.NoError(t, exitStatus.Error(), "failed to retrieve exitStatus") assert.Equal(t, uint32(0), exitStatus.ExitCode()) + // Print stderr to help with debugging + stderrOutput := stderr.String() + if len(stderrOutput) != 0 { + fmt.Printf("stderr output from container %s: %s", c.ID(), stderrOutput) + } + status, err := task.Delete(ctx) assert.NoErrorf(t, err, "failed to delete task %q after exit", c.ID()) if status != nil { assert.NoError(t, status.Error()) } - - assert.Equal(t, "", stderr.String()) case <-ctx.Done(): require.Fail(t, "context cancelled", "context cancelled while waiting for container %s to exit, err: %v", c.ID(), ctx.Err())