mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
integration/*: make e2e run without failure
… mainly by skipping if daemon is remote. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
7bda5be956
commit
6016e79d25
10 changed files with 78 additions and 46 deletions
|
@ -13,8 +13,8 @@ export DOCKER_ENGINE_GOARCH=${DOCKER_ENGINE_GOARCH:-${ARCH}}
|
||||||
: ${TESTDEBUG:=}
|
: ${TESTDEBUG:=}
|
||||||
|
|
||||||
integration_api_dirs=${TEST_INTEGRATION_DIR:-"$(
|
integration_api_dirs=${TEST_INTEGRATION_DIR:-"$(
|
||||||
find ./integration -type d |
|
find /tests/integration -type d |
|
||||||
grep -vE '(^./integration($|/internal)|/testdata)')"}
|
grep -vE '(^/tests/integration($|/internal)|/testdata)')"}
|
||||||
|
|
||||||
run_test_integration() {
|
run_test_integration() {
|
||||||
[[ "$TESTFLAGS" != *-check.f* ]] && run_test_integration_suites
|
[[ "$TESTFLAGS" != *-check.f* ]] && run_test_integration_suites
|
||||||
|
@ -35,7 +35,7 @@ run_test_integration_suites() {
|
||||||
run_test_integration_legacy_suites() {
|
run_test_integration_legacy_suites() {
|
||||||
(
|
(
|
||||||
flags="-check.v -check.timeout=${TIMEOUT} -test.timeout=360m $TESTFLAGS"
|
flags="-check.v -check.timeout=${TIMEOUT} -test.timeout=360m $TESTFLAGS"
|
||||||
cd test/integration-cli
|
cd /tests/integration-cli
|
||||||
echo "Running $PWD"
|
echo "Running $PWD"
|
||||||
test_env ./test.main $flags
|
test_env ./test.main $flags
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -12,11 +13,13 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"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-cli/cli/build/fakecontext"
|
||||||
"github.com/docker/docker/integration/internal/request"
|
"github.com/docker/docker/integration/internal/request"
|
||||||
"github.com/docker/docker/pkg/jsonmessage"
|
"github.com/docker/docker/pkg/jsonmessage"
|
||||||
"github.com/gotestyourself/gotestyourself/assert"
|
"github.com/gotestyourself/gotestyourself/assert"
|
||||||
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
is "github.com/gotestyourself/gotestyourself/assert/cmp"
|
||||||
|
"github.com/gotestyourself/gotestyourself/skip"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBuildWithRemoveAndForceRemove(t *testing.T) {
|
func TestBuildWithRemoveAndForceRemove(t *testing.T) {
|
||||||
|
@ -304,6 +307,9 @@ COPY bar /`
|
||||||
// docker/for-linux#135
|
// docker/for-linux#135
|
||||||
// #35641
|
// #35641
|
||||||
func TestBuildMultiStageLayerLeak(t *testing.T) {
|
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()
|
ctx := context.TODO()
|
||||||
defer setupTest(t)()
|
defer setupTest(t)()
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/docker/docker/integration-cli/daemon"
|
"github.com/docker/docker/integration-cli/daemon"
|
||||||
"github.com/docker/docker/internal/test/environment"
|
"github.com/docker/docker/internal/test/environment"
|
||||||
"github.com/gotestyourself/gotestyourself/assert"
|
"github.com/gotestyourself/gotestyourself/assert"
|
||||||
|
"github.com/gotestyourself/gotestyourself/skip"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -21,6 +22,7 @@ const (
|
||||||
|
|
||||||
// NewSwarm creates a swarm daemon for testing
|
// NewSwarm creates a swarm daemon for testing
|
||||||
func NewSwarm(t *testing.T, testEnv *environment.Execution) *daemon.Swarm {
|
func NewSwarm(t *testing.T, testEnv *environment.Execution) *daemon.Swarm {
|
||||||
|
skip.IfCondition(t, testEnv.IsRemoteDaemon())
|
||||||
d := &daemon.Swarm{
|
d := &daemon.Swarm{
|
||||||
Daemon: daemon.New(t, "", dockerdBinary, daemon.Config{
|
Daemon: daemon.New(t, "", dockerdBinary, daemon.Config{
|
||||||
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
|
Experimental: testEnv.DaemonInfo.ExperimentalBuild,
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
package network // import "github.com/docker/docker/integration/network"
|
package network // import "github.com/docker/docker/integration/network"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"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/client"
|
||||||
"github.com/docker/docker/integration-cli/daemon"
|
"github.com/docker/docker/integration/internal/swarm"
|
||||||
"github.com/gotestyourself/gotestyourself/assert"
|
"github.com/gotestyourself/gotestyourself/assert"
|
||||||
"github.com/gotestyourself/gotestyourself/poll"
|
"github.com/gotestyourself/gotestyourself/poll"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
@ -21,7 +20,7 @@ const dockerdBinary = "dockerd"
|
||||||
|
|
||||||
func TestInspectNetwork(t *testing.T) {
|
func TestInspectNetwork(t *testing.T) {
|
||||||
defer setupTest(t)()
|
defer setupTest(t)()
|
||||||
d := newSwarm(t)
|
d := swarm.NewSwarm(t, testEnv)
|
||||||
defer d.Stop(t)
|
defer d.Stop(t)
|
||||||
client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
|
client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
@ -38,8 +37,9 @@ func TestInspectNetwork(t *testing.T) {
|
||||||
|
|
||||||
var instances uint64 = 4
|
var instances uint64 = 4
|
||||||
serviceName := "TestService"
|
serviceName := "TestService"
|
||||||
|
// FIXME(vdemeester) consolidate with swarm.CreateService
|
||||||
serviceSpec := swarmServiceSpec(serviceName, instances)
|
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{
|
serviceResp, err := client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{
|
||||||
QueryRegistry: false,
|
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))
|
poll.WaitOn(t, networkIsRemoved(client, overlayID), poll.WithTimeout(1*time.Minute), poll.WithDelay(10*time.Second))
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSwarm(t *testing.T) *daemon.Swarm {
|
func swarmServiceSpec(name string, replicas uint64) swarmtypes.ServiceSpec {
|
||||||
d := &daemon.Swarm{
|
return swarmtypes.ServiceSpec{
|
||||||
Daemon: daemon.New(t, "", dockerdBinary, daemon.Config{
|
Annotations: swarmtypes.Annotations{
|
||||||
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{
|
|
||||||
Name: name,
|
Name: name,
|
||||||
},
|
},
|
||||||
TaskTemplate: swarm.TaskSpec{
|
TaskTemplate: swarmtypes.TaskSpec{
|
||||||
ContainerSpec: &swarm.ContainerSpec{
|
ContainerSpec: &swarmtypes.ContainerSpec{
|
||||||
Image: "busybox:latest",
|
Image: "busybox:latest",
|
||||||
Command: []string{"/bin/top"},
|
Command: []string{"/bin/top"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Mode: swarm.ServiceMode{
|
Mode: swarmtypes.ServiceMode{
|
||||||
Replicated: &swarm.ReplicatedService{
|
Replicated: &swarmtypes.ReplicatedService{
|
||||||
Replicas: &replicas,
|
Replicas: &replicas,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -157,7 +138,7 @@ func serviceRunningTasksCount(client client.ServiceAPIClient, serviceID string,
|
||||||
return poll.Error(err)
|
return poll.Error(err)
|
||||||
case len(tasks) == int(instances):
|
case len(tasks) == int(instances):
|
||||||
for _, task := range tasks {
|
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")
|
return poll.Continue("waiting for tasks to enter run state")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,9 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"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/client"
|
||||||
|
"github.com/docker/docker/integration/internal/swarm"
|
||||||
"github.com/gotestyourself/gotestyourself/assert"
|
"github.com/gotestyourself/gotestyourself/assert"
|
||||||
"github.com/gotestyourself/gotestyourself/poll"
|
"github.com/gotestyourself/gotestyourself/poll"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
@ -16,7 +17,7 @@ import (
|
||||||
|
|
||||||
func TestServiceWithPredefinedNetwork(t *testing.T) {
|
func TestServiceWithPredefinedNetwork(t *testing.T) {
|
||||||
defer setupTest(t)()
|
defer setupTest(t)()
|
||||||
d := newSwarm(t)
|
d := swarm.NewSwarm(t, testEnv)
|
||||||
defer d.Stop(t)
|
defer d.Stop(t)
|
||||||
client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
|
client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
@ -25,7 +26,7 @@ func TestServiceWithPredefinedNetwork(t *testing.T) {
|
||||||
var instances uint64 = 1
|
var instances uint64 = 1
|
||||||
serviceName := "TestService"
|
serviceName := "TestService"
|
||||||
serviceSpec := swarmServiceSpec(serviceName, instances)
|
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{
|
serviceResp, err := client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{
|
||||||
QueryRegistry: false,
|
QueryRegistry: false,
|
||||||
|
@ -60,7 +61,7 @@ const ingressNet = "ingress"
|
||||||
|
|
||||||
func TestServiceWithIngressNetwork(t *testing.T) {
|
func TestServiceWithIngressNetwork(t *testing.T) {
|
||||||
defer setupTest(t)()
|
defer setupTest(t)()
|
||||||
d := newSwarm(t)
|
d := swarm.NewSwarm(t, testEnv)
|
||||||
defer d.Stop(t)
|
defer d.Stop(t)
|
||||||
|
|
||||||
client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
|
client, err := client.NewClientWithOpts(client.WithHost((d.Sock())))
|
||||||
|
@ -81,13 +82,13 @@ func TestServiceWithIngressNetwork(t *testing.T) {
|
||||||
var instances uint64 = 1
|
var instances uint64 = 1
|
||||||
serviceName := "TestIngressService"
|
serviceName := "TestIngressService"
|
||||||
serviceSpec := swarmServiceSpec(serviceName, instances)
|
serviceSpec := swarmServiceSpec(serviceName, instances)
|
||||||
serviceSpec.TaskTemplate.Networks = append(serviceSpec.TaskTemplate.Networks, swarm.NetworkAttachmentConfig{Target: ingressNet})
|
serviceSpec.TaskTemplate.Networks = append(serviceSpec.TaskTemplate.Networks, swarmtypes.NetworkAttachmentConfig{Target: ingressNet})
|
||||||
serviceSpec.EndpointSpec = &swarm.EndpointSpec{
|
serviceSpec.EndpointSpec = &swarmtypes.EndpointSpec{
|
||||||
Ports: []swarm.PortConfig{
|
Ports: []swarmtypes.PortConfig{
|
||||||
{
|
{
|
||||||
Protocol: swarm.PortConfigProtocolTCP,
|
Protocol: swarmtypes.PortConfigProtocolTCP,
|
||||||
TargetPort: 80,
|
TargetPort: 80,
|
||||||
PublishMode: swarm.PortConfigPublishModeIngress,
|
PublishMode: swarmtypes.PortConfigPublishModeIngress,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/docker/docker/internal/test/environment"
|
"github.com/docker/docker/internal/test/environment"
|
||||||
"github.com/docker/docker/pkg/authorization"
|
"github.com/docker/docker/pkg/authorization"
|
||||||
"github.com/docker/docker/pkg/plugins"
|
"github.com/docker/docker/pkg/plugins"
|
||||||
|
"github.com/gotestyourself/gotestyourself/skip"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -48,6 +49,7 @@ func TestMain(m *testing.M) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupTest(t *testing.T) func() {
|
func setupTest(t *testing.T) func() {
|
||||||
|
skip.IfCondition(t, testEnv.IsRemoteDaemon(), "cannot run daemon when remote daemon")
|
||||||
environment.ProtectAll(t, testEnv)
|
environment.ProtectAll(t, testEnv)
|
||||||
|
|
||||||
d = daemon.New(t, "", dockerdBinary, daemon.Config{
|
d = daemon.New(t, "", dockerdBinary, daemon.Config{
|
||||||
|
|
|
@ -14,8 +14,6 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const dockerdBinary = "dockerd"
|
|
||||||
|
|
||||||
var pluginBuildLock = locker.New()
|
var pluginBuildLock = locker.New()
|
||||||
|
|
||||||
func ensurePlugin(t *testing.T, name string) string {
|
func ensurePlugin(t *testing.T, name string) string {
|
||||||
|
|
31
integration/plugin/logging/main_test.go
Normal file
31
integration/plugin/logging/main_test.go
Normal file
|
@ -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())
|
||||||
|
}
|
|
@ -7,12 +7,14 @@ import (
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/integration-cli/daemon"
|
"github.com/docker/docker/integration-cli/daemon"
|
||||||
"github.com/gotestyourself/gotestyourself/assert"
|
"github.com/gotestyourself/gotestyourself/assert"
|
||||||
|
"github.com/gotestyourself/gotestyourself/skip"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Regression test for #35553
|
// Regression test for #35553
|
||||||
// Ensure that a daemon with a log plugin set as the default logger for containers
|
// Ensure that a daemon with a log plugin set as the default logger for containers
|
||||||
// does not keep the daemon from starting.
|
// does not keep the daemon from starting.
|
||||||
func TestDaemonStartWithLogOpt(t *testing.T) {
|
func TestDaemonStartWithLogOpt(t *testing.T) {
|
||||||
|
skip.IfCondition(t, testEnv.IsRemoteDaemon(), "cannot run daemon when remote daemon")
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
d := daemon.New(t, "", dockerdBinary, daemon.Config{})
|
d := daemon.New(t, "", dockerdBinary, daemon.Config{})
|
||||||
|
|
|
@ -121,6 +121,15 @@ func (e *Execution) IsRemoteDaemon() bool {
|
||||||
return !e.IsLocalDaemon()
|
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
|
// Print the execution details to stdout
|
||||||
// TODO: print everything
|
// TODO: print everything
|
||||||
func (e *Execution) Print() {
|
func (e *Execution) Print() {
|
||||||
|
|
Loading…
Reference in a new issue