Merge pull request #24646 from anusha-ragunathan/use-volume-plugins

Remove use of exec-root in plugins due to socket pathname limits.
Upstream-commit: ba6adc5f46ae1e979551998a02e16e3396a77402
Component: engine
This commit is contained in:
Arnaud Porterie
2016-07-18 16:28:22 +00:00
committed by GitHub
4 changed files with 58 additions and 14 deletions
@@ -3,11 +3,14 @@
package main
import (
"github.com/docker/docker/pkg/integration/checker"
"github.com/go-check/check"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
"github.com/docker/docker/pkg/integration/checker"
"github.com/go-check/check"
)
var pluginName = "tiborvass/no-remove"
@@ -133,3 +136,53 @@ func (s *DockerDaemonSuite) TestDaemonShutdownWithPlugins(c *check.C) {
c.Fatalf("Expected exit code '1', got %d err: %v output: %s ", ec, err, out)
}
}
// TestVolumePlugin tests volume creation using a plugin.
func (s *DockerDaemonSuite) TestVolumePlugin(c *check.C) {
volName := "plugin-volume"
volRoot := "/data"
destDir := "/tmp/data/"
destFile := "foo"
if err := s.d.Start(); err != nil {
c.Fatalf("Could not start daemon: %v", err)
}
out, err := s.d.Cmd("plugin", "install", pluginName, "--grant-all-permissions")
if err != nil {
c.Fatalf("Could not install plugin: %v %s", err, out)
}
defer func() {
if out, err := s.d.Cmd("plugin", "disable", pluginName); err != nil {
c.Fatalf("Could not disable plugin: %v %s", err, out)
}
if out, err := s.d.Cmd("plugin", "remove", pluginName); err != nil {
c.Fatalf("Could not remove plugin: %v %s", err, out)
}
}()
out, err = s.d.Cmd("volume", "create", "-d", pluginName, "--name", volName)
if err != nil {
c.Fatalf("Could not create volume: %v %s", err, out)
}
defer func() {
if out, err := s.d.Cmd("volume", "remove", volName); err != nil {
c.Fatalf("Could not remove volume: %v %s", err, out)
}
}()
mountPoint, err := s.d.Cmd("volume", "inspect", volName, "--format", "{{.Mountpoint}}")
if err != nil {
c.Fatalf("Could not inspect volume: %v %s", err, mountPoint)
}
mountPoint = strings.TrimSpace(mountPoint)
out, err = s.d.Cmd("run", "--rm", "-v", volName+":"+destDir, "busybox", "touch", destDir+destFile)
c.Assert(err, checker.IsNil, check.Commentf(out))
path := filepath.Join(mountPoint, destFile)
_, err = os.Lstat(path)
c.Assert(err, checker.IsNil)
// tiborvass/no-remove is a volume plugin that persists data on disk at /data,
// even after the volume is removed. So perform an explicit filesystem cleanup.
os.RemoveAll(volRoot)
}