github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/integration/plugin/volumes/mounts_test.go (about) 1 package volumes 2 3 import ( 4 "context" 5 "io/ioutil" 6 "os" 7 "testing" 8 9 "github.com/demonoid81/moby/api/types" 10 "github.com/demonoid81/moby/testutil/daemon" 11 "github.com/demonoid81/moby/testutil/fixtures/plugin" 12 "gotest.tools/v3/assert" 13 "gotest.tools/v3/skip" 14 ) 15 16 // TestPluginWithDevMounts tests very specific regression caused by mounts ordering 17 // (sorted in the daemon). See #36698 18 func TestPluginWithDevMounts(t *testing.T) { 19 skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon") 20 skip.If(t, testEnv.DaemonInfo.OSType == "windows") 21 skip.If(t, testEnv.IsRootless) 22 t.Parallel() 23 24 d := daemon.New(t) 25 d.Start(t, "--iptables=false") 26 defer d.Stop(t) 27 28 c := d.NewClientT(t) 29 ctx := context.Background() 30 31 testDir, err := ioutil.TempDir("", "test-dir") 32 assert.NilError(t, err) 33 defer os.RemoveAll(testDir) 34 35 createPlugin(t, c, "test", "dummy", asVolumeDriver, func(c *plugin.Config) { 36 root := "/" 37 dev := "/dev" 38 mounts := []types.PluginMount{ 39 {Type: "bind", Source: &root, Destination: "/host", Options: []string{"rbind"}}, 40 {Type: "bind", Source: &dev, Destination: "/dev", Options: []string{"rbind"}}, 41 {Type: "bind", Source: &testDir, Destination: "/etc/foo", Options: []string{"rbind"}}, 42 } 43 c.PluginConfig.Mounts = append(c.PluginConfig.Mounts, mounts...) 44 c.PropagatedMount = "/propagated" 45 c.Network = types.PluginConfigNetwork{Type: "host"} 46 c.IpcHost = true 47 }) 48 49 err = c.PluginEnable(ctx, "test", types.PluginEnableOptions{Timeout: 30}) 50 assert.NilError(t, err) 51 defer func() { 52 err := c.PluginRemove(ctx, "test", types.PluginRemoveOptions{Force: true}) 53 assert.Check(t, err) 54 }() 55 56 p, _, err := c.PluginInspectWithRaw(ctx, "test") 57 assert.NilError(t, err) 58 assert.Assert(t, p.Enabled) 59 }