Merge pull request #10320 from milas/e2e-win-pause

test: tweak pause test to try and prevent failures in Windows CI
This commit is contained in:
Guillaume Lours 2023-03-01 10:36:11 +01:00 committed by GitHub
commit a99a0b50ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View File

@ -2,8 +2,16 @@ services:
a: a:
image: nginx:alpine image: nginx:alpine
ports: [80] ports: [80]
healthcheck:
test: wget --spider -S -T1 http://localhost:80
interval: 1s
timeout: 1s
b: b:
image: nginx:alpine image: nginx:alpine
ports: [80] ports: [80]
depends_on: depends_on:
- a - a
healthcheck:
test: wget --spider -S -T1 http://localhost:80
interval: 1s
timeout: 1s

View File

@ -103,7 +103,7 @@ func NewCLI(t testing.TB, opts ...CLIOption) *CLI {
for _, opt := range opts { for _, opt := range opts {
opt(c) opt(c)
} }
t.Log(c.RunDockerComposeCmdNoCheck(t, "version").Combined()) c.RunDockerComposeCmdNoCheck(t, "version")
return c return c
} }
@ -305,7 +305,10 @@ func (c *CLI) RunDockerComposeCmd(t testing.TB, args ...string) *icmd.Result {
// RunDockerComposeCmdNoCheck runs a docker compose command, don't presume of any expectation and returns a result // RunDockerComposeCmdNoCheck runs a docker compose command, don't presume of any expectation and returns a result
func (c *CLI) RunDockerComposeCmdNoCheck(t testing.TB, args ...string) *icmd.Result { func (c *CLI) RunDockerComposeCmdNoCheck(t testing.TB, args ...string) *icmd.Result {
t.Helper() t.Helper()
return icmd.RunCmd(c.NewDockerComposeCmd(t, args...)) cmd := c.NewDockerComposeCmd(t, args...)
cmd.Stdout = os.Stdout
t.Logf("Running command: %s", strings.Join(cmd.Command, " "))
return icmd.RunCmd(cmd)
} }
// NewDockerComposeCmd creates a command object for Compose, either in plugin // NewDockerComposeCmd creates a command object for Compose, either in plugin

View File

@ -101,7 +101,7 @@ func TestPauseServiceAlreadyPaused(t *testing.T) {
t.Cleanup(cleanup) t.Cleanup(cleanup)
// launch a and wait for it to come up // launch a and wait for it to come up
cli.RunDockerComposeCmd(t, "up", "-d", "a") cli.RunDockerComposeCmd(t, "up", "--wait", "a")
HTTPGetWithRetry(t, urlForService(t, cli, "a", 80), http.StatusOK, 50*time.Millisecond, 10*time.Second) HTTPGetWithRetry(t, urlForService(t, cli, "a", 80), http.StatusOK, 50*time.Millisecond, 10*time.Second)
// pause a twice - first time should pass, second time fail // pause a twice - first time should pass, second time fail