Skip some tests in certain condition to run with e2e image

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester 2018-03-27 18:13:47 +02:00
parent f12574891c
commit e55d6fc857
16 changed files with 58 additions and 31 deletions

View File

@ -22,7 +22,7 @@ run_test_integration() {
}
run_test_integration_suites() {
local flags="-test.v -test.timeout=${TIMEOUT:=10m} $TESTFLAGS"
local flags="-test.v -test.timeout=${TIMEOUT:-10m} $TESTFLAGS"
for dir in $integration_api_dirs; do
if ! (
cd $dir
@ -34,7 +34,7 @@ run_test_integration_suites() {
run_test_integration_legacy_suites() {
(
flags="-check.v -check.timeout=${TIMEOUT} -test.timeout=360m $TESTFLAGS"
flags="-check.v -check.timeout=${TIMEOUT:-200m} -test.timeout=360m $TESTFLAGS"
cd /tests/integration-cli
echo "Running $PWD"
test_env ./test.main $flags
@ -68,4 +68,5 @@ test_env() {
)
}
sh /scripts/ensure-emptyfs.sh
run_test_integration

View File

@ -17,6 +17,7 @@ import (
type testingT interface {
assert.TestingT
logT
skipT
Fatal(args ...interface{})
Fatalf(string, ...interface{})
}
@ -25,6 +26,10 @@ type logT interface {
Logf(string, ...interface{})
}
type skipT interface {
Skip(reason string)
}
type gitServer interface {
URL() string
Close() error

View File

@ -23,6 +23,7 @@ var testEnv *environment.Execution
type testingT interface {
assert.TestingT
logT
skipT
Fatal(args ...interface{})
Fatalf(string, ...interface{})
}
@ -31,6 +32,10 @@ type logT interface {
Logf(string, ...interface{})
}
type skipT interface {
Skip(reason string)
}
// Fake is a static file server. It might be running locally or remotely
// on test host.
type Fake interface {
@ -51,10 +56,15 @@ func New(t testingT, dir string, modifiers ...func(*fakecontext.Fake) error) Fak
t.Fatal("fakstorage package requires SetTestEnvironment() to be called before use.")
}
ctx := fakecontext.New(t, dir, modifiers...)
if testEnv.IsLocalDaemon() {
switch {
case testEnv.IsRemoteDaemon() && strings.HasPrefix(request.DaemonHost(), "unix:///"):
t.Skip(fmt.Sprintf("e2e run : daemon is remote but docker host points to a unix socket"))
case testEnv.IsLocalDaemon():
return newLocalFakeStorage(ctx)
default:
return newRemoteFileServer(t, ctx)
}
return newRemoteFileServer(t, ctx)
return nil
}
// localFileStorage is a file storage on the running machine
@ -152,7 +162,6 @@ COPY . /static`); err != nil {
if err != nil {
t.Fatalf("unable to parse daemon host URL: %v", err)
}
host, _, err := net.SplitHostPort(dockerHostURL.Host)
if err != nil {
t.Fatalf("unable to parse docker daemon host:port: %v", err)

View File

@ -1713,7 +1713,9 @@ func (s *DockerSuite) TestContainersAPICreateMountsValidation(c *check.C) {
Type: "bind",
Source: notExistPath,
Target: destPath}}},
msg: "bind mount source path does not exist: " + notExistPath,
msg: "source path does not exist",
// FIXME(vdemeester) fails into e2e, migrate to integration/container anyway
// msg: "bind mount source path does not exist: " + notExistPath,
},
{
config: containertypes.Config{

View File

@ -115,7 +115,14 @@ func (s *DockerSuite) TestAPIImagesHistory(c *check.C) {
c.Assert(err, checker.IsNil)
c.Assert(historydata, checker.Not(checker.HasLen), 0)
c.Assert(historydata[0].Tags[0], checker.Equals, "test-api-images-history:latest")
var found bool
for _, tag := range historydata[0].Tags {
if tag == "test-api-images-history:latest" {
found = true
break
}
}
c.Assert(found, checker.True)
}
func (s *DockerSuite) TestAPIImagesImportBadSrc(c *check.C) {

View File

@ -93,7 +93,6 @@ func (s *DockerSuite) TestLogsAPIContainerNotFound(c *check.C) {
func (s *DockerSuite) TestLogsAPIUntilFutureFollow(c *check.C) {
testRequires(c, DaemonIsLinux)
name := "logsuntilfuturefollow"
dockerCmd(c, "run", "-d", "--name", name, "busybox", "/bin/sh", "-c", "while true; do date +%s; sleep 1; done")
c.Assert(waitRun(name), checker.IsNil)
@ -103,7 +102,7 @@ func (s *DockerSuite) TestLogsAPIUntilFutureFollow(c *check.C) {
c.Assert(err, checker.IsNil)
until := daemonTime(c).Add(untilDur)
client, err := request.NewClient()
client, err := client.NewEnvClient()
if err != nil {
c.Fatal(err)
}
@ -153,7 +152,7 @@ func (s *DockerSuite) TestLogsAPIUntil(c *check.C) {
name := "logsuntil"
dockerCmd(c, "run", "--name", name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do echo log$i; sleep 1; done")
client, err := request.NewClient()
client, err := client.NewEnvClient()
if err != nil {
c.Fatal(err)
}
@ -190,7 +189,7 @@ func (s *DockerSuite) TestLogsAPIUntilDefaultValue(c *check.C) {
name := "logsuntildefaultval"
dockerCmd(c, "run", "--name", name, "busybox", "/bin/sh", "-c", "for i in $(seq 1 3); do echo log$i; done")
client, err := request.NewClient()
client, err := client.NewEnvClient()
if err != nil {
c.Fatal(err)
}

View File

@ -1050,7 +1050,7 @@ func (s *DockerSuite) TestBuildAddBadLinksVolume(c *check.C) {
// Issue #5270 - ensure we throw a better error than "unexpected EOF"
// when we can't access files in the context.
func (s *DockerSuite) TestBuildWithInaccessibleFilesInContext(c *check.C) {
testRequires(c, DaemonIsLinux, UnixCli) // test uses chown/chmod: not available on windows
testRequires(c, DaemonIsLinux, UnixCli, SameHostDaemon) // test uses chown/chmod: not available on windows
{
name := "testbuildinaccessiblefiles"

View File

@ -379,7 +379,7 @@ func (s *DockerSuite) TestCpSymlinkComponent(c *check.C) {
// Check that cp with unprivileged user doesn't return any error
func (s *DockerSuite) TestCpUnprivilegedUser(c *check.C) {
testRequires(c, DaemonIsLinux)
testRequires(c, DaemonIsLinux, SameHostDaemon)
testRequires(c, UnixCli) // uses chmod/su: not available on windows
out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "touch "+cpTestName)

View File

@ -563,6 +563,8 @@ func (s *DockerRegistrySuite) TestEventsImageFilterPush(c *check.C) {
}
func (s *DockerSuite) TestEventsFilterType(c *check.C) {
// FIXME(vdemeester) fails on e2e run
testRequires(c, SameHostDaemon)
since := daemonUnixTime(c)
name := "labelfiltertest"
label := "io.docker.testing=image"

View File

@ -347,7 +347,7 @@ func (s *DockerExternalGraphdriverSuite) TearDownSuite(c *check.C) {
}
func (s *DockerExternalGraphdriverSuite) TestExternalGraphDriver(c *check.C) {
testRequires(c, ExperimentalDaemon)
testRequires(c, ExperimentalDaemon, SameHostDaemon)
s.testExternalGraphDriver("test-external-graph-driver", "spec", c)
s.testExternalGraphDriver("json-external-graph-driver", "json", c)
@ -395,7 +395,7 @@ func (s *DockerExternalGraphdriverSuite) testExternalGraphDriver(name string, ex
}
func (s *DockerExternalGraphdriverSuite) TestExternalGraphDriverPull(c *check.C) {
testRequires(c, Network, ExperimentalDaemon)
testRequires(c, Network, ExperimentalDaemon, SameHostDaemon)
s.d.Start(c)

View File

@ -36,7 +36,7 @@ func checkKernelMajorVersionGreaterOrEqualThen(kernelVersion int, majorVersion i
func (s *DockerNetworkSuite) TestDockerNetworkIpvlanPersistance(c *check.C) {
// verify the driver automatically provisions the 802.1q link (di-dummy0.70)
testRequires(c, DaemonIsLinux, ipvlanKernelSupport, NotUserNamespace, NotArm, ExperimentalDaemon)
testRequires(c, DaemonIsLinux, ipvlanKernelSupport, NotUserNamespace, NotArm, ExperimentalDaemon, SameHostDaemon)
// master dummy interface 'di' notation represent 'docker ipvlan'
master := "di-dummy0"
// simulate the master link the vlan tagged subinterface parent link will use
@ -54,7 +54,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkIpvlanPersistance(c *check.C) {
func (s *DockerNetworkSuite) TestDockerNetworkIpvlanSubIntCreate(c *check.C) {
// verify the driver automatically provisions the 802.1q link (di-dummy0.50)
testRequires(c, DaemonIsLinux, ipvlanKernelSupport, NotUserNamespace, NotArm, ExperimentalDaemon)
testRequires(c, DaemonIsLinux, ipvlanKernelSupport, NotUserNamespace, NotArm, ExperimentalDaemon, SameHostDaemon)
// master dummy interface 'dm' abbreviation represents 'docker ipvlan'
master := "di-dummy0"
// simulate the master link the vlan tagged subinterface parent link will use
@ -68,7 +68,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkIpvlanSubIntCreate(c *check.C) {
func (s *DockerNetworkSuite) TestDockerNetworkIpvlanOverlapParent(c *check.C) {
// verify the same parent interface cannot be used if already in use by an existing network
testRequires(c, DaemonIsLinux, ipvlanKernelSupport, NotUserNamespace, NotArm, ExperimentalDaemon)
testRequires(c, DaemonIsLinux, ipvlanKernelSupport, NotUserNamespace, NotArm, ExperimentalDaemon, SameHostDaemon)
// master dummy interface 'dm' abbreviation represents 'docker ipvlan'
master := "di-dummy0"
createMasterDummy(c, master)

View File

@ -5,7 +5,6 @@ import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"strings"
@ -249,6 +248,7 @@ RUN cat somefile`
// #35403 #36122
func TestBuildUncleanTarFilenames(t *testing.T) {
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.37"), "broken in earlier versions")
ctx := context.TODO()
defer setupTest(t)()
@ -307,9 +307,7 @@ 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")
skip.IfCondition(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.37"), "broken in earlier versions")
ctx := context.TODO()
defer setupTest(t)()

View File

@ -10,11 +10,14 @@ import (
"github.com/docker/docker/integration/internal/request"
"github.com/docker/docker/pkg/stdcopy"
"github.com/gotestyourself/gotestyourself/assert"
"github.com/gotestyourself/gotestyourself/skip"
)
// Regression test for #35370
// Makes sure that when following we don't get an EOF error when there are no logs
func TestLogsFollowTailEmpty(t *testing.T) {
// FIXME(vdemeester) fails on a e2e run on linux...
skip.IfCondition(t, testEnv.IsRemoteDaemon())
defer setupTest(t)()
client := request.NewAPIClient(t)
ctx := context.Background()

View File

@ -155,6 +155,7 @@ func TestContainerNetworkMountsNoChown(t *testing.T) {
}
func TestMountDaemonRoot(t *testing.T) {
skip.If(t, testEnv.DaemonInfo.OSType != "linux" || testEnv.IsRemoteDaemon())
t.Parallel()
client := request.NewAPIClient(t)

View File

@ -17,10 +17,9 @@ func TestPsFilter(t *testing.T) {
client := request.NewAPIClient(t)
ctx := context.Background()
prev := container.Create(t, ctx, client, container.WithName("prev-"+t.Name()))
topContainerName := "top-" + t.Name()
container.Create(t, ctx, client, container.WithName(topContainerName))
next := container.Create(t, ctx, client, container.WithName("next-"+t.Name()))
prev := container.Create(t, ctx, client)
top := container.Create(t, ctx, client)
next := container.Create(t, ctx, client)
containerIDs := func(containers []types.Container) []string {
entries := []string{}
@ -31,7 +30,7 @@ func TestPsFilter(t *testing.T) {
}
f1 := filters.NewArgs()
f1.Add("since", topContainerName)
f1.Add("since", top)
q1, err := client.ContainerList(ctx, types.ContainerListOptions{
All: true,
Filters: f1,
@ -40,7 +39,7 @@ func TestPsFilter(t *testing.T) {
assert.Check(t, is.Contains(containerIDs(q1), next))
f2 := filters.NewArgs()
f2.Add("before", topContainerName)
f2.Add("before", top)
q2, err := client.ContainerList(ctx, types.ContainerListOptions{
All: true,
Filters: f2,

View File

@ -13,6 +13,7 @@ import (
"github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/integration/internal/request"
"github.com/docker/docker/internal/testutil"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp"
)
@ -36,14 +37,14 @@ func TestVolumesCreateAndList(t *testing.T) {
Name: name,
Mountpoint: fmt.Sprintf("%s/volumes/%s/_data", testEnv.DaemonInfo.DockerRootDir, name),
}
assert.Check(t, is.DeepEqual(vol, expected))
assert.Check(t, is.DeepEqual(vol, expected, cmpopts.EquateEmpty()))
volumes, err := client.VolumeList(ctx, filters.Args{})
assert.NilError(t, err)
assert.Check(t, is.Equal(len(volumes.Volumes), 1))
assert.Check(t, volumes.Volumes[0] != nil)
assert.Check(t, is.DeepEqual(*volumes.Volumes[0], expected))
assert.Check(t, is.DeepEqual(*volumes.Volumes[0], expected, cmpopts.EquateEmpty()))
}
func TestVolumesRemove(t *testing.T) {
@ -96,7 +97,7 @@ func TestVolumesInspect(t *testing.T) {
Name: name,
Mountpoint: fmt.Sprintf("%s/volumes/%s/_data", testEnv.DaemonInfo.DockerRootDir, name),
}
assert.Check(t, is.DeepEqual(vol, expected))
assert.Check(t, is.DeepEqual(vol, expected, cmpopts.EquateEmpty()))
// comparing CreatedAt field time for the new volume to now. Removing a minute from both to avoid false positive
testCreatedAt, err := time.Parse(time.RFC3339, strings.TrimSpace(vol.CreatedAt))