mirror of
https://github.com/docker/compose.git
synced 2026-08-27 03:45:29 +00:00
No need to filter services again in backend, filter is done by cli command. Added e2e test, labels one-off and slug
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
parent
370781e95e
commit
b289138ca9
6 changed files with 116 additions and 131 deletions
|
|
@ -103,6 +103,57 @@ func TestLocalComposeUp(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestLocalComposeRun(t *testing.T) {
|
||||
c := NewParallelE2eCLI(t, binDir)
|
||||
|
||||
t.Run("compose run", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "run", "-f", "./fixtures/run-test/docker-compose.yml", "back")
|
||||
res.Assert(t, icmd.Expected{Out: "Hello there!!"})
|
||||
})
|
||||
|
||||
t.Run("check run container exited", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("ps", "--all")
|
||||
lines := Lines(res.Stdout())
|
||||
var runContainerID string
|
||||
for _, line := range lines {
|
||||
fields := strings.Fields(line)
|
||||
containerID := fields[len(fields)-1]
|
||||
assert.Assert(t, !strings.HasPrefix(containerID, "run-test_front"))
|
||||
if strings.HasPrefix(containerID, "run-test_back") {
|
||||
//only the one-off container for back service
|
||||
assert.Assert(t, strings.HasPrefix(containerID, "run-test_back_run_"), containerID)
|
||||
runContainerID = containerID
|
||||
assert.Assert(t, strings.Contains(line, "Exited"), line)
|
||||
}
|
||||
if strings.HasPrefix(containerID, "run-test_db_1") {
|
||||
assert.Assert(t, strings.Contains(line, "Up"), line)
|
||||
}
|
||||
}
|
||||
assert.Assert(t, runContainerID != "")
|
||||
res = c.RunDockerCmd("inspect", runContainerID)
|
||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.container-number": "1"`})
|
||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.project": "run-test"`})
|
||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.oneoff": "True",`})
|
||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.slug": "`})
|
||||
})
|
||||
|
||||
t.Run("compose run --rm", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "run", "-f", "./fixtures/run-test/docker-compose.yml", "--rm", "back")
|
||||
res.Assert(t, icmd.Expected{Out: "Hello there!!"})
|
||||
})
|
||||
|
||||
t.Run("check run container removed", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("ps", "--all")
|
||||
assert.Assert(t, strings.Contains(res.Stdout(), "run-test_back"), res.Stdout())
|
||||
})
|
||||
|
||||
t.Run("down", func(t *testing.T) {
|
||||
_ = c.RunDockerCmd("compose", "down", "-f", "./fixtures/run-test/docker-compose.yml")
|
||||
res := c.RunDockerCmd("ps", "--all")
|
||||
assert.Assert(t, !strings.Contains(res.Stdout(), "run-test"), res.Stdout())
|
||||
})
|
||||
}
|
||||
|
||||
func TestLocalComposeBuild(t *testing.T) {
|
||||
c := NewParallelE2eCLI(t, binDir)
|
||||
|
||||
|
|
|
|||
24
tests/compose-e2e/fixtures/run-test/docker-compose.yml
Normal file
24
tests/compose-e2e/fixtures/run-test/docker-compose.yml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
version: '3.8'
|
||||
services:
|
||||
back:
|
||||
image: alpine
|
||||
command: echo "Hello there!!"
|
||||
depends_on:
|
||||
- db
|
||||
networks:
|
||||
- backnet
|
||||
db:
|
||||
image: nginx
|
||||
networks:
|
||||
- backnet
|
||||
volumes:
|
||||
- data:/test
|
||||
front:
|
||||
image: nginx
|
||||
networks:
|
||||
- frontnet
|
||||
networks:
|
||||
frontnet: {}
|
||||
backnet: {}
|
||||
volumes:
|
||||
data: {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue