2016-06-17 08:21:03 -07:00
|
|
|
// +build linux, experimental
|
2016-03-18 11:50:19 -07:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-06-17 08:21:03 -07:00
|
|
|
"github.com/docker/docker/pkg/integration/checker"
|
2016-03-18 11:50:19 -07:00
|
|
|
"github.com/go-check/check"
|
|
|
|
)
|
|
|
|
|
2016-06-17 08:21:03 -07:00
|
|
|
var pluginName = "tiborvass/no-remove"
|
2016-03-18 11:50:19 -07:00
|
|
|
|
2016-06-17 08:21:03 -07:00
|
|
|
// TestDaemonRestartWithPluginEnabled tests state restore for an enabled plugin
|
|
|
|
func (s *DockerDaemonSuite) TestDaemonRestartWithPluginEnabled(c *check.C) {
|
2016-03-18 11:50:19 -07:00
|
|
|
if err := s.d.Start(); err != nil {
|
2016-06-17 08:21:03 -07:00
|
|
|
c.Fatalf("Could not start daemon: %v", err)
|
2016-03-04 14:41:53 -08:00
|
|
|
}
|
|
|
|
|
2016-06-17 08:21:03 -07:00
|
|
|
if out, err := s.d.Cmd("plugin", "install", "--grant-all-permissions", pluginName); err != nil {
|
|
|
|
c.Fatalf("Could not install plugin: %v %s", err, out)
|
2016-03-04 14:41:53 -08:00
|
|
|
}
|
|
|
|
|
2016-06-27 20:32:03 -07:00
|
|
|
defer func() {
|
|
|
|
if out, err := s.d.Cmd("plugin", "disable", pluginName); err != nil {
|
|
|
|
c.Fatalf("Could not disable plugin: %v %s", err, out)
|
|
|
|
}
|
|
|
|
if out, err := s.d.Cmd("plugin", "remove", pluginName); err != nil {
|
|
|
|
c.Fatalf("Could not remove plugin: %v %s", err, out)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2016-06-17 08:21:03 -07:00
|
|
|
if err := s.d.Restart(); err != nil {
|
|
|
|
c.Fatalf("Could not restart daemon: %v", err)
|
2016-03-18 11:50:19 -07:00
|
|
|
}
|
|
|
|
|
2016-06-17 08:21:03 -07:00
|
|
|
out, err := s.d.Cmd("plugin", "ls")
|
2016-03-18 11:50:19 -07:00
|
|
|
if err != nil {
|
2016-06-17 08:21:03 -07:00
|
|
|
c.Fatalf("Could not list plugins: %v %s", err, out)
|
2016-03-18 11:50:19 -07:00
|
|
|
}
|
2016-06-17 08:21:03 -07:00
|
|
|
c.Assert(out, checker.Contains, pluginName)
|
|
|
|
c.Assert(out, checker.Contains, "true")
|
|
|
|
}
|
2016-03-18 11:50:19 -07:00
|
|
|
|
2016-06-17 08:21:03 -07:00
|
|
|
// TestDaemonRestartWithPluginEnabled tests state restore for a disabled plugin
|
|
|
|
func (s *DockerDaemonSuite) TestDaemonRestartWithPluginDisabled(c *check.C) {
|
|
|
|
if err := s.d.Start(); err != nil {
|
|
|
|
c.Fatalf("Could not start daemon: %v", err)
|
2016-03-18 11:50:19 -07:00
|
|
|
}
|
|
|
|
|
2016-06-17 08:21:03 -07:00
|
|
|
if out, err := s.d.Cmd("plugin", "install", "--grant-all-permissions", pluginName, "--disable"); err != nil {
|
|
|
|
c.Fatalf("Could not install plugin: %v %s", err, out)
|
2016-03-18 11:50:19 -07:00
|
|
|
}
|
|
|
|
|
2016-06-27 20:32:03 -07:00
|
|
|
defer func() {
|
|
|
|
if out, err := s.d.Cmd("plugin", "remove", pluginName); err != nil {
|
|
|
|
c.Fatalf("Could not remove plugin: %v %s", err, out)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2016-06-17 08:21:03 -07:00
|
|
|
if err := s.d.Restart(); err != nil {
|
|
|
|
c.Fatalf("Could not restart daemon: %v", err)
|
2016-03-18 11:50:19 -07:00
|
|
|
}
|
|
|
|
|
2016-06-17 08:21:03 -07:00
|
|
|
out, err := s.d.Cmd("plugin", "ls")
|
|
|
|
if err != nil {
|
|
|
|
c.Fatalf("Could not list plugins: %v %s", err, out)
|
2016-06-14 11:06:11 -07:00
|
|
|
}
|
2016-06-17 08:21:03 -07:00
|
|
|
c.Assert(out, checker.Contains, pluginName)
|
|
|
|
c.Assert(out, checker.Contains, "false")
|
2016-03-18 11:50:19 -07:00
|
|
|
}
|