Merge pull request #9349 from fuweid/deflaky-TestIssue9103

integration: deflake TestIssue9103
This commit is contained in:
Phil Estes 2023-11-08 17:58:08 +00:00 committed by GitHub
commit c2b39b139e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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)