1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Update TestPsShowMounts to also test bind mounts

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2016-03-16 16:15:04 -07:00
parent 8451a08ed5
commit cdd7fddfec

View file

@ -764,22 +764,40 @@ func (s *DockerSuite) TestPsShowMounts(c *check.C) {
mp := prefix + slash + "test"
dockerCmd(c, "volume", "create", "--name", "ps-volume-test")
// volume mount containers
runSleepingContainer(c, "--name=volume-test-1", "--volume", "ps-volume-test:"+mp)
c.Assert(waitRun("volume-test-1"), checker.IsNil)
runSleepingContainer(c, "--name=volume-test-2", "--volume", mp)
c.Assert(waitRun("volume-test-2"), checker.IsNil)
// bind mount container
var bindMountSource string
var bindMountDestination string
if DaemonIsWindows.Condition() {
bindMountSource = "c:\\"
bindMountDestination = "c:\\t"
} else {
bindMountSource = "/tmp"
bindMountDestination = "/t"
}
runSleepingContainer(c, "--name=bind-mount-test", "-v", bindMountSource+":"+bindMountDestination)
c.Assert(waitRun("bind-mount-test"), checker.IsNil)
out, _ := dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}")
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
c.Assert(lines, checker.HasLen, 2)
c.Assert(lines, checker.HasLen, 3)
fields := strings.Fields(lines[0])
c.Assert(fields, checker.HasLen, 2)
c.Assert(fields[0], checker.Equals, "bind-mount-test")
c.Assert(fields[1], checker.Equals, bindMountSource)
fields = strings.Fields(lines[1])
c.Assert(fields, checker.HasLen, 2)
annonymounsVolumeID := fields[1]
fields = strings.Fields(lines[1])
fields = strings.Fields(lines[2])
c.Assert(fields[1], checker.Equals, "ps-volume-test")
// filter by volume name
@ -806,6 +824,28 @@ func (s *DockerSuite) TestPsShowMounts(c *check.C) {
fields = strings.Fields(lines[1])
c.Assert(fields[1], checker.Equals, "ps-volume-test")
// filter by bind mount source
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+bindMountSource)
lines = strings.Split(strings.TrimSpace(string(out)), "\n")
c.Assert(lines, checker.HasLen, 1)
fields = strings.Fields(lines[0])
c.Assert(fields, checker.HasLen, 2)
c.Assert(fields[0], checker.Equals, "bind-mount-test")
c.Assert(fields[1], checker.Equals, bindMountSource)
// filter by bind mount destination
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+bindMountDestination)
lines = strings.Split(strings.TrimSpace(string(out)), "\n")
c.Assert(lines, checker.HasLen, 1)
fields = strings.Fields(lines[0])
c.Assert(fields, checker.HasLen, 2)
c.Assert(fields[0], checker.Equals, "bind-mount-test")
c.Assert(fields[1], checker.Equals, bindMountSource)
// empty results filtering by unknown mount point
out, _ = dockerCmd(c, "ps", "--format", "{{.Names}} {{.Mounts}}", "--filter", "volume="+prefix+slash+"this-path-was-never-mounted")
c.Assert(strings.TrimSpace(string(out)), checker.HasLen, 0)