From a6bfb90545d183861736c20da8c4211922ea14bf Mon Sep 17 00:00:00 2001 From: Tom Manville Date: Thu, 24 Oct 2024 21:24:59 -0700 Subject: [PATCH] Fix TestParallelStdout: Wait for process to terminate --- pkg/kanx/kanx_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkg/kanx/kanx_test.go b/pkg/kanx/kanx_test.go index f4d4604f49..87de4fd8c1 100644 --- a/pkg/kanx/kanx_test.go +++ b/pkg/kanx/kanx_test.go @@ -10,6 +10,7 @@ import ( "testing" "time" + "github.com/kanisterio/kanister/pkg/poll" "google.golang.org/grpc" . "gopkg.in/check.v1" ) @@ -257,9 +258,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")