2015-04-18 12:46:47 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2015-06-05 16:09:53 -04:00
|
|
|
"fmt"
|
2016-10-15 13:20:34 -04:00
|
|
|
"net/http/httptest"
|
2016-03-09 03:18:30 -05:00
|
|
|
"os"
|
2017-07-12 16:31:13 -04:00
|
|
|
"path"
|
2016-03-09 03:18:30 -05:00
|
|
|
"path/filepath"
|
2016-06-29 14:00:11 -04:00
|
|
|
"sync"
|
2016-07-28 10:19:09 -04:00
|
|
|
"syscall"
|
2015-04-18 12:46:47 -04:00
|
|
|
"testing"
|
2017-07-12 16:31:13 -04:00
|
|
|
"time"
|
2015-04-18 12:46:47 -04:00
|
|
|
|
2016-09-06 14:18:12 -04:00
|
|
|
"github.com/docker/docker/api/types/swarm"
|
2017-06-01 16:34:31 -04:00
|
|
|
"github.com/docker/docker/cli/config"
|
2017-07-12 16:31:13 -04:00
|
|
|
"github.com/docker/docker/integration-cli/checker"
|
2017-03-23 13:35:22 -04:00
|
|
|
"github.com/docker/docker/integration-cli/cli"
|
2017-04-10 08:42:21 -04:00
|
|
|
"github.com/docker/docker/integration-cli/cli/build/fakestorage"
|
2016-12-09 04:17:53 -05:00
|
|
|
"github.com/docker/docker/integration-cli/daemon"
|
2016-12-25 14:28:38 -05:00
|
|
|
"github.com/docker/docker/integration-cli/environment"
|
2017-07-12 16:31:13 -04:00
|
|
|
"github.com/docker/docker/integration-cli/fixtures/plugin"
|
2016-12-30 13:10:04 -05:00
|
|
|
"github.com/docker/docker/integration-cli/registry"
|
2015-06-05 16:09:53 -04:00
|
|
|
"github.com/docker/docker/pkg/reexec"
|
2015-04-18 12:46:47 -04:00
|
|
|
"github.com/go-check/check"
|
2017-07-12 16:31:13 -04:00
|
|
|
"golang.org/x/net/context"
|
2015-04-18 12:46:47 -04:00
|
|
|
)
|
|
|
|
|
2016-12-25 14:28:38 -05:00
|
|
|
const (
|
|
|
|
// the private registry to use for tests
|
|
|
|
privateRegistryURL = "127.0.0.1:5000"
|
|
|
|
|
|
|
|
// path to containerd's ctr binary
|
|
|
|
ctrBinary = "docker-containerd-ctr"
|
|
|
|
|
|
|
|
// the docker daemon binary to use
|
|
|
|
dockerdBinary = "dockerd"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
testEnv *environment.Execution
|
|
|
|
|
|
|
|
// the docker client binary to use
|
2017-04-17 19:18:46 -04:00
|
|
|
dockerBinary = ""
|
2016-12-25 14:28:38 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
var err error
|
|
|
|
|
2015-06-05 16:09:53 -04:00
|
|
|
reexec.Init() // This is required for external graphdriver tests
|
|
|
|
|
2016-12-25 14:28:38 -05:00
|
|
|
testEnv, err = environment.New()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMain(m *testing.M) {
|
2017-03-23 13:35:22 -04:00
|
|
|
dockerBinary = testEnv.DockerBinary()
|
2016-12-25 14:28:38 -05:00
|
|
|
|
2017-01-13 11:23:28 -05:00
|
|
|
if testEnv.LocalDaemon() {
|
2015-06-05 16:09:53 -04:00
|
|
|
fmt.Println("INFO: Testing against a local daemon")
|
2017-01-13 11:23:28 -05:00
|
|
|
} else {
|
|
|
|
fmt.Println("INFO: Testing against a remote daemon")
|
2015-06-05 16:09:53 -04:00
|
|
|
}
|
2016-12-25 14:28:38 -05:00
|
|
|
exitCode := m.Run()
|
|
|
|
os.Exit(exitCode)
|
|
|
|
}
|
2015-06-05 16:09:53 -04:00
|
|
|
|
2016-12-25 14:28:38 -05:00
|
|
|
func Test(t *testing.T) {
|
2017-03-23 13:35:22 -04:00
|
|
|
cli.EnsureTestEnvIsLoaded(t)
|
2017-04-10 08:42:21 -04:00
|
|
|
fakestorage.EnsureTestEnvIsLoaded(t)
|
2017-07-12 17:51:46 -04:00
|
|
|
environment.ProtectImages(t, testEnv)
|
2015-04-22 14:20:32 -04:00
|
|
|
check.TestingT(t)
|
|
|
|
}
|
2015-04-18 12:46:47 -04:00
|
|
|
|
2015-04-24 17:16:56 -04:00
|
|
|
func init() {
|
|
|
|
check.Suite(&DockerSuite{})
|
|
|
|
}
|
|
|
|
|
2015-04-18 12:46:47 -04:00
|
|
|
type DockerSuite struct {
|
|
|
|
}
|
|
|
|
|
2016-07-27 14:17:44 -04:00
|
|
|
func (s *DockerSuite) OnTimeout(c *check.C) {
|
2017-01-13 11:23:28 -05:00
|
|
|
if testEnv.DaemonPID() > 0 && testEnv.LocalDaemon() {
|
2016-12-25 14:28:38 -05:00
|
|
|
daemon.SignalDaemonDump(testEnv.DaemonPID())
|
2016-07-27 14:17:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-18 12:46:47 -04:00
|
|
|
func (s *DockerSuite) TearDownTest(c *check.C) {
|
2017-03-01 12:45:04 -05:00
|
|
|
testEnv.Clean(c, dockerBinary)
|
2015-04-18 12:46:47 -04:00
|
|
|
}
|
|
|
|
|
2015-04-24 17:16:56 -04:00
|
|
|
func init() {
|
|
|
|
check.Suite(&DockerRegistrySuite{
|
|
|
|
ds: &DockerSuite{},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
type DockerRegistrySuite struct {
|
|
|
|
ds *DockerSuite
|
2016-12-30 13:10:04 -05:00
|
|
|
reg *registry.V2
|
2016-12-09 04:17:53 -05:00
|
|
|
d *daemon.Daemon
|
2015-04-24 17:16:56 -04:00
|
|
|
}
|
|
|
|
|
2016-07-27 14:17:44 -04:00
|
|
|
func (s *DockerRegistrySuite) OnTimeout(c *check.C) {
|
|
|
|
s.d.DumpStackAndQuit()
|
|
|
|
}
|
|
|
|
|
2015-04-24 17:16:56 -04:00
|
|
|
func (s *DockerRegistrySuite) SetUpTest(c *check.C) {
|
2016-12-30 13:10:04 -05:00
|
|
|
testRequires(c, DaemonIsLinux, registry.Hosting)
|
2016-03-14 16:11:35 -04:00
|
|
|
s.reg = setupRegistry(c, false, "", "")
|
2016-12-09 04:17:53 -05:00
|
|
|
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
2017-01-13 11:23:28 -05:00
|
|
|
Experimental: testEnv.ExperimentalDaemon(),
|
2016-12-09 04:17:53 -05:00
|
|
|
})
|
2015-04-24 17:16:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerRegistrySuite) TearDownTest(c *check.C) {
|
2015-07-23 05:40:54 -04:00
|
|
|
if s.reg != nil {
|
|
|
|
s.reg.Close()
|
|
|
|
}
|
2016-01-13 04:51:01 -05:00
|
|
|
if s.d != nil {
|
2016-12-09 17:20:14 -05:00
|
|
|
s.d.Stop(c)
|
2015-07-23 05:40:54 -04:00
|
|
|
}
|
2016-01-13 04:51:01 -05:00
|
|
|
s.ds.TearDownTest(c)
|
2015-04-24 17:16:56 -04:00
|
|
|
}
|
2015-04-25 22:47:42 -04:00
|
|
|
|
2015-12-18 18:06:23 -05:00
|
|
|
func init() {
|
|
|
|
check.Suite(&DockerSchema1RegistrySuite{
|
|
|
|
ds: &DockerSuite{},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
type DockerSchema1RegistrySuite struct {
|
|
|
|
ds *DockerSuite
|
2016-12-30 13:10:04 -05:00
|
|
|
reg *registry.V2
|
2016-12-09 04:17:53 -05:00
|
|
|
d *daemon.Daemon
|
2015-12-18 18:06:23 -05:00
|
|
|
}
|
|
|
|
|
2016-07-27 14:17:44 -04:00
|
|
|
func (s *DockerSchema1RegistrySuite) OnTimeout(c *check.C) {
|
|
|
|
s.d.DumpStackAndQuit()
|
|
|
|
}
|
|
|
|
|
2015-12-18 18:06:23 -05:00
|
|
|
func (s *DockerSchema1RegistrySuite) SetUpTest(c *check.C) {
|
2016-12-30 13:10:04 -05:00
|
|
|
testRequires(c, DaemonIsLinux, registry.Hosting, NotArm64)
|
2016-03-14 16:11:35 -04:00
|
|
|
s.reg = setupRegistry(c, true, "", "")
|
2016-12-09 04:17:53 -05:00
|
|
|
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
2017-01-13 11:23:28 -05:00
|
|
|
Experimental: testEnv.ExperimentalDaemon(),
|
2016-12-09 04:17:53 -05:00
|
|
|
})
|
2015-12-18 18:06:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerSchema1RegistrySuite) TearDownTest(c *check.C) {
|
|
|
|
if s.reg != nil {
|
|
|
|
s.reg.Close()
|
|
|
|
}
|
2016-01-13 04:51:01 -05:00
|
|
|
if s.d != nil {
|
2016-12-09 17:20:14 -05:00
|
|
|
s.d.Stop(c)
|
2015-12-18 18:06:23 -05:00
|
|
|
}
|
2016-01-13 04:51:01 -05:00
|
|
|
s.ds.TearDownTest(c)
|
2015-12-18 18:06:23 -05:00
|
|
|
}
|
|
|
|
|
2016-01-23 13:45:01 -05:00
|
|
|
func init() {
|
2016-03-14 16:11:35 -04:00
|
|
|
check.Suite(&DockerRegistryAuthHtpasswdSuite{
|
2016-01-23 13:45:01 -05:00
|
|
|
ds: &DockerSuite{},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-03-14 16:11:35 -04:00
|
|
|
type DockerRegistryAuthHtpasswdSuite struct {
|
2016-01-23 13:45:01 -05:00
|
|
|
ds *DockerSuite
|
2016-12-30 13:10:04 -05:00
|
|
|
reg *registry.V2
|
2016-12-09 04:17:53 -05:00
|
|
|
d *daemon.Daemon
|
2016-01-23 13:45:01 -05:00
|
|
|
}
|
|
|
|
|
2016-07-27 14:17:44 -04:00
|
|
|
func (s *DockerRegistryAuthHtpasswdSuite) OnTimeout(c *check.C) {
|
|
|
|
s.d.DumpStackAndQuit()
|
|
|
|
}
|
|
|
|
|
2016-03-14 16:11:35 -04:00
|
|
|
func (s *DockerRegistryAuthHtpasswdSuite) SetUpTest(c *check.C) {
|
2016-12-30 13:10:04 -05:00
|
|
|
testRequires(c, DaemonIsLinux, registry.Hosting)
|
2016-03-14 16:11:35 -04:00
|
|
|
s.reg = setupRegistry(c, false, "htpasswd", "")
|
2016-12-09 04:17:53 -05:00
|
|
|
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
2017-01-13 11:23:28 -05:00
|
|
|
Experimental: testEnv.ExperimentalDaemon(),
|
2016-12-09 04:17:53 -05:00
|
|
|
})
|
2016-01-23 13:45:01 -05:00
|
|
|
}
|
|
|
|
|
2016-03-14 16:11:35 -04:00
|
|
|
func (s *DockerRegistryAuthHtpasswdSuite) TearDownTest(c *check.C) {
|
2016-01-23 13:45:01 -05:00
|
|
|
if s.reg != nil {
|
|
|
|
out, err := s.d.Cmd("logout", privateRegistryURL)
|
|
|
|
c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
s.reg.Close()
|
|
|
|
}
|
|
|
|
if s.d != nil {
|
2016-12-09 17:20:14 -05:00
|
|
|
s.d.Stop(c)
|
2016-01-23 13:45:01 -05:00
|
|
|
}
|
|
|
|
s.ds.TearDownTest(c)
|
|
|
|
}
|
|
|
|
|
2016-03-14 16:11:35 -04:00
|
|
|
func init() {
|
|
|
|
check.Suite(&DockerRegistryAuthTokenSuite{
|
|
|
|
ds: &DockerSuite{},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
type DockerRegistryAuthTokenSuite struct {
|
|
|
|
ds *DockerSuite
|
2016-12-30 13:10:04 -05:00
|
|
|
reg *registry.V2
|
2016-12-09 04:17:53 -05:00
|
|
|
d *daemon.Daemon
|
2016-03-14 16:11:35 -04:00
|
|
|
}
|
|
|
|
|
2016-07-27 14:17:44 -04:00
|
|
|
func (s *DockerRegistryAuthTokenSuite) OnTimeout(c *check.C) {
|
|
|
|
s.d.DumpStackAndQuit()
|
|
|
|
}
|
|
|
|
|
2016-03-14 16:11:35 -04:00
|
|
|
func (s *DockerRegistryAuthTokenSuite) SetUpTest(c *check.C) {
|
2016-12-30 13:10:04 -05:00
|
|
|
testRequires(c, DaemonIsLinux, registry.Hosting)
|
2016-12-09 04:17:53 -05:00
|
|
|
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
2017-01-13 11:23:28 -05:00
|
|
|
Experimental: testEnv.ExperimentalDaemon(),
|
2016-12-09 04:17:53 -05:00
|
|
|
})
|
2016-03-14 16:11:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerRegistryAuthTokenSuite) TearDownTest(c *check.C) {
|
|
|
|
if s.reg != nil {
|
|
|
|
out, err := s.d.Cmd("logout", privateRegistryURL)
|
|
|
|
c.Assert(err, check.IsNil, check.Commentf(out))
|
|
|
|
s.reg.Close()
|
|
|
|
}
|
|
|
|
if s.d != nil {
|
2016-12-09 17:20:14 -05:00
|
|
|
s.d.Stop(c)
|
2016-03-14 16:11:35 -04:00
|
|
|
}
|
|
|
|
s.ds.TearDownTest(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerRegistryAuthTokenSuite) setupRegistryWithTokenService(c *check.C, tokenURL string) {
|
|
|
|
if s == nil {
|
|
|
|
c.Fatal("registry suite isn't initialized")
|
|
|
|
}
|
|
|
|
s.reg = setupRegistry(c, false, "token", tokenURL)
|
|
|
|
}
|
|
|
|
|
2015-04-25 22:47:42 -04:00
|
|
|
func init() {
|
|
|
|
check.Suite(&DockerDaemonSuite{
|
|
|
|
ds: &DockerSuite{},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
type DockerDaemonSuite struct {
|
|
|
|
ds *DockerSuite
|
2016-12-09 04:17:53 -05:00
|
|
|
d *daemon.Daemon
|
2015-04-25 22:47:42 -04:00
|
|
|
}
|
|
|
|
|
2016-07-27 14:17:44 -04:00
|
|
|
func (s *DockerDaemonSuite) OnTimeout(c *check.C) {
|
|
|
|
s.d.DumpStackAndQuit()
|
|
|
|
}
|
|
|
|
|
2015-04-25 22:47:42 -04:00
|
|
|
func (s *DockerDaemonSuite) SetUpTest(c *check.C) {
|
2016-12-13 06:04:53 -05:00
|
|
|
testRequires(c, DaemonIsLinux, SameHostDaemon)
|
2016-12-09 04:17:53 -05:00
|
|
|
s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
2017-01-13 11:23:28 -05:00
|
|
|
Experimental: testEnv.ExperimentalDaemon(),
|
2016-12-09 04:17:53 -05:00
|
|
|
})
|
2015-04-25 22:47:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
|
2016-12-13 06:04:53 -05:00
|
|
|
testRequires(c, DaemonIsLinux, SameHostDaemon)
|
2016-01-13 04:51:01 -05:00
|
|
|
if s.d != nil {
|
2016-12-09 17:20:14 -05:00
|
|
|
s.d.Stop(c)
|
2016-01-13 04:51:01 -05:00
|
|
|
}
|
2015-04-25 22:47:42 -04:00
|
|
|
s.ds.TearDownTest(c)
|
|
|
|
}
|
2015-07-20 01:56:10 -04:00
|
|
|
|
2016-07-28 10:19:09 -04:00
|
|
|
func (s *DockerDaemonSuite) TearDownSuite(c *check.C) {
|
2016-12-09 04:17:53 -05:00
|
|
|
filepath.Walk(daemon.SockRoot, func(path string, fi os.FileInfo, err error) error {
|
2016-07-28 10:19:09 -04:00
|
|
|
if err != nil {
|
2016-08-10 15:18:35 -04:00
|
|
|
// ignore errors here
|
|
|
|
// not cleaning up sockets is not really an error
|
|
|
|
return nil
|
2016-07-28 10:19:09 -04:00
|
|
|
}
|
|
|
|
if fi.Mode() == os.ModeSocket {
|
|
|
|
syscall.Unlink(path)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
2016-12-09 04:17:53 -05:00
|
|
|
os.RemoveAll(daemon.SockRoot)
|
2016-07-28 10:19:09 -04:00
|
|
|
}
|
|
|
|
|
2016-06-13 22:54:20 -04:00
|
|
|
const defaultSwarmPort = 2477
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
check.Suite(&DockerSwarmSuite{
|
|
|
|
ds: &DockerSuite{},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
type DockerSwarmSuite struct {
|
2016-10-15 13:20:34 -04:00
|
|
|
server *httptest.Server
|
2016-06-29 14:00:11 -04:00
|
|
|
ds *DockerSuite
|
2016-12-09 04:17:53 -05:00
|
|
|
daemons []*daemon.Swarm
|
2016-06-29 14:00:11 -04:00
|
|
|
daemonsLock sync.Mutex // protect access to daemons
|
|
|
|
portIndex int
|
2016-06-13 22:54:20 -04:00
|
|
|
}
|
|
|
|
|
2016-07-27 14:17:44 -04:00
|
|
|
func (s *DockerSwarmSuite) OnTimeout(c *check.C) {
|
|
|
|
s.daemonsLock.Lock()
|
|
|
|
defer s.daemonsLock.Unlock()
|
|
|
|
for _, d := range s.daemons {
|
|
|
|
d.DumpStackAndQuit()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-13 22:54:20 -04:00
|
|
|
func (s *DockerSwarmSuite) SetUpTest(c *check.C) {
|
|
|
|
testRequires(c, DaemonIsLinux)
|
|
|
|
}
|
|
|
|
|
2016-12-09 04:17:53 -05:00
|
|
|
func (s *DockerSwarmSuite) AddDaemon(c *check.C, joinSwarm, manager bool) *daemon.Swarm {
|
|
|
|
d := &daemon.Swarm{
|
|
|
|
Daemon: daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
|
2017-01-13 11:23:28 -05:00
|
|
|
Experimental: testEnv.ExperimentalDaemon(),
|
2016-12-09 04:17:53 -05:00
|
|
|
}),
|
|
|
|
Port: defaultSwarmPort + s.portIndex,
|
2016-06-13 22:54:20 -04:00
|
|
|
}
|
2016-12-09 04:17:53 -05:00
|
|
|
d.ListenAddr = fmt.Sprintf("0.0.0.0:%d", d.Port)
|
2016-10-06 10:09:54 -04:00
|
|
|
args := []string{"--iptables=false", "--swarm-default-advertise-addr=lo"} // avoid networking conflicts
|
2016-12-09 17:20:14 -05:00
|
|
|
d.StartWithBusybox(c, args...)
|
2016-06-13 22:54:20 -04:00
|
|
|
|
|
|
|
if joinSwarm == true {
|
|
|
|
if len(s.daemons) > 0 {
|
2016-12-09 04:17:53 -05:00
|
|
|
tokens := s.daemons[0].JoinTokens(c)
|
2016-07-20 14:15:08 -04:00
|
|
|
token := tokens.Worker
|
|
|
|
if manager {
|
|
|
|
token = tokens.Manager
|
|
|
|
}
|
2016-06-19 22:00:45 -04:00
|
|
|
c.Assert(d.Join(swarm.JoinRequest{
|
2016-12-09 04:17:53 -05:00
|
|
|
RemoteAddrs: []string{s.daemons[0].ListenAddr},
|
2016-07-20 14:15:08 -04:00
|
|
|
JoinToken: token,
|
2016-06-19 22:00:45 -04:00
|
|
|
}), check.IsNil)
|
2016-07-20 14:15:08 -04:00
|
|
|
} else {
|
|
|
|
c.Assert(d.Init(swarm.InitRequest{}), check.IsNil)
|
2016-06-13 22:54:20 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s.portIndex++
|
2016-06-29 14:00:11 -04:00
|
|
|
s.daemonsLock.Lock()
|
2016-06-13 22:54:20 -04:00
|
|
|
s.daemons = append(s.daemons, d)
|
2016-06-29 14:00:11 -04:00
|
|
|
s.daemonsLock.Unlock()
|
2016-06-13 22:54:20 -04:00
|
|
|
|
|
|
|
return d
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerSwarmSuite) TearDownTest(c *check.C) {
|
|
|
|
testRequires(c, DaemonIsLinux)
|
2016-06-29 14:00:11 -04:00
|
|
|
s.daemonsLock.Lock()
|
2016-06-13 22:54:20 -04:00
|
|
|
for _, d := range s.daemons {
|
2016-11-21 12:37:13 -05:00
|
|
|
if d != nil {
|
2016-12-09 17:20:14 -05:00
|
|
|
d.Stop(c)
|
2016-12-09 04:17:53 -05:00
|
|
|
// FIXME(vdemeester) should be handled by SwarmDaemon ?
|
2016-11-21 12:37:13 -05:00
|
|
|
// raft state file is quite big (64MB) so remove it after every test
|
2016-12-09 04:17:53 -05:00
|
|
|
walDir := filepath.Join(d.Root, "swarm/raft/wal")
|
2016-11-21 12:37:13 -05:00
|
|
|
if err := os.RemoveAll(walDir); err != nil {
|
|
|
|
c.Logf("error removing %v: %v", walDir, err)
|
|
|
|
}
|
2016-08-23 19:50:15 -04:00
|
|
|
|
2016-12-09 04:17:53 -05:00
|
|
|
d.CleanupExecRoot(c)
|
2016-11-21 12:37:13 -05:00
|
|
|
}
|
2016-06-13 22:54:20 -04:00
|
|
|
}
|
|
|
|
s.daemons = nil
|
2016-06-29 14:00:11 -04:00
|
|
|
s.daemonsLock.Unlock()
|
2016-06-13 22:54:20 -04:00
|
|
|
|
2016-06-29 14:00:11 -04:00
|
|
|
s.portIndex = 0
|
2016-06-13 22:54:20 -04:00
|
|
|
s.ds.TearDownTest(c)
|
|
|
|
}
|
|
|
|
|
2015-07-20 01:56:10 -04:00
|
|
|
func init() {
|
|
|
|
check.Suite(&DockerTrustSuite{
|
|
|
|
ds: &DockerSuite{},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
type DockerTrustSuite struct {
|
|
|
|
ds *DockerSuite
|
2016-12-30 13:10:04 -05:00
|
|
|
reg *registry.V2
|
2015-07-20 01:56:10 -04:00
|
|
|
not *testNotary
|
|
|
|
}
|
|
|
|
|
2017-01-11 13:35:53 -05:00
|
|
|
func (s *DockerTrustSuite) OnTimeout(c *check.C) {
|
|
|
|
s.ds.OnTimeout(c)
|
|
|
|
}
|
|
|
|
|
2015-07-20 01:56:10 -04:00
|
|
|
func (s *DockerTrustSuite) SetUpTest(c *check.C) {
|
2016-12-30 13:10:04 -05:00
|
|
|
testRequires(c, registry.Hosting, NotaryServerHosting)
|
2016-03-14 16:11:35 -04:00
|
|
|
s.reg = setupRegistry(c, false, "", "")
|
2015-07-20 01:56:10 -04:00
|
|
|
s.not = setupNotary(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerTrustSuite) TearDownTest(c *check.C) {
|
2016-01-13 04:51:01 -05:00
|
|
|
if s.reg != nil {
|
|
|
|
s.reg.Close()
|
|
|
|
}
|
|
|
|
if s.not != nil {
|
|
|
|
s.not.Close()
|
|
|
|
}
|
2016-03-09 03:18:30 -05:00
|
|
|
|
|
|
|
// Remove trusted keys and metadata after test
|
2017-06-01 16:34:31 -04:00
|
|
|
os.RemoveAll(filepath.Join(config.Dir(), "trust"))
|
2015-07-20 01:56:10 -04:00
|
|
|
s.ds.TearDownTest(c)
|
|
|
|
}
|
2016-12-06 13:57:58 -05:00
|
|
|
|
|
|
|
func init() {
|
|
|
|
ds := &DockerSuite{}
|
|
|
|
check.Suite(&DockerTrustedSwarmSuite{
|
|
|
|
trustSuite: DockerTrustSuite{
|
|
|
|
ds: ds,
|
|
|
|
},
|
|
|
|
swarmSuite: DockerSwarmSuite{
|
|
|
|
ds: ds,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
type DockerTrustedSwarmSuite struct {
|
|
|
|
swarmSuite DockerSwarmSuite
|
|
|
|
trustSuite DockerTrustSuite
|
2016-12-30 13:10:04 -05:00
|
|
|
reg *registry.V2
|
2016-12-06 13:57:58 -05:00
|
|
|
not *testNotary
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerTrustedSwarmSuite) SetUpTest(c *check.C) {
|
|
|
|
s.swarmSuite.SetUpTest(c)
|
|
|
|
s.trustSuite.SetUpTest(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerTrustedSwarmSuite) TearDownTest(c *check.C) {
|
|
|
|
s.trustSuite.TearDownTest(c)
|
|
|
|
s.swarmSuite.TearDownTest(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *DockerTrustedSwarmSuite) OnTimeout(c *check.C) {
|
|
|
|
s.swarmSuite.OnTimeout(c)
|
|
|
|
}
|
2017-07-12 16:31:13 -04:00
|
|
|
|
|
|
|
func init() {
|
|
|
|
check.Suite(&DockerPluginSuite{
|
|
|
|
ds: &DockerSuite{},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
type DockerPluginSuite struct {
|
|
|
|
ds *DockerSuite
|
|
|
|
registry *registry.V2
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ps *DockerPluginSuite) registryHost() string {
|
|
|
|
return privateRegistryURL
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ps *DockerPluginSuite) getPluginRepo() string {
|
|
|
|
return path.Join(ps.registryHost(), "plugin", "basic")
|
|
|
|
}
|
|
|
|
func (ps *DockerPluginSuite) getPluginRepoWithTag() string {
|
|
|
|
return ps.getPluginRepo() + ":" + "latest"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ps *DockerPluginSuite) SetUpSuite(c *check.C) {
|
|
|
|
testRequires(c, DaemonIsLinux)
|
|
|
|
ps.registry = setupRegistry(c, false, "", "")
|
|
|
|
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
err := plugin.CreateInRegistry(ctx, ps.getPluginRepo(), nil)
|
|
|
|
c.Assert(err, checker.IsNil, check.Commentf("failed to create plugin"))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ps *DockerPluginSuite) TearDownSuite(c *check.C) {
|
|
|
|
if ps.registry != nil {
|
|
|
|
ps.registry.Close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ps *DockerPluginSuite) TearDownTest(c *check.C) {
|
|
|
|
ps.ds.TearDownTest(c)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ps *DockerPluginSuite) OnTimeout(c *check.C) {
|
|
|
|
ps.ds.OnTimeout(c)
|
|
|
|
}
|