mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Test for following logs for stopped container
Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
This commit is contained in:
parent
badf8247af
commit
f04ef96e07
1 changed files with 32 additions and 0 deletions
|
@ -213,3 +213,35 @@ func TestLogsTail(t *testing.T) {
|
|||
deleteContainer(cleanedContainerID)
|
||||
logDone("logs - logs tail")
|
||||
}
|
||||
|
||||
func TestLogsFollowStopped(t *testing.T) {
|
||||
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "echo", "hello")
|
||||
|
||||
out, _, _, err := runCommandWithStdoutStderr(runCmd)
|
||||
errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
|
||||
|
||||
cleanedContainerID := stripTrailingCharacters(out)
|
||||
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
||||
|
||||
logsCmd := exec.Command(dockerBinary, "logs", "-f", cleanedContainerID)
|
||||
if err := logsCmd.Start(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
c := make(chan struct{})
|
||||
go func() {
|
||||
if err := logsCmd.Wait(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
close(c)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-c:
|
||||
case <-time.After(1 * time.Second):
|
||||
t.Fatal("Following logs is hanged")
|
||||
}
|
||||
|
||||
deleteContainer(cleanedContainerID)
|
||||
logDone("logs - logs follow stopped container")
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue