Skip to content

Commit acb81bb

Browse files
author
Kazuyoshi Kato
committed
integration: fix TestContainerPids
task.Pids returns the task's processes, but the order is not guaranteed. Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent a5eccab commit acb81bb

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

integration/client/container_test.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,9 @@ func TestContainerPids(t *testing.T) {
443443
t.Fatal(err)
444444
}
445445

446-
pid := task.Pid()
447-
if pid < 1 {
448-
t.Errorf("invalid task pid %d", pid)
446+
taskPid := task.Pid()
447+
if taskPid < 1 {
448+
t.Errorf("invalid task pid %d", taskPid)
449449
}
450450
processes, err := task.Pids(ctx)
451451
switch runtime.GOOS {
@@ -459,12 +459,17 @@ func TestContainerPids(t *testing.T) {
459459
if l := len(processes); l != 2 {
460460
t.Errorf("expected 2 process but received %d", l)
461461
}
462-
if len(processes) > 0 {
463-
actual := processes[0].Pid
464-
if pid != actual {
465-
t.Errorf("expected pid %d but received %d. processes = %+v", pid, actual, processes)
462+
463+
var found bool
464+
for _, p := range processes {
465+
if p.Pid == taskPid {
466+
found = true
467+
break
466468
}
467469
}
470+
if !found {
471+
t.Errorf("pid %d must be in %+v", taskPid, processes)
472+
}
468473
}
469474
if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
470475
select {

0 commit comments

Comments
 (0)