Add integration test.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2018-10-09 23:13:48 -07:00
parent 1f1e92e4a4
commit 84775d2c10
5 changed files with 156 additions and 30 deletions

View File

@@ -19,7 +19,6 @@ package integration
import (
"sort"
"testing"
"time"
"github.com/containerd/containerd"
"github.com/stretchr/testify/assert"
@@ -140,27 +139,8 @@ func TestContainerdRestart(t *testing.T) {
imagesBeforeRestart, err := imageService.ListImages(nil)
assert.NoError(t, err)
t.Logf("Kill containerd")
require.NoError(t, KillProcess("containerd"))
defer func() {
assert.NoError(t, Eventually(func() (bool, error) {
return ConnectDaemons() == nil, nil
}, time.Second, 30*time.Second), "make sure containerd is running before test finish")
}()
t.Logf("Wait until containerd is killed")
require.NoError(t, Eventually(func() (bool, error) {
pid, err := PidOf("containerd")
if err != nil {
return false, err
}
return pid == 0, nil
}, time.Second, 30*time.Second), "wait for containerd to be killed")
t.Logf("Wait until containerd is restarted")
require.NoError(t, Eventually(func() (bool, error) {
return ConnectDaemons() == nil, nil
}, time.Second, 30*time.Second), "wait for containerd to be restarted")
t.Logf("Restart containerd")
RestartContainerd(t)
t.Logf("Check sandbox and container state after restart")
loadedSandboxes, err := runtimeService.ListPodSandbox(&runtime.PodSandboxFilter{})