Add test for killing a long lived exec process
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
parent
7117935db4
commit
a7f27b8fb9
1 changed files with 63 additions and 0 deletions
|
@ -1,6 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/docker/containerd/api/grpc/types"
|
"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"
|
||||||
|
@ -54,3 +57,63 @@ func (cs *ContainerdSuite) TestBusyboxTopExecEcho(t *check.C) {
|
||||||
|
|
||||||
t.Assert(echop.io.stdoutBuffer.String(), checker.Equals, "Ay Caramba!")
|
t.Assert(echop.io.stdoutBuffer.String(), checker.Equals, "Ay Caramba!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cs *ContainerdSuite) TestBusyboxTopExecTop(t *check.C) {
|
||||||
|
bundleName := "busybox-top"
|
||||||
|
if err := CreateBusyboxBundle(bundleName, []string{"top"}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
initp *containerProcess
|
||||||
|
)
|
||||||
|
|
||||||
|
containerId := "top"
|
||||||
|
initp, err = cs.StartContainer(containerId, bundleName)
|
||||||
|
t.Assert(err, checker.Equals, nil)
|
||||||
|
|
||||||
|
execId := "top1"
|
||||||
|
_, err = cs.AddProcessToContainer(initp, execId, "/", []string{"PATH=/usr/bin"}, []string{"top"}, 0, 0)
|
||||||
|
t.Assert(err, checker.Equals, nil)
|
||||||
|
|
||||||
|
for idx, evt := range []types.Event{
|
||||||
|
{
|
||||||
|
Type: "start-container",
|
||||||
|
Id: containerId,
|
||||||
|
Status: 0,
|
||||||
|
Pid: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Type: "start-process",
|
||||||
|
Id: containerId,
|
||||||
|
Status: 0,
|
||||||
|
Pid: execId,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Type: "exit",
|
||||||
|
Id: containerId,
|
||||||
|
Status: 137,
|
||||||
|
Pid: execId,
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
ch := initp.GetEventsChannel()
|
||||||
|
e := <-ch
|
||||||
|
evt.Timestamp = e.Timestamp
|
||||||
|
t.Assert(*e, checker.Equals, evt)
|
||||||
|
if idx == 1 {
|
||||||
|
// Process Started, kill it
|
||||||
|
cs.SignalContainerProcess(containerId, "top1", uint32(syscall.SIGKILL))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Container should still be 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")
|
||||||
|
t.Assert(containers[0].BundlePath, check.Equals, filepath.Join(cs.cwd, GetBundle(bundleName).Path))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue