2015-04-18 12:46:47 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2018-04-19 18:30:59 -04:00
|
|
|
"context"
|
2019-08-08 20:38:35 -04:00
|
|
|
"flag"
|
2015-06-05 16:09:53 -04:00
|
|
|
"fmt"
|
2017-08-25 18:48:36 -04:00
|
|
|
"io/ioutil"
|
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"
|
2017-08-25 18:48:36 -04:00
|
|
|
"strconv"
|
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
|
|
|
|
2017-03-23 13:35:22 -04:00
|
|
|
"github.com/docker/docker/integration-cli/cli"
|
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"
|
2019-08-08 20:38:35 -04:00
|
|
|
"github.com/docker/docker/internal/test/suite"
|
2015-06-05 16:09:53 -04:00
|
|
|
"github.com/docker/docker/pkg/reexec"
|
2019-08-29 16:52:40 -04:00
|
|
|
testdaemon "github.com/docker/docker/testutil/daemon"
|
|
|
|
ienv "github.com/docker/docker/testutil/environment"
|
|
|
|
"github.com/docker/docker/testutil/fakestorage"
|
|
|
|
"github.com/docker/docker/testutil/fixtures/plugin"
|
|
|
|
"github.com/docker/docker/testutil/registry"
|
2019-04-04 09:23:19 -04:00
|
|
|
"gotest.tools/assert"
|
2015-04-18 12:46:47 -04:00
|
|
|
)
|
|
|
|
|
2016-12-25 14:28:38 -05:00
|
|
|
const (
|
|
|
|
// the private registry to use for tests
|
2018-04-13 04:45:34 -04:00
|
|
|
privateRegistryURL = registry.DefaultURL
|
2016-12-25 14:28:38 -05:00
|
|
|
|
|
|
|
// path to containerd's ctr binary
|
2018-09-21 18:58:34 -04:00
|
|
|
ctrBinary = "ctr"
|
2016-12-25 14:28:38 -05:00
|
|
|
|
|
|
|
// 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 = ""
|
2019-09-12 14:05:18 -04:00
|
|
|
|
|
|
|
testEnvOnce sync.Once
|
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) {
|
2019-08-08 20:38:35 -04:00
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
// Global set up
|
2017-03-23 13:35:22 -04:00
|
|
|
dockerBinary = testEnv.DockerBinary()
|
2017-10-24 14:24:25 -04:00
|
|
|
err := ienv.EnsureFrozenImagesLinux(&testEnv.Execution)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2017-08-25 18:48:36 -04:00
|
|
|
testEnv.Print()
|
|
|
|
os.Exit(m.Run())
|
2016-12-25 14:28:38 -05:00
|
|
|
}
|
2015-06-05 16:09:53 -04:00
|
|
|
|
2019-09-12 14:05:18 -04:00
|
|
|
func ensureTestEnvSetup(t *testing.T) {
|
|
|
|
testEnvOnce.Do(func() {
|
|
|
|
cli.SetTestEnvironment(testEnv)
|
|
|
|
fakestorage.SetTestEnvironment(&testEnv.Execution)
|
|
|
|
ienv.ProtectAll(t, &testEnv.Execution)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDockerSuite(t *testing.T) {
|
|
|
|
ensureTestEnvSetup(t)
|
2019-08-08 20:38:35 -04:00
|
|
|
suite.Run(t, &DockerSuite{})
|
2019-09-12 14:05:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestDockerRegistrySuite(t *testing.T) {
|
|
|
|
ensureTestEnvSetup(t)
|
2019-08-08 20:38:35 -04:00
|
|
|
suite.Run(t, &DockerRegistrySuite{ds: &DockerSuite{}})
|
2019-09-12 14:05:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestDockerSchema1RegistrySuite(t *testing.T) {
|
|
|
|
ensureTestEnvSetup(t)
|
2019-08-08 20:38:35 -04:00
|
|
|
suite.Run(t, &DockerSchema1RegistrySuite{ds: &DockerSuite{}})
|
2019-09-12 14:05:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestDockerRegistryAuthHtpasswdSuite(t *testing.T) {
|
|
|
|
ensureTestEnvSetup(t)
|
2019-08-08 20:38:35 -04:00
|
|
|
suite.Run(t, &DockerRegistryAuthHtpasswdSuite{ds: &DockerSuite{}})
|
2019-09-12 14:05:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestDockerRegistryAuthTokenSuite(t *testing.T) {
|
|
|
|
ensureTestEnvSetup(t)
|
2019-08-08 20:38:35 -04:00
|
|
|
suite.Run(t, &DockerRegistryAuthTokenSuite{ds: &DockerSuite{}})
|
2019-09-12 14:05:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestDockerDaemonSuite(t *testing.T) {
|
|
|
|
ensureTestEnvSetup(t)
|
2019-08-08 20:38:35 -04:00
|
|
|
suite.Run(t, &DockerDaemonSuite{ds: &DockerSuite{}})
|
2019-09-12 14:05:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestDockerSwarmSuite(t *testing.T) {
|
|
|
|
ensureTestEnvSetup(t)
|
2019-08-08 20:38:35 -04:00
|
|
|
suite.Run(t, &DockerSwarmSuite{ds: &DockerSuite{}})
|
2019-09-12 14:05:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestDockerPluginSuite(t *testing.T) {
|
|
|
|
ensureTestEnvSetup(t)
|
2019-08-08 20:38:35 -04:00
|
|
|
suite.Run(t, &DockerPluginSuite{ds: &DockerSuite{}})
|
2019-09-12 14:05:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestDockerExternalVolumeSuite(t *testing.T) {
|
|
|
|
ensureTestEnvSetup(t)
|
|
|
|
testRequires(t, DaemonIsLinux)
|
|
|
|
suite.Run(t, &DockerExternalVolumeSuite{ds: &DockerSuite{}})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDockerNetworkSuite(t *testing.T) {
|
|
|
|
ensureTestEnvSetup(t)
|
|
|
|
testRequires(t, DaemonIsLinux)
|
2019-09-30 09:49:33 -04:00
|
|
|
suite.Run(t, &DockerNetworkSuite{ds: &DockerSuite{}})
|
2019-09-12 14:05:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestDockerHubPullSuite(t *testing.T) {
|
|
|
|
ensureTestEnvSetup(t)
|
|
|
|
// FIXME. Temporarily turning this off for Windows as GH16039 was breaking
|
|
|
|
// Windows to Linux CI @icecrime
|
|
|
|
testRequires(t, DaemonIsLinux)
|
|
|
|
suite.Run(t, newDockerHubPullSuite())
|
2015-04-24 17:16:56 -04:00
|
|
|
}
|
|
|
|
|
2015-04-18 12:46:47 -04:00
|
|
|
type DockerSuite struct {
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerSuite) OnTimeout(c *testing.T) {
|
2018-03-02 08:45:14 -05:00
|
|
|
if testEnv.IsRemoteDaemon() {
|
2017-09-13 17:00:55 -04:00
|
|
|
return
|
|
|
|
}
|
2017-08-25 18:48:36 -04:00
|
|
|
path := filepath.Join(os.Getenv("DEST"), "docker.pid")
|
|
|
|
b, err := ioutil.ReadFile(path)
|
|
|
|
if err != nil {
|
|
|
|
c.Fatalf("Failed to get daemon PID from %s\n", path)
|
|
|
|
}
|
|
|
|
|
|
|
|
rawPid, err := strconv.ParseInt(string(b), 10, 32)
|
|
|
|
if err != nil {
|
|
|
|
c.Fatalf("Failed to parse pid from %s: %s\n", path, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
daemonPid := int(rawPid)
|
2017-09-13 17:00:55 -04:00
|
|
|
if daemonPid > 0 {
|
2018-04-10 10:29:48 -04:00
|
|
|
testdaemon.SignalDaemonDump(daemonPid)
|
2016-07-27 14:17:44 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerSuite) TearDownTest(c *testing.T) {
|
2017-08-25 18:48:36 -04:00
|
|
|
testEnv.Clean(c)
|
2015-04-18 12:46:47 -04:00
|
|
|
}
|
|
|
|
|
2015-04-24 17:16:56 -04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerRegistrySuite) OnTimeout(c *testing.T) {
|
2016-07-27 14:17:44 -04:00
|
|
|
s.d.DumpStackAndQuit()
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerRegistrySuite) SetUpTest(c *testing.T) {
|
2018-12-24 07:25:53 -05:00
|
|
|
testRequires(c, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon)
|
2018-04-13 04:45:34 -04:00
|
|
|
s.reg = registry.NewV2(c)
|
|
|
|
s.reg.WaitReady(c)
|
2018-04-13 11:02:56 -04:00
|
|
|
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
|
2015-04-24 17:16:56 -04:00
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerRegistrySuite) TearDownTest(c *testing.T) {
|
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
|
|
|
|
2019-06-17 17:50:31 -04:00
|
|
|
type DockerSchema1RegistrySuite struct {
|
|
|
|
ds *DockerSuite
|
|
|
|
reg *registry.V2
|
|
|
|
d *daemon.Daemon
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerSchema1RegistrySuite) OnTimeout(c *testing.T) {
|
2019-06-17 17:50:31 -04:00
|
|
|
s.d.DumpStackAndQuit()
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerSchema1RegistrySuite) SetUpTest(c *testing.T) {
|
2019-06-17 17:50:31 -04:00
|
|
|
testRequires(c, DaemonIsLinux, RegistryHosting, NotArm64, testEnv.IsLocalDaemon)
|
|
|
|
s.reg = registry.NewV2(c, registry.Schema1)
|
|
|
|
s.reg.WaitReady(c)
|
|
|
|
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerSchema1RegistrySuite) TearDownTest(c *testing.T) {
|
2019-06-17 17:50:31 -04:00
|
|
|
if s.reg != nil {
|
|
|
|
s.reg.Close()
|
|
|
|
}
|
|
|
|
if s.d != nil {
|
|
|
|
s.d.Stop(c)
|
|
|
|
}
|
|
|
|
s.ds.TearDownTest(c)
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerRegistryAuthHtpasswdSuite) OnTimeout(c *testing.T) {
|
2016-07-27 14:17:44 -04:00
|
|
|
s.d.DumpStackAndQuit()
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerRegistryAuthHtpasswdSuite) SetUpTest(c *testing.T) {
|
2018-12-24 07:25:53 -05:00
|
|
|
testRequires(c, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon)
|
2018-04-13 04:45:34 -04:00
|
|
|
s.reg = registry.NewV2(c, registry.Htpasswd)
|
|
|
|
s.reg.WaitReady(c)
|
2018-04-13 11:02:56 -04:00
|
|
|
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
|
2016-01-23 13:45:01 -05:00
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerRegistryAuthHtpasswdSuite) TearDownTest(c *testing.T) {
|
2016-01-23 13:45:01 -05:00
|
|
|
if s.reg != nil {
|
|
|
|
out, err := s.d.Cmd("logout", privateRegistryURL)
|
2019-04-04 09:23:19 -04:00
|
|
|
assert.NilError(c, err, out)
|
2016-01-23 13:45:01 -05:00
|
|
|
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
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerRegistryAuthTokenSuite) OnTimeout(c *testing.T) {
|
2016-07-27 14:17:44 -04:00
|
|
|
s.d.DumpStackAndQuit()
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerRegistryAuthTokenSuite) SetUpTest(c *testing.T) {
|
2018-12-24 07:25:53 -05:00
|
|
|
testRequires(c, DaemonIsLinux, RegistryHosting, testEnv.IsLocalDaemon)
|
2018-04-13 11:02:56 -04:00
|
|
|
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
|
2016-03-14 16:11:35 -04:00
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerRegistryAuthTokenSuite) TearDownTest(c *testing.T) {
|
2016-03-14 16:11:35 -04:00
|
|
|
if s.reg != nil {
|
|
|
|
out, err := s.d.Cmd("logout", privateRegistryURL)
|
2019-04-04 09:23:19 -04:00
|
|
|
assert.NilError(c, err, out)
|
2016-03-14 16:11:35 -04:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerRegistryAuthTokenSuite) setupRegistryWithTokenService(c *testing.T, tokenURL string) {
|
2016-03-14 16:11:35 -04:00
|
|
|
if s == nil {
|
|
|
|
c.Fatal("registry suite isn't initialized")
|
|
|
|
}
|
2018-04-13 04:45:34 -04:00
|
|
|
s.reg = registry.NewV2(c, registry.Token(tokenURL))
|
|
|
|
s.reg.WaitReady(c)
|
2016-03-14 16:11:35 -04:00
|
|
|
}
|
|
|
|
|
2015-04-25 22:47:42 -04:00
|
|
|
type DockerDaemonSuite struct {
|
|
|
|
ds *DockerSuite
|
2016-12-09 04:17:53 -05:00
|
|
|
d *daemon.Daemon
|
2015-04-25 22:47:42 -04:00
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerDaemonSuite) OnTimeout(c *testing.T) {
|
2016-07-27 14:17:44 -04:00
|
|
|
s.d.DumpStackAndQuit()
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerDaemonSuite) SetUpTest(c *testing.T) {
|
2018-12-24 07:25:53 -05:00
|
|
|
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
|
2018-04-13 11:02:56 -04:00
|
|
|
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
|
2015-04-25 22:47:42 -04:00
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerDaemonSuite) TearDownTest(c *testing.T) {
|
2018-12-24 07:25:53 -05:00
|
|
|
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
|
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
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerDaemonSuite) TearDownSuite(c *testing.T) {
|
2018-04-10 10:29:48 -04:00
|
|
|
filepath.Walk(testdaemon.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
|
|
|
|
})
|
2018-04-10 10:29:48 -04:00
|
|
|
os.RemoveAll(testdaemon.SockRoot)
|
2016-07-28 10:19:09 -04:00
|
|
|
}
|
|
|
|
|
2016-06-13 22:54:20 -04:00
|
|
|
const defaultSwarmPort = 2477
|
|
|
|
|
|
|
|
type DockerSwarmSuite struct {
|
2016-10-15 13:20:34 -04:00
|
|
|
server *httptest.Server
|
2016-06-29 14:00:11 -04:00
|
|
|
ds *DockerSuite
|
2019-07-12 21:13:37 -04:00
|
|
|
daemonsLock sync.Mutex // protect access to daemons and portIndex
|
2018-04-11 06:10:17 -04:00
|
|
|
daemons []*daemon.Daemon
|
2016-06-29 14:00:11 -04:00
|
|
|
portIndex int
|
2016-06-13 22:54:20 -04:00
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerSwarmSuite) OnTimeout(c *testing.T) {
|
2016-07-27 14:17:44 -04:00
|
|
|
s.daemonsLock.Lock()
|
|
|
|
defer s.daemonsLock.Unlock()
|
|
|
|
for _, d := range s.daemons {
|
|
|
|
d.DumpStackAndQuit()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerSwarmSuite) SetUpTest(c *testing.T) {
|
2018-12-24 07:25:53 -05:00
|
|
|
testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon)
|
2016-06-13 22:54:20 -04:00
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerSwarmSuite) AddDaemon(c *testing.T, joinSwarm, manager bool) *daemon.Daemon {
|
2018-04-13 11:02:56 -04:00
|
|
|
d := daemon.New(c, dockerBinary, dockerdBinary,
|
|
|
|
testdaemon.WithEnvironment(testEnv.Execution),
|
|
|
|
testdaemon.WithSwarmPort(defaultSwarmPort+s.portIndex),
|
|
|
|
)
|
2017-10-16 23:30:05 -04:00
|
|
|
if joinSwarm {
|
2016-06-13 22:54:20 -04:00
|
|
|
if len(s.daemons) > 0 {
|
2018-04-13 11:02:56 -04:00
|
|
|
d.StartAndSwarmJoin(c, s.daemons[0].Daemon, manager)
|
2016-07-20 14:15:08 -04:00
|
|
|
} else {
|
2018-04-13 11:02:56 -04:00
|
|
|
d.StartAndSwarmInit(c)
|
2016-06-13 22:54:20 -04:00
|
|
|
}
|
2018-04-13 11:02:56 -04:00
|
|
|
} else {
|
2019-09-09 16:38:44 -04:00
|
|
|
d.StartNodeWithBusybox(c)
|
2016-06-13 22:54:20 -04:00
|
|
|
}
|
|
|
|
|
2016-06-29 14:00:11 -04:00
|
|
|
s.daemonsLock.Lock()
|
2019-07-12 21:13:37 -04:00
|
|
|
s.portIndex++
|
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
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (s *DockerSwarmSuite) TearDownTest(c *testing.T) {
|
2016-06-13 22:54:20 -04:00
|
|
|
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)
|
2018-04-17 06:00:38 -04:00
|
|
|
d.Cleanup(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.portIndex = 0
|
2019-07-12 21:13:37 -04:00
|
|
|
s.daemonsLock.Unlock()
|
2016-06-13 22:54:20 -04:00
|
|
|
s.ds.TearDownTest(c)
|
|
|
|
}
|
|
|
|
|
2017-07-12 16:31:13 -04:00
|
|
|
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"
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (ps *DockerPluginSuite) SetUpSuite(c *testing.T) {
|
2018-04-13 04:45:34 -04:00
|
|
|
testRequires(c, DaemonIsLinux, RegistryHosting)
|
|
|
|
ps.registry = registry.NewV2(c)
|
|
|
|
ps.registry.WaitReady(c)
|
2017-07-12 16:31:13 -04:00
|
|
|
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
err := plugin.CreateInRegistry(ctx, ps.getPluginRepo(), nil)
|
2019-04-04 09:23:19 -04:00
|
|
|
assert.NilError(c, err, "failed to create plugin")
|
2017-07-12 16:31:13 -04:00
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (ps *DockerPluginSuite) TearDownSuite(c *testing.T) {
|
2017-07-12 16:31:13 -04:00
|
|
|
if ps.registry != nil {
|
|
|
|
ps.registry.Close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (ps *DockerPluginSuite) TearDownTest(c *testing.T) {
|
2017-07-12 16:31:13 -04:00
|
|
|
ps.ds.TearDownTest(c)
|
|
|
|
}
|
|
|
|
|
2019-09-09 17:05:55 -04:00
|
|
|
func (ps *DockerPluginSuite) OnTimeout(c *testing.T) {
|
2017-07-12 16:31:13 -04:00
|
|
|
ps.ds.OnTimeout(c)
|
|
|
|
}
|