mirror of
https://github.com/docker/compose.git
synced 2025-07-25 06:34:35 +02:00
e2e test covering multi-service rebuild with common resources
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
ed10804e0f
commit
d04b3f48e4
@ -162,7 +162,7 @@ func TestLocalComposeRun(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("--quiet-pull", func(t *testing.T) {
|
t.Run("--quiet-pull", func(t *testing.T) {
|
||||||
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/quiet-pull.yaml", "down", "--rmi", "all")
|
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/quiet-pull.yaml", "down", "--remove-orphans", "--rmi", "all")
|
||||||
res.Assert(t, icmd.Success)
|
res.Assert(t, icmd.Success)
|
||||||
|
|
||||||
res = c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/quiet-pull.yaml", "run", "--quiet-pull", "backend")
|
res = c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/quiet-pull.yaml", "run", "--quiet-pull", "backend")
|
||||||
@ -171,12 +171,11 @@ func TestLocalComposeRun(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
t.Run("--pull", func(t *testing.T) {
|
t.Run("--pull", func(t *testing.T) {
|
||||||
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/pull.yaml", "down", "--rmi", "all")
|
res := c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/pull.yaml", "down", "--remove-orphans", "--rmi", "all")
|
||||||
res.Assert(t, icmd.Success)
|
res.Assert(t, icmd.Success)
|
||||||
|
|
||||||
res = c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/pull.yaml", "run", "--pull", "always", "backend")
|
res = c.RunDockerComposeCmd(t, "-f", "./fixtures/run-test/pull.yaml", "run", "--pull", "always", "backend")
|
||||||
assert.Assert(t, strings.Contains(res.Combined(), "backend Pulling"), res.Combined())
|
assert.Assert(t, strings.Contains(res.Combined(), "backend Pulling"), res.Combined())
|
||||||
assert.Assert(t, strings.Contains(res.Combined(), "Download complete"), res.Combined())
|
|
||||||
assert.Assert(t, strings.Contains(res.Combined(), "backend Pulled"), res.Combined())
|
assert.Assert(t, strings.Contains(res.Combined(), "backend Pulled"), res.Combined())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
31
pkg/e2e/fixtures/watch/rebuild.yaml
Normal file
31
pkg/e2e/fixtures/watch/rebuild.yaml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
services:
|
||||||
|
a:
|
||||||
|
build:
|
||||||
|
dockerfile_inline: |
|
||||||
|
FROM nginx
|
||||||
|
RUN mkdir /data
|
||||||
|
COPY test /data/a
|
||||||
|
develop:
|
||||||
|
watch:
|
||||||
|
- path: test
|
||||||
|
action: rebuild
|
||||||
|
b:
|
||||||
|
build:
|
||||||
|
dockerfile_inline: |
|
||||||
|
FROM nginx
|
||||||
|
RUN mkdir /data
|
||||||
|
COPY test /data/b
|
||||||
|
develop:
|
||||||
|
watch:
|
||||||
|
- path: test
|
||||||
|
action: rebuild
|
||||||
|
c:
|
||||||
|
build:
|
||||||
|
dockerfile_inline: |
|
||||||
|
FROM nginx
|
||||||
|
RUN mkdir /data
|
||||||
|
COPY test /data/c
|
||||||
|
develop:
|
||||||
|
watch:
|
||||||
|
- path: test
|
||||||
|
action: rebuild
|
@ -322,3 +322,49 @@ func TestWatchExec(t *testing.T) {
|
|||||||
})
|
})
|
||||||
c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "kill", "-s", "9")
|
c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "kill", "-s", "9")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWatchMultiServices(t *testing.T) {
|
||||||
|
c := NewCLI(t)
|
||||||
|
const projectName = "test_watch_rebuild"
|
||||||
|
|
||||||
|
defer c.cleanupWithDown(t, projectName)
|
||||||
|
|
||||||
|
tmpdir := t.TempDir()
|
||||||
|
composeFilePath := filepath.Join(tmpdir, "compose.yaml")
|
||||||
|
CopyFile(t, filepath.Join("fixtures", "watch", "rebuild.yaml"), composeFilePath)
|
||||||
|
|
||||||
|
testFile := filepath.Join(tmpdir, "test")
|
||||||
|
require.NoError(t, os.WriteFile(testFile, []byte("test"), 0o600))
|
||||||
|
|
||||||
|
cmd := c.NewDockerComposeCmd(t, "-p", projectName, "-f", composeFilePath, "up", "--watch")
|
||||||
|
buffer := bytes.NewBuffer(nil)
|
||||||
|
cmd.Stdout = buffer
|
||||||
|
watch := icmd.StartCmd(cmd)
|
||||||
|
|
||||||
|
poll.WaitOn(t, func(l poll.LogT) poll.Result {
|
||||||
|
if strings.Contains(watch.Stdout(), "Attaching to ") {
|
||||||
|
return poll.Success()
|
||||||
|
}
|
||||||
|
return poll.Continue("%v", watch.Stdout())
|
||||||
|
})
|
||||||
|
|
||||||
|
waitRebuild := func(service string, expected string) {
|
||||||
|
poll.WaitOn(t, func(l poll.LogT) poll.Result {
|
||||||
|
cat := c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "exec", service, "cat", "/data/"+service)
|
||||||
|
if strings.Contains(cat.Stdout(), expected) {
|
||||||
|
return poll.Success()
|
||||||
|
}
|
||||||
|
return poll.Continue("%v", cat.Combined())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
waitRebuild("a", "test")
|
||||||
|
waitRebuild("b", "test")
|
||||||
|
waitRebuild("c", "test")
|
||||||
|
|
||||||
|
require.NoError(t, os.WriteFile(testFile, []byte("updated"), 0o600))
|
||||||
|
waitRebuild("a", "updated")
|
||||||
|
waitRebuild("b", "updated")
|
||||||
|
waitRebuild("c", "updated")
|
||||||
|
|
||||||
|
c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "kill", "-s", "9")
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user