mirror of
https://github.com/docker/cli.git
synced 2026-09-26 17:30:51 -04:00
Merge pull request #29556 from mavenugo/refcount
Fixing a couple of network plugin life-cycle mgmt issues Upstream-commit: 2ef6d8045415899b3faf8b68c0c732aa8c18917d Component: engine
This commit is contained in:
@@ -16,8 +16,10 @@ import (
|
||||
var (
|
||||
pluginProcessName = "sample-volume-plugin"
|
||||
pName = "tonistiigi/sample-volume-plugin"
|
||||
npName = "tonistiigi/test-docker-netplugin"
|
||||
pTag = "latest"
|
||||
pNameWithTag = pName + ":" + pTag
|
||||
npNameWithTag = npName + ":" + pTag
|
||||
)
|
||||
|
||||
func (s *DockerSuite) TestPluginBasicOps(c *check.C) {
|
||||
@@ -87,6 +89,33 @@ func (s *DockerSuite) TestPluginActive(c *check.C) {
|
||||
c.Assert(out, checker.Contains, pNameWithTag)
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPluginActiveNetwork(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
||||
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", npNameWithTag)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
out, _, err = dockerCmdWithError("network", "create", "-d", npNameWithTag, "test")
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
nID := strings.TrimSpace(out)
|
||||
|
||||
out, _, err = dockerCmdWithError("plugin", "remove", npNameWithTag)
|
||||
c.Assert(out, checker.Contains, "is in use")
|
||||
|
||||
_, _, err = dockerCmdWithError("network", "rm", nID)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
out, _, err = dockerCmdWithError("plugin", "remove", npNameWithTag)
|
||||
c.Assert(out, checker.Contains, "is enabled")
|
||||
|
||||
_, _, err = dockerCmdWithError("plugin", "disable", npNameWithTag)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
out, _, err = dockerCmdWithError("plugin", "remove", npNameWithTag)
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(out, checker.Contains, npNameWithTag)
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPluginInstallDisable(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux, IsAmd64, Network)
|
||||
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", "--disable", pName)
|
||||
|
||||
@@ -499,13 +499,6 @@ func (s *DockerSwarmSuite) TestPsListContainersFilterIsTask(c *check.C) {
|
||||
const globalNetworkPlugin = "global-network-plugin"
|
||||
const globalIPAMPlugin = "global-ipam-plugin"
|
||||
|
||||
func (s *DockerSwarmSuite) SetUpSuite(c *check.C) {
|
||||
mux := http.NewServeMux()
|
||||
s.server = httptest.NewServer(mux)
|
||||
c.Assert(s.server, check.NotNil, check.Commentf("Failed to start an HTTP Server"))
|
||||
setupRemoteGlobalNetworkPlugin(c, mux, s.server.URL, globalNetworkPlugin, globalIPAMPlugin)
|
||||
}
|
||||
|
||||
func setupRemoteGlobalNetworkPlugin(c *check.C, mux *http.ServeMux, url, netDrv, ipamDrv string) {
|
||||
|
||||
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -675,6 +668,16 @@ func setupRemoteGlobalNetworkPlugin(c *check.C, mux *http.ServeMux, url, netDrv,
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmNetworkPlugin(c *check.C) {
|
||||
mux := http.NewServeMux()
|
||||
s.server = httptest.NewServer(mux)
|
||||
c.Assert(s.server, check.NotNil, check.Commentf("Failed to start an HTTP Server"))
|
||||
setupRemoteGlobalNetworkPlugin(c, mux, s.server.URL, globalNetworkPlugin, globalIPAMPlugin)
|
||||
defer func() {
|
||||
s.server.Close()
|
||||
err := os.RemoveAll("/etc/docker/plugins")
|
||||
c.Assert(err, checker.IsNil)
|
||||
}()
|
||||
|
||||
d := s.AddDaemon(c, true, true)
|
||||
|
||||
out, err := d.Cmd("network", "create", "-d", globalNetworkPlugin, "foo")
|
||||
|
||||
Reference in New Issue
Block a user