github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/integration/plugin/volumes/mounts_test.go (about) 1 package volumes 2 3 import ( 4 "os" 5 "testing" 6 7 "github.com/Prakhar-Agarwal-byte/moby/api/types" 8 "github.com/Prakhar-Agarwal-byte/moby/testutil" 9 "github.com/Prakhar-Agarwal-byte/moby/testutil/daemon" 10 "github.com/Prakhar-Agarwal-byte/moby/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 ctx := testutil.StartSpan(baseContext, t) 24 25 d := daemon.New(t) 26 d.Start(t, "--iptables=false") 27 defer d.Stop(t) 28 29 c := d.NewClientT(t) 30 31 testDir, err := os.MkdirTemp("", "test-dir") 32 assert.NilError(t, err) 33 defer os.RemoveAll(testDir) 34 35 createPlugin(ctx, 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 }