Add a test checking a ls container generated events

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2016-03-28 11:29:55 -07:00
parent 3481996e9d
commit 90009c8a31

View file

@ -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")
}
}
}