Add a test checking a ls container generated events
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
parent
3481996e9d
commit
90009c8a31
1 changed files with 40 additions and 0 deletions
|
@ -1,6 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/docker/containerd/api/grpc/types"
|
||||||
"github.com/docker/docker/pkg/integration/checker"
|
"github.com/docker/docker/pkg/integration/checker"
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
)
|
)
|
||||||
|
@ -56,3 +59,40 @@ func (cs *ContainerdSuite) TestStartBusyboxTop(t *check.C) {
|
||||||
_, err := cs.StartContainer("top", "busybox-top")
|
_, err := cs.StartContainer("top", "busybox-top")
|
||||||
t.Assert(err, checker.Equals, nil)
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue