From 1a1d6a96f500766f41c85b6d0055c17d7ba6f284 Mon Sep 17 00:00:00 2001 From: Kenfe-Mickael Laventure Date: Thu, 31 Mar 2016 12:04:12 -0700 Subject: [PATCH] Add test for pause/resume commands Signed-off-by: Kenfe-Mickael Laventure --- integration-test/start_test.go | 61 ++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/integration-test/start_test.go b/integration-test/start_test.go index a8081c5..a2312fe 100644 --- a/integration-test/start_test.go +++ b/integration-test/start_test.go @@ -250,3 +250,64 @@ func (cs *ContainerdSuite) TestStartBusyboxTrapUSR1(t *check.C) { t.Assert(c.io.stdoutBuffer.String(), checker.Equals, "booh!") } + +func (cs *ContainerdSuite) TestStartBusyboxTopPauseResume(t *check.C) { + bundleName := "busybox-top" + if err := CreateBusyboxBundle(bundleName, []string{"top"}); err != nil { + t.Fatal(err) + } + + containerId := "top" + c, err := cs.StartContainer(containerId, bundleName) + if err != nil { + t.Fatal(err) + } + + if err := cs.PauseContainer(containerId); err != nil { + t.Fatal(err) + } + + if err := cs.ResumeContainer(containerId); err != nil { + t.Fatal(err) + } + + for _, evt := range []types.Event{ + { + Type: "start-container", + Id: containerId, + Status: 0, + Pid: "", + }, + { + Type: "pause", + Id: containerId, + Status: 0, + Pid: "", + }, + { + Type: "resume", + Id: containerId, + Status: 0, + Pid: "", + }, + } { + ch := c.GetEventsChannel() + select { + case e := <-ch: + evt.Timestamp = e.Timestamp + + t.Assert(*e, checker.Equals, evt) + case <-time.After(2 * time.Second): + t.Fatal("Container took more than 2 seconds to terminate") + } + } + + // check that status is running + containers, err := cs.ListRunningContainers() + if err != nil { + t.Fatal(err) + } + t.Assert(len(containers), checker.Equals, 1) + t.Assert(containers[0].Id, checker.Equals, "top") + t.Assert(containers[0].Status, checker.Equals, "running") +}