From 73383ee755acbdddae64b991a1515893431bba2c Mon Sep 17 00:00:00 2001 From: Piotr Kazmierczak <470696+pkazmierczak@users.noreply.github.com> Date: Thu, 7 Nov 2024 13:35:32 +0100 Subject: [PATCH] e2e: unflake testDockerExecStdin (#24385) --- e2e/allocexec/docker_exec_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/e2e/allocexec/docker_exec_test.go b/e2e/allocexec/docker_exec_test.go index 2956d700d..17c165af4 100644 --- a/e2e/allocexec/docker_exec_test.go +++ b/e2e/allocexec/docker_exec_test.go @@ -7,6 +7,7 @@ import ( "archive/tar" "bytes" "context" + "fmt" "strings" "testing" "time" @@ -27,13 +28,14 @@ func TestDockerAllocExec(t *testing.T) { } func testDockerExecStdin(t *testing.T) { - _, cleanup := jobs3.Submit(t, "./input/sleepytar.hcl") + sub, cleanup := jobs3.Submit(t, "./input/sleepytar.hcl") t.Cleanup(cleanup) client, err := nomadapi.NewClient(nomadapi.DefaultConfig()) must.NoError(t, err) - allocations, _, err := client.Allocations().List(nil) + filter := fmt.Sprintf("JobID == \"%s\"", sub.JobID()) + allocations, _, err := client.Allocations().List(&nomadapi.QueryOptions{Filter: filter}) must.NoError(t, err) must.SliceLen(t, 1, allocations) @@ -85,7 +87,7 @@ func testDockerExecStdin(t *testing.T) { nil, nil, ) - must.NoError(t, err) + must.NoError(t, err, must.Sprintf("error executing command inside the container: %v", err)) must.Zero(t, exitCode) // check the output of tar