mirror of
https://github.com/docker/compose.git
synced 2025-07-22 21:24:38 +02:00
Fix race in TestAttachRestart : wait for logs to appear rather than have a fixed TTL for the application
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
parent
d99a5101a2
commit
6c5bd67c19
@ -22,7 +22,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -192,15 +191,16 @@ func TestDownComposefileInParentFolder(t *testing.T) {
|
|||||||
func TestAttachRestart(t *testing.T) {
|
func TestAttachRestart(t *testing.T) {
|
||||||
c := NewParallelE2eCLI(t, binDir)
|
c := NewParallelE2eCLI(t, binDir)
|
||||||
|
|
||||||
res := c.RunDockerOrExitError("compose", "--ansi=never", "--project-directory", "./fixtures/attach-restart", "up")
|
cmd := c.NewDockerCmd("compose", "--ansi=never", "--project-directory", "./fixtures/attach-restart", "up")
|
||||||
|
res := icmd.StartCmd(cmd)
|
||||||
defer c.RunDockerOrExitError("compose", "-p", "attach-restart", "down")
|
defer c.RunDockerOrExitError("compose", "-p", "attach-restart", "down")
|
||||||
output := res.Stdout()
|
|
||||||
|
|
||||||
exitRegex := regexp.MustCompile("another_1 exited with code 1")
|
c.WaitForCondition(func() (bool, string) {
|
||||||
assert.Equal(t, len(exitRegex.FindAllStringIndex(output, -1)), 3, res.Combined())
|
debug := res.Combined()
|
||||||
|
return strings.Count(res.Stdout(), "another_1 exited with code 1") == 3, fmt.Sprintf("'another_1 exited with code 1' not found 3 times in : \n%s\n", debug)
|
||||||
|
}, 2*time.Minute, 2*time.Second)
|
||||||
|
|
||||||
execRegex := regexp.MustCompile(`another_1 \| world`)
|
assert.Equal(t, strings.Count(res.Stdout(), "another_1 | world"), 3, res.Combined())
|
||||||
assert.Equal(t, len(execRegex.FindAllStringIndex(output, -1)), 3, res.Combined())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInitContainer(t *testing.T) {
|
func TestInitContainer(t *testing.T) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
simple:
|
simple:
|
||||||
image: alpine
|
image: alpine
|
||||||
command: sh -c "sleep 5"
|
command: sh -c "sleep infinity"
|
||||||
another:
|
another:
|
||||||
image: alpine
|
image: alpine
|
||||||
command: sh -c "sleep 0.1 && echo world && /bin/false"
|
command: sh -c "sleep 0.1 && echo world && /bin/false"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user