From 47fc6456827e9424530fa39d58d8d3debcc84b6a Mon Sep 17 00:00:00 2001 From: lifupan Date: Wed, 8 May 2019 12:24:28 +0800 Subject: [PATCH] Integration test task.Delete fix task.Delete() will try to kill the task before delete it, but once the task is killed, the TaskExit event will also tigger another task.Delete() which would conflict with this test task.Delete(). To avoid this conflict, kill the task instead of Delete it, and let TaskExit trigger task.Delete(). Signed-off-by: lifupan --- integration/sandbox_clean_remove_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/integration/sandbox_clean_remove_test.go b/integration/sandbox_clean_remove_test.go index ecfbf1b37..a686a57ee 100644 --- a/integration/sandbox_clean_remove_test.go +++ b/integration/sandbox_clean_remove_test.go @@ -21,6 +21,7 @@ import ( "os" "path/filepath" "strings" + "syscall" "testing" "time" @@ -53,7 +54,9 @@ func TestSandboxCleanRemove(t *testing.T) { require.NoError(t, err) task, err := cntr.Task(ctx, nil) require.NoError(t, err) - _, err = task.Delete(ctx, containerd.WithProcessKill) + // Kill the task with signal SIGKILL, once the task exited, + // the TaskExit event will trigger the task.Delete(). + err = task.Kill(ctx, syscall.SIGKILL, containerd.WithKillAll) require.NoError(t, err) t.Logf("Sandbox state should be NOTREADY")