From 90009c8a31688b6f54791fccb3e043bf448b284f Mon Sep 17 00:00:00 2001 From: Kenfe-Mickael Laventure Date: Mon, 28 Mar 2016 11:29:55 -0700 Subject: [PATCH] Add a test checking a ls container generated events Signed-off-by: Kenfe-Mickael Laventure --- integration-test/start_test.go | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/integration-test/start_test.go b/integration-test/start_test.go index 161ff9f..db4f81f 100644 --- a/integration-test/start_test.go +++ b/integration-test/start_test.go @@ -1,6 +1,9 @@ package main import ( + "time" + + "github.com/docker/containerd/api/grpc/types" "github.com/docker/docker/pkg/integration/checker" "github.com/go-check/check" ) @@ -56,3 +59,40 @@ func (cs *ContainerdSuite) TestStartBusyboxTop(t *check.C) { _, err := cs.StartContainer("top", "busybox-top") t.Assert(err, checker.Equals, nil) } + +func (cs *ContainerdSuite) TestStartBusyboxLsEvents(t *check.C) { + if err := CreateBusyboxBundle("busybox-ls", []string{"ls"}); err != nil { + t.Fatal(err) + } + + containerId := "ls-events" + c, err := cs.StartContainer(containerId, "busybox-ls") + if err != nil { + t.Fatal(err) + } + + for _, evt := range []types.Event{ + { + Type: "start-container", + Id: containerId, + Status: 0, + Pid: "", + }, + { + Type: "exit", + Id: containerId, + Status: 0, + Pid: "init", + }, + } { + 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") + } + } +}