github.com/rita33cool1/iot-system-gateway@v0.0.0-20200911033302-e65bde238cc5/docker-engine/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/docker/docker/api/types" 10 "github.com/docker/docker/internal/test/daemon" 11 "github.com/docker/docker/internal/test/fixtures/plugin" 12 "github.com/gotestyourself/gotestyourself/assert" 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 t.Parallel() 19 20 d := daemon.New(t) 21 d.Start(t, "--iptables=false") 22 defer d.Stop(t) 23 24 client, err := d.NewClient() 25 assert.Assert(t, err) 26 ctx := context.Background() 27 28 testDir, err := ioutil.TempDir("", "test-dir") 29 assert.Assert(t, err) 30 defer os.RemoveAll(testDir) 31 32 createPlugin(t, client, "test", "dummy", asVolumeDriver, func(c *plugin.Config) { 33 root := "/" 34 dev := "/dev" 35 mounts := []types.PluginMount{ 36 {Type: "bind", Source: &root, Destination: "/host", Options: []string{"rbind"}}, 37 {Type: "bind", Source: &dev, Destination: "/dev", Options: []string{"rbind"}}, 38 {Type: "bind", Source: &testDir, Destination: "/etc/foo", Options: []string{"rbind"}}, 39 } 40 c.PluginConfig.Mounts = append(c.PluginConfig.Mounts, mounts...) 41 c.PropagatedMount = "/propagated" 42 c.Network = types.PluginConfigNetwork{Type: "host"} 43 c.IpcHost = true 44 }) 45 46 err = client.PluginEnable(ctx, "test", types.PluginEnableOptions{Timeout: 30}) 47 assert.Assert(t, err) 48 defer func() { 49 err := client.PluginRemove(ctx, "test", types.PluginRemoveOptions{Force: true}) 50 assert.Check(t, err) 51 }() 52 53 p, _, err := client.PluginInspectWithRaw(ctx, "test") 54 assert.Assert(t, err) 55 assert.Assert(t, p.Enabled) 56 }