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