From c1a82aa713a3418b9206b0549fbef2a35ae3155e Mon Sep 17 00:00:00 2001 From: Tom Manville Date: Mon, 28 Oct 2024 09:09:28 -0700 Subject: [PATCH] Fix TestParallelStdout: Wait for process to terminate (#3200) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- pkg/kanx/kanx_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/kanx/kanx_test.go b/pkg/kanx/kanx_test.go index f4d4604f49..559e80fa49 100644 --- a/pkg/kanx/kanx_test.go +++ b/pkg/kanx/kanx_test.go @@ -12,6 +12,8 @@ import ( "google.golang.org/grpc" . "gopkg.in/check.v1" + + "github.com/kanisterio/kanister/pkg/poll" ) // Hook up gocheck into the "go test" runner. @@ -257,9 +259,13 @@ func (s *KanXSuite) TestParallelStdout(c *C) { err = sp.cmd.Process.Kill() c.Assert(err, IsNil) - ps, err = ListProcesses(ctx, addr) - c.Assert(err, IsNil) - c.Assert(ps, HasLen, 1) + _ = poll.Wait(ctx, func(context.Context) (bool, error) { + ps, err = ListProcesses(ctx, addr) + c.Assert(err, IsNil) + c.Assert(ps, HasLen, 1) + return ps[0].GetState() != ProcessState_PROCESS_STATE_RUNNING, nil + }) + c.Assert(ps[0].GetPid(), Equals, p.GetPid()) c.Assert(ps[0].GetState(), Equals, ProcessState_PROCESS_STATE_FAILED) c.Assert(ps[0].GetExitErr(), Equals, "signal: killed")