Improve TestKillDifferentUser to prevent timeout on buildbot
This commit is contained in:
parent
6178dc7f1b
commit
db9d68c3e4
|
@ -401,9 +401,11 @@ func TestOutput(t *testing.T) {
|
||||||
func TestKillDifferentUser(t *testing.T) {
|
func TestKillDifferentUser(t *testing.T) {
|
||||||
runtime := mkRuntime(t)
|
runtime := mkRuntime(t)
|
||||||
defer nuke(runtime)
|
defer nuke(runtime)
|
||||||
|
|
||||||
container, err := NewBuilder(runtime).Create(&Config{
|
container, err := NewBuilder(runtime).Create(&Config{
|
||||||
Image: GetTestImage(runtime).ID,
|
Image: GetTestImage(runtime).ID,
|
||||||
Cmd: []string{"tail", "-f", "/etc/resolv.conf"},
|
Cmd: []string{"cat"},
|
||||||
|
OpenStdin: true,
|
||||||
User: "daemon",
|
User: "daemon",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -411,12 +413,12 @@ func TestKillDifferentUser(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer runtime.Destroy(container)
|
defer runtime.Destroy(container)
|
||||||
|
defer container.stdin.Close()
|
||||||
|
|
||||||
if container.State.Running {
|
if container.State.Running {
|
||||||
t.Errorf("Container shouldn't be running")
|
t.Errorf("Container shouldn't be running")
|
||||||
}
|
}
|
||||||
hostConfig := &HostConfig{}
|
if err := container.Start(&HostConfig{}); err != nil {
|
||||||
if err := container.Start(hostConfig); err != nil {
|
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,8 +428,13 @@ func TestKillDifferentUser(t *testing.T) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Even if the state is running, lets give some time to lxc to spawn the process
|
setTimeout(t, "read/write assertion timed out", 2*time.Second, func() {
|
||||||
container.WaitTimeout(500 * time.Millisecond)
|
out, _ := container.StdoutPipe()
|
||||||
|
in, _ := container.StdinPipe()
|
||||||
|
if err := assertPipe("hello\n", "hello", out, in, 15); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if err := container.Kill(); err != nil {
|
if err := container.Kill(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|
Loading…
Reference in New Issue