diff --git a/hack/test/e2e-run.sh b/hack/test/e2e-run.sh index b80f7fc312..b1470d6547 100755 --- a/hack/test/e2e-run.sh +++ b/hack/test/e2e-run.sh @@ -13,8 +13,8 @@ export DOCKER_ENGINE_GOARCH=${DOCKER_ENGINE_GOARCH:-${ARCH}} : ${TESTDEBUG:=} integration_api_dirs=${TEST_INTEGRATION_DIR:-"$( - find ./integration -type d | - grep -vE '(^./integration($|/internal)|/testdata)')"} + find /tests/integration -type d | + grep -vE '(^/tests/integration($|/internal)|/testdata)')"} run_test_integration() { [[ "$TESTFLAGS" != *-check.f* ]] && run_test_integration_suites @@ -35,7 +35,7 @@ run_test_integration_suites() { run_test_integration_legacy_suites() { ( flags="-check.v -check.timeout=${TIMEOUT} -test.timeout=360m $TESTFLAGS" - cd test/integration-cli + cd /tests/integration-cli echo "Running $PWD" test_env ./test.main $flags ) diff --git a/integration/build/build_test.go b/integration/build/build_test.go index 9d396da865..d8cb298cd4 100644 --- a/integration/build/build_test.go +++ b/integration/build/build_test.go @@ -5,6 +5,7 @@ import ( "bytes" "context" "encoding/json" + "fmt" "io" "io/ioutil" "strings" @@ -12,11 +13,13 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/integration-cli/cli/build/fakecontext" "github.com/docker/docker/integration/internal/request" "github.com/docker/docker/pkg/jsonmessage" "github.com/gotestyourself/gotestyourself/assert" is "github.com/gotestyourself/gotestyourself/assert/cmp" + "github.com/gotestyourself/gotestyourself/skip" ) func TestBuildWithRemoveAndForceRemove(t *testing.T) { @@ -304,6 +307,9 @@ COPY bar /` // docker/for-linux#135 // #35641 func TestBuildMultiStageLayerLeak(t *testing.T) { + fmt.Println(testEnv.DaemonAPIVersion()) + skip.IfCondition(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.38"), + "Don't run on API lower than 1.38 as it has been fixed starting from that version") ctx := context.TODO() defer setupTest(t)() diff --git a/integration/internal/swarm/service.go b/integration/internal/swarm/service.go index 0ec4d5175e..79705961a1 100644 --- a/integration/internal/swarm/service.go +++ b/integration/internal/swarm/service.go @@ -12,6 +12,7 @@ import ( "github.com/docker/docker/integration-cli/daemon" "github.com/docker/docker/internal/test/environment" "github.com/gotestyourself/gotestyourself/assert" + "github.com/gotestyourself/gotestyourself/skip" ) const ( @@ -21,6 +22,7 @@ const ( // NewSwarm creates a swarm daemon for testing func NewSwarm(t *testing.T, testEnv *environment.Execution) *daemon.Swarm { + skip.IfCondition(t, testEnv.IsRemoteDaemon()) d := &daemon.Swarm{ Daemon: daemon.New(t, "", dockerdBinary, daemon.Config{ Experimental: testEnv.DaemonInfo.ExperimentalBuild, diff --git a/integration/network/inspect_test.go b/integration/network/inspect_test.go index 3afdcf1ac4..ad4a344c49 100644 --- a/integration/network/inspect_test.go +++ b/integration/network/inspect_test.go @@ -1,16 +1,15 @@ package network // import "github.com/docker/docker/integration/network" import ( - "fmt" "runtime" "testing" "time" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/swarm" + swarmtypes "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/client" - "github.com/docker/docker/integration-cli/daemon" + "github.com/docker/docker/integration/internal/swarm" "github.com/gotestyourself/gotestyourself/assert" "github.com/gotestyourself/gotestyourself/poll" "golang.org/x/net/context" @@ -21,7 +20,7 @@ const dockerdBinary = "dockerd" func TestInspectNetwork(t *testing.T) { defer setupTest(t)() - d := newSwarm(t) + d := swarm.NewSwarm(t, testEnv) defer d.Stop(t) client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) assert.NilError(t, err) @@ -38,8 +37,9 @@ func TestInspectNetwork(t *testing.T) { var instances uint64 = 4 serviceName := "TestService" + // FIXME(vdemeester) consolidate with swarm.CreateService serviceSpec := swarmServiceSpec(serviceName, instances) - serviceSpec.TaskTemplate.Networks = append(serviceSpec.TaskTemplate.Networks, swarm.NetworkAttachmentConfig{Target: overlayName}) + serviceSpec.TaskTemplate.Networks = append(serviceSpec.TaskTemplate.Networks, swarmtypes.NetworkAttachmentConfig{Target: overlayName}) serviceResp, err := client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{ QueryRegistry: false, @@ -107,38 +107,19 @@ func TestInspectNetwork(t *testing.T) { poll.WaitOn(t, networkIsRemoved(client, overlayID), poll.WithTimeout(1*time.Minute), poll.WithDelay(10*time.Second)) } -func newSwarm(t *testing.T) *daemon.Swarm { - d := &daemon.Swarm{ - Daemon: daemon.New(t, "", dockerdBinary, daemon.Config{ - Experimental: testEnv.DaemonInfo.ExperimentalBuild, - }), - // TODO: better method of finding an unused port - Port: defaultSwarmPort, - } - // TODO: move to a NewSwarm constructor - d.ListenAddr = fmt.Sprintf("0.0.0.0:%d", d.Port) - - // avoid networking conflicts - args := []string{"--iptables=false", "--swarm-default-advertise-addr=lo"} - d.StartWithBusybox(t, args...) - - assert.NilError(t, d.Init(swarm.InitRequest{})) - return d -} - -func swarmServiceSpec(name string, replicas uint64) swarm.ServiceSpec { - return swarm.ServiceSpec{ - Annotations: swarm.Annotations{ +func swarmServiceSpec(name string, replicas uint64) swarmtypes.ServiceSpec { + return swarmtypes.ServiceSpec{ + Annotations: swarmtypes.Annotations{ Name: name, }, - TaskTemplate: swarm.TaskSpec{ - ContainerSpec: &swarm.ContainerSpec{ + TaskTemplate: swarmtypes.TaskSpec{ + ContainerSpec: &swarmtypes.ContainerSpec{ Image: "busybox:latest", Command: []string{"/bin/top"}, }, }, - Mode: swarm.ServiceMode{ - Replicated: &swarm.ReplicatedService{ + Mode: swarmtypes.ServiceMode{ + Replicated: &swarmtypes.ReplicatedService{ Replicas: &replicas, }, }, @@ -157,7 +138,7 @@ func serviceRunningTasksCount(client client.ServiceAPIClient, serviceID string, return poll.Error(err) case len(tasks) == int(instances): for _, task := range tasks { - if task.Status.State != swarm.TaskStateRunning { + if task.Status.State != swarmtypes.TaskStateRunning { return poll.Continue("waiting for tasks to enter run state") } } diff --git a/integration/network/service_test.go b/integration/network/service_test.go index b8470a1e85..a9fccf9522 100644 --- a/integration/network/service_test.go +++ b/integration/network/service_test.go @@ -7,8 +7,9 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/swarm" + swarmtypes "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/client" + "github.com/docker/docker/integration/internal/swarm" "github.com/gotestyourself/gotestyourself/assert" "github.com/gotestyourself/gotestyourself/poll" "golang.org/x/net/context" @@ -16,7 +17,7 @@ import ( func TestServiceWithPredefinedNetwork(t *testing.T) { defer setupTest(t)() - d := newSwarm(t) + d := swarm.NewSwarm(t, testEnv) defer d.Stop(t) client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) assert.NilError(t, err) @@ -25,7 +26,7 @@ func TestServiceWithPredefinedNetwork(t *testing.T) { var instances uint64 = 1 serviceName := "TestService" serviceSpec := swarmServiceSpec(serviceName, instances) - serviceSpec.TaskTemplate.Networks = append(serviceSpec.TaskTemplate.Networks, swarm.NetworkAttachmentConfig{Target: hostName}) + serviceSpec.TaskTemplate.Networks = append(serviceSpec.TaskTemplate.Networks, swarmtypes.NetworkAttachmentConfig{Target: hostName}) serviceResp, err := client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{ QueryRegistry: false, @@ -60,7 +61,7 @@ const ingressNet = "ingress" func TestServiceWithIngressNetwork(t *testing.T) { defer setupTest(t)() - d := newSwarm(t) + d := swarm.NewSwarm(t, testEnv) defer d.Stop(t) client, err := client.NewClientWithOpts(client.WithHost((d.Sock()))) @@ -81,13 +82,13 @@ func TestServiceWithIngressNetwork(t *testing.T) { var instances uint64 = 1 serviceName := "TestIngressService" serviceSpec := swarmServiceSpec(serviceName, instances) - serviceSpec.TaskTemplate.Networks = append(serviceSpec.TaskTemplate.Networks, swarm.NetworkAttachmentConfig{Target: ingressNet}) - serviceSpec.EndpointSpec = &swarm.EndpointSpec{ - Ports: []swarm.PortConfig{ + serviceSpec.TaskTemplate.Networks = append(serviceSpec.TaskTemplate.Networks, swarmtypes.NetworkAttachmentConfig{Target: ingressNet}) + serviceSpec.EndpointSpec = &swarmtypes.EndpointSpec{ + Ports: []swarmtypes.PortConfig{ { - Protocol: swarm.PortConfigProtocolTCP, + Protocol: swarmtypes.PortConfigProtocolTCP, TargetPort: 80, - PublishMode: swarm.PortConfigPublishModeIngress, + PublishMode: swarmtypes.PortConfigPublishModeIngress, }, }, } diff --git a/integration/plugin/authz/main_test.go b/integration/plugin/authz/main_test.go index ea72a03f16..3d5f406b92 100644 --- a/integration/plugin/authz/main_test.go +++ b/integration/plugin/authz/main_test.go @@ -16,6 +16,7 @@ import ( "github.com/docker/docker/internal/test/environment" "github.com/docker/docker/pkg/authorization" "github.com/docker/docker/pkg/plugins" + "github.com/gotestyourself/gotestyourself/skip" ) var ( @@ -48,6 +49,7 @@ func TestMain(m *testing.M) { } func setupTest(t *testing.T) func() { + skip.IfCondition(t, testEnv.IsRemoteDaemon(), "cannot run daemon when remote daemon") environment.ProtectAll(t, testEnv) d = daemon.New(t, "", dockerdBinary, daemon.Config{ diff --git a/integration/plugin/logging/helpers_test.go b/integration/plugin/logging/helpers_test.go index 61b2f35f43..371d43d831 100644 --- a/integration/plugin/logging/helpers_test.go +++ b/integration/plugin/logging/helpers_test.go @@ -14,8 +14,6 @@ import ( "github.com/pkg/errors" ) -const dockerdBinary = "dockerd" - var pluginBuildLock = locker.New() func ensurePlugin(t *testing.T, name string) string { diff --git a/integration/plugin/logging/main_test.go b/integration/plugin/logging/main_test.go new file mode 100644 index 0000000000..b2446ca8c8 --- /dev/null +++ b/integration/plugin/logging/main_test.go @@ -0,0 +1,31 @@ +package logging // import "github.com/docker/docker/integration/plugin/logging" + +import ( + "fmt" + "os" + "testing" + + "github.com/docker/docker/internal/test/environment" +) + +var ( + testEnv *environment.Execution +) + +const dockerdBinary = "dockerd" + +func TestMain(m *testing.M) { + var err error + testEnv, err = environment.New() + if err != nil { + fmt.Println(err) + os.Exit(1) + } + err = environment.EnsureFrozenImagesLinux(testEnv) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + testEnv.Print() + os.Exit(m.Run()) +} diff --git a/integration/plugin/logging/validation_test.go b/integration/plugin/logging/validation_test.go index eb3fe7a029..f0d6e9e8b2 100644 --- a/integration/plugin/logging/validation_test.go +++ b/integration/plugin/logging/validation_test.go @@ -7,12 +7,14 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/integration-cli/daemon" "github.com/gotestyourself/gotestyourself/assert" + "github.com/gotestyourself/gotestyourself/skip" ) // Regression test for #35553 // Ensure that a daemon with a log plugin set as the default logger for containers // does not keep the daemon from starting. func TestDaemonStartWithLogOpt(t *testing.T) { + skip.IfCondition(t, testEnv.IsRemoteDaemon(), "cannot run daemon when remote daemon") t.Parallel() d := daemon.New(t, "", dockerdBinary, daemon.Config{}) diff --git a/internal/test/environment/environment.go b/internal/test/environment/environment.go index 16f6146334..8e6e2c72fa 100644 --- a/internal/test/environment/environment.go +++ b/internal/test/environment/environment.go @@ -121,6 +121,15 @@ func (e *Execution) IsRemoteDaemon() bool { return !e.IsLocalDaemon() } +// DaemonAPIVersion returns the negociated daemon api version +func (e *Execution) DaemonAPIVersion() string { + version, err := e.APIClient().ServerVersion(context.TODO()) + if err != nil { + return "" + } + return version.APIVersion +} + // Print the execution details to stdout // TODO: print everything func (e *Execution) Print() {