From 4ce124fdab18aa90f4899d15ce2ff0db4ae559a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Pa=C3=9F?= <22845248+mpass99@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:20:42 +0100 Subject: [PATCH] Fix flaky TestNomadStderrFifoIsRemoved that expected only one allocation per job. However, in practice, a job can be rescheduled on multiple allocations. --- tests/e2e/websocket_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/e2e/websocket_test.go b/tests/e2e/websocket_test.go index e2592f2..9b112ad 100644 --- a/tests/e2e/websocket_test.go +++ b/tests/e2e/websocket_test.go @@ -7,6 +7,7 @@ import ( "encoding/json" "fmt" "github.com/gorilla/websocket" + "github.com/hashicorp/nomad/api" "github.com/openHPI/poseidon/internal/nomad" "github.com/openHPI/poseidon/pkg/dto" "github.com/openHPI/poseidon/pkg/logging" @@ -324,8 +325,14 @@ func parseLogFile(t *testing.T, name string, start time.Time, end time.Time) (lo func (s *E2ETestSuite) ListTempDirectory(runnerID string) string { allocListStub, _, err := nomadClient.Jobs().Allocations(runnerID, true, nil) s.Require().NoError(err) - s.Require().Equal(1, len(allocListStub)) - alloc, _, err := nomadClient.Allocations().Info(allocListStub[0].ID, nil) + var runningAllocStub *api.AllocationListStub + for _, stub := range allocListStub { + if stub.ClientStatus == api.AllocClientStatusRunning && stub.DesiredStatus == api.AllocDesiredStatusRun { + runningAllocStub = stub + break + } + } + alloc, _, err := nomadClient.Allocations().Info(runningAllocStub.ID, nil) s.Require().NoError(err) var stdout, stderr bytes.Buffer