integration: deflake TestIssue9103

Fixes: #9334

Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
Wei Fu 2023-11-08 23:35:55 +08:00
parent 5149050d6b
commit dac056fe74

View File

@ -1447,6 +1447,7 @@ func TestIssue9103(t *testing.T) {
for idx, tc := range []struct { for idx, tc := range []struct {
desc string desc string
cntrOpts []NewContainerOpts cntrOpts []NewContainerOpts
bakingFn func(ctx context.Context, t *testing.T, task Task)
expectedStatus ProcessStatus expectedStatus ProcessStatus
}{ }{
{ {
@ -1456,6 +1457,7 @@ func TestIssue9103(t *testing.T) {
withProcessArgs("sleep", "30"), withProcessArgs("sleep", "30"),
), ),
}, },
bakingFn: func(context.Context, *testing.T, Task) {},
expectedStatus: Created, expectedStatus: Created,
}, },
{ {
@ -1471,6 +1473,17 @@ func TestIssue9103(t *testing.T) {
BinaryName: "runc-fp", BinaryName: "runc-fp",
}), }),
}, },
bakingFn: func(ctx context.Context, t *testing.T, task Task) {
waitCh, err := task.Wait(ctx)
require.NoError(t, err)
select {
case <-time.After(30 * time.Second):
t.Fatal("timeout")
case e := <-waitCh:
require.NoError(t, e.Error())
}
},
expectedStatus: Stopped, expectedStatus: Stopped,
}, },
} { } {
@ -1490,6 +1503,8 @@ func TestIssue9103(t *testing.T) {
defer task.Delete(ctx, WithProcessKill) defer task.Delete(ctx, WithProcessKill)
tc.bakingFn(ctx, t, task)
status, err := task.Status(ctx) status, err := task.Status(ctx)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, tc.expectedStatus, status.Status) require.Equal(t, tc.expectedStatus, status.Status)