mirror of
https://github.com/docker/compose.git
synced 2025-07-25 22:54:54 +02:00
e2e test for recreate volume
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
977530c22a
commit
a20b69ac5b
@ -6,5 +6,5 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
my_vol:
|
my_vol:
|
||||||
external: true
|
labels:
|
||||||
name: test_external_volume
|
foo: bar
|
||||||
|
@ -6,5 +6,5 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
my_vol:
|
my_vol:
|
||||||
external: true
|
labels:
|
||||||
name: test_external_volume_2
|
foo: zot
|
||||||
|
10
pkg/e2e/fixtures/switch-volumes/compose.yaml
Normal file
10
pkg/e2e/fixtures/switch-volumes/compose.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: alpine
|
||||||
|
volumes:
|
||||||
|
- my_vol:/my_vol
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
my_vol:
|
||||||
|
external: true
|
||||||
|
name: test_external_volume
|
10
pkg/e2e/fixtures/switch-volumes/compose2.yaml
Normal file
10
pkg/e2e/fixtures/switch-volumes/compose2.yaml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
services:
|
||||||
|
app:
|
||||||
|
image: alpine
|
||||||
|
volumes:
|
||||||
|
- my_vol:/my_vol
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
my_vol:
|
||||||
|
external: true
|
||||||
|
name: test_external_volume_2
|
@ -123,9 +123,9 @@ func TestProjectVolumeBind(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUpRecreateVolumes(t *testing.T) {
|
func TestUpSwitchVolumes(t *testing.T) {
|
||||||
c := NewCLI(t)
|
c := NewCLI(t)
|
||||||
const projectName = "compose-e2e-recreate-volumes"
|
const projectName = "compose-e2e-switch-volumes"
|
||||||
t.Cleanup(func() {
|
t.Cleanup(func() {
|
||||||
c.cleanupWithDown(t, projectName)
|
c.cleanupWithDown(t, projectName)
|
||||||
c.RunDockerCmd(t, "volume", "rm", "-f", "test_external_volume")
|
c.RunDockerCmd(t, "volume", "rm", "-f", "test_external_volume")
|
||||||
@ -135,12 +135,29 @@ func TestUpRecreateVolumes(t *testing.T) {
|
|||||||
c.RunDockerCmd(t, "volume", "create", "test_external_volume")
|
c.RunDockerCmd(t, "volume", "create", "test_external_volume")
|
||||||
c.RunDockerCmd(t, "volume", "create", "test_external_volume_2")
|
c.RunDockerCmd(t, "volume", "create", "test_external_volume_2")
|
||||||
|
|
||||||
c.RunDockerComposeCmd(t, "-f", "./fixtures/recreate-volumes/compose.yaml", "--project-name", projectName, "up", "-d")
|
c.RunDockerComposeCmd(t, "-f", "./fixtures/switch-volumes/compose.yaml", "--project-name", projectName, "up", "-d")
|
||||||
|
|
||||||
res := c.RunDockerCmd(t, "inspect", fmt.Sprintf("%s-app-1", projectName), "-f", "{{ (index .Mounts 0).Name }}")
|
res := c.RunDockerCmd(t, "inspect", fmt.Sprintf("%s-app-1", projectName), "-f", "{{ (index .Mounts 0).Name }}")
|
||||||
res.Assert(t, icmd.Expected{Out: "test_external_volume"})
|
res.Assert(t, icmd.Expected{Out: "test_external_volume"})
|
||||||
|
|
||||||
c.RunDockerComposeCmd(t, "-f", "./fixtures/recreate-volumes/compose2.yaml", "--project-name", projectName, "up", "-d")
|
c.RunDockerComposeCmd(t, "-f", "./fixtures/switch-volumes/compose2.yaml", "--project-name", projectName, "up", "-d")
|
||||||
res = c.RunDockerCmd(t, "inspect", fmt.Sprintf("%s-app-1", projectName), "-f", "{{ (index .Mounts 0).Name }}")
|
res = c.RunDockerCmd(t, "inspect", fmt.Sprintf("%s-app-1", projectName), "-f", "{{ (index .Mounts 0).Name }}")
|
||||||
res.Assert(t, icmd.Expected{Out: "test_external_volume_2"})
|
res.Assert(t, icmd.Expected{Out: "test_external_volume_2"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUpRecreateVolumes(t *testing.T) {
|
||||||
|
c := NewCLI(t)
|
||||||
|
const projectName = "compose-e2e-recreate-volumes"
|
||||||
|
t.Cleanup(func() {
|
||||||
|
c.cleanupWithDown(t, projectName)
|
||||||
|
})
|
||||||
|
|
||||||
|
c.RunDockerComposeCmd(t, "-f", "./fixtures/recreate-volumes/compose.yaml", "--project-name", projectName, "up", "-d")
|
||||||
|
|
||||||
|
res := c.RunDockerCmd(t, "volume", "inspect", fmt.Sprintf("%s_my_vol", projectName), "-f", "{{ index .Labels \"foo\" }}")
|
||||||
|
res.Assert(t, icmd.Expected{Out: "bar"})
|
||||||
|
|
||||||
|
c.RunDockerComposeCmd(t, "-f", "./fixtures/recreate-volumes/compose2.yaml", "--project-name", projectName, "up", "-d", "-y")
|
||||||
|
res = c.RunDockerCmd(t, "volume", "inspect", fmt.Sprintf("%s_my_vol", projectName), "-f", "{{ index .Labels \"foo\" }}")
|
||||||
|
res.Assert(t, icmd.Expected{Out: "zot"})
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user