From: Paul Tagliamonte Date: Tue, 12 Jul 2016 14:46:35 +0000 (+0100) Subject: skip-privileged-unit-tests X-Git-Tag: archive/raspbian/18.09.1+dfsg1-7+rpi1~1^2^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ee0b0df196875cd88d2f86461aa921b1e82986f1;p=docker.io.git skip-privileged-unit-tests Gbp-Pq: Name skip-privileged-unit-tests.patch --- diff --git a/daemon/daemon_test.go b/daemon/daemon_test.go index 609ed952..921e4007 100644 --- a/daemon/daemon_test.go +++ b/daemon/daemon_test.go @@ -155,6 +155,10 @@ func TestValidContainerNames(t *testing.T) { } func TestContainerInitDNS(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + tmp, err := ioutil.TempDir("", "docker-container-test-") if err != nil { t.Fatal(err) diff --git a/daemon/graphdriver/aufs/aufs_test.go b/daemon/graphdriver/aufs/aufs_test.go index b0ddf89a..c224c310 100644 --- a/daemon/graphdriver/aufs/aufs_test.go +++ b/daemon/graphdriver/aufs/aufs_test.go @@ -28,6 +28,10 @@ func init() { } func testInit(dir string, t testing.TB) graphdriver.Driver { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + d, err := Init(dir, nil, nil, nil) if err != nil { if err == graphdriver.ErrNotSupported { diff --git a/daemon/graphdriver/devmapper/devmapper_test.go b/daemon/graphdriver/devmapper/devmapper_test.go index 5c2abcef..2159ccf7 100644 --- a/daemon/graphdriver/devmapper/devmapper_test.go +++ b/daemon/graphdriver/devmapper/devmapper_test.go @@ -11,50 +11,70 @@ import ( "github.com/docker/docker/daemon/graphdriver/graphtest" ) -func init() { +func shortSkip(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } +} + +// This avoids creating a new driver for each test if all tests are run +// Make sure to put new tests between TestDevmapperSetup and TestDevmapperTeardown +func TestDevmapperSetup(t *testing.T) { + shortSkip(t) + // Reduce the size the the base fs and loopback for the tests defaultDataLoopbackSize = 300 * 1024 * 1024 defaultMetaDataLoopbackSize = 200 * 1024 * 1024 defaultBaseFsSize = 300 * 1024 * 1024 defaultUdevSyncOverride = true if err := graphtest.InitLoopbacks(); err != nil { - panic(err) + t.Fatal(err) } -} -// This avoids creating a new driver for each test if all tests are run -// Make sure to put new tests between TestDevmapperSetup and TestDevmapperTeardown -func TestDevmapperSetup(t *testing.T) { graphtest.GetDriver(t, "devicemapper") } func TestDevmapperCreateEmpty(t *testing.T) { + shortSkip(t) + graphtest.DriverTestCreateEmpty(t, "devicemapper") } func TestDevmapperCreateBase(t *testing.T) { + shortSkip(t) + graphtest.DriverTestCreateBase(t, "devicemapper") } func TestDevmapperCreateSnap(t *testing.T) { + shortSkip(t) + graphtest.DriverTestCreateSnap(t, "devicemapper") } func TestDevmapperTeardown(t *testing.T) { + shortSkip(t) + graphtest.PutDriver(t) } func TestDevmapperReduceLoopBackSize(t *testing.T) { + shortSkip(t) + tenMB := int64(10 * 1024 * 1024) testChangeLoopBackSize(t, -tenMB, defaultDataLoopbackSize, defaultMetaDataLoopbackSize) } func TestDevmapperIncreaseLoopBackSize(t *testing.T) { + shortSkip(t) + tenMB := int64(10 * 1024 * 1024) testChangeLoopBackSize(t, tenMB, defaultDataLoopbackSize+tenMB, defaultMetaDataLoopbackSize+tenMB) } func testChangeLoopBackSize(t *testing.T, delta, expectDataSize, expectMetaDataSize int64) { + shortSkip(t) + driver := graphtest.GetDriver(t, "devicemapper").(*graphtest.Driver).Driver.(*graphdriver.NaiveDiffDriver).ProtoDriver.(*Driver) defer graphtest.PutDriver(t) // make sure data or metadata loopback size are the default size @@ -83,6 +103,8 @@ func testChangeLoopBackSize(t *testing.T, delta, expectDataSize, expectMetaDataS // Make sure devices.Lock() has been release upon return from cleanupDeletedDevices() function func TestDevmapperLockReleasedDeviceDeletion(t *testing.T) { + shortSkip(t) + driver := graphtest.GetDriver(t, "devicemapper").(*graphtest.Driver).Driver.(*graphdriver.NaiveDiffDriver).ProtoDriver.(*Driver) defer graphtest.PutDriver(t) diff --git a/daemon/graphdriver/overlay/overlay_test.go b/daemon/graphdriver/overlay/overlay_test.go index 8dfcd62e..f5451d3a 100644 --- a/daemon/graphdriver/overlay/overlay_test.go +++ b/daemon/graphdriver/overlay/overlay_test.go @@ -11,18 +11,30 @@ import ( // This avoids creating a new driver for each test if all tests are run // Make sure to put new tests between TestOverlaySetup and TestOverlayTeardown func TestOverlaySetup(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } graphtest.GetDriver(t, "overlay") } func TestOverlayCreateEmpty(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } graphtest.DriverTestCreateEmpty(t, "overlay") } func TestOverlayCreateBase(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } graphtest.DriverTestCreateBase(t, "overlay") } func TestOverlayCreateSnap(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } graphtest.DriverTestCreateSnap(t, "overlay") } diff --git a/daemon/graphdriver/vfs/vfs_test.go b/daemon/graphdriver/vfs/vfs_test.go index 9ecf21db..0902926b 100644 --- a/daemon/graphdriver/vfs/vfs_test.go +++ b/daemon/graphdriver/vfs/vfs_test.go @@ -10,28 +10,42 @@ import ( "github.com/docker/docker/pkg/reexec" ) -func init() { - reexec.Init() +func shortSkip(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } } // This avoids creating a new driver for each test if all tests are run // Make sure to put new tests between TestVfsSetup and TestVfsTeardown func TestVfsSetup(t *testing.T) { + shortSkip(t) + + reexec.Init() + graphtest.GetDriver(t, "vfs") } func TestVfsCreateEmpty(t *testing.T) { + shortSkip(t) + graphtest.DriverTestCreateEmpty(t, "vfs") } func TestVfsCreateBase(t *testing.T) { + shortSkip(t) + graphtest.DriverTestCreateBase(t, "vfs") } func TestVfsCreateSnap(t *testing.T) { + shortSkip(t) + graphtest.DriverTestCreateSnap(t, "vfs") } func TestVfsTeardown(t *testing.T) { + shortSkip(t) + graphtest.PutDriver(t) } diff --git a/pkg/archive/archive_test.go b/pkg/archive/archive_test.go index 495cac83..3c56b0a8 100644 --- a/pkg/archive/archive_test.go +++ b/pkg/archive/archive_test.go @@ -305,6 +305,10 @@ func TestUntarPathWithInvalidSrc(t *testing.T) { } func TestUntarPath(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + tmpFolder, err := ioutil.TempDir("", "docker-archive-test") if err != nil { t.Fatal(err) @@ -439,6 +443,10 @@ func TestCopyWithTarInvalidSrc(t *testing.T) { } func TestCopyWithTarInexistentDestWillCreateIt(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + tempFolder, err := ioutil.TempDir("", "docker-archive-test") if err != nil { t.Fatal(nil) @@ -923,6 +931,11 @@ func TestUntarHardlinkToSymlink(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("hardlinks on Windows") } + + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + for i, headers := range [][]*tar.Header{ { { diff --git a/pkg/archive/archive_unix_test.go b/pkg/archive/archive_unix_test.go index 548391b3..2663a74f 100644 --- a/pkg/archive/archive_unix_test.go +++ b/pkg/archive/archive_unix_test.go @@ -150,6 +150,10 @@ func getInode(path string) (uint64, error) { } func TestTarWithBlockCharFifo(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + origin, err := ioutil.TempDir("", "docker-test-tar-hardlink") if err != nil { t.Fatal(err) @@ -203,6 +207,10 @@ func TestTarWithBlockCharFifo(t *testing.T) { // TestTarUntarWithXattr is Unix as Lsetxattr is not supported on Windows func TestTarUntarWithXattr(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + origin, err := ioutil.TempDir("", "docker-test-untar-origin") if err != nil { t.Fatal(err) diff --git a/pkg/archive/changes_test.go b/pkg/archive/changes_test.go index bca68250..f9846c6d 100644 --- a/pkg/archive/changes_test.go +++ b/pkg/archive/changes_test.go @@ -142,6 +142,10 @@ func TestChangesWithNoChanges(t *testing.T) { } func TestChangesWithChanges(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + // TODO Windows. There may be a way of running this, but turning off for now // as createSampleDir uses symlinks. if runtime.GOOS == "windows" { @@ -198,6 +202,11 @@ func TestChangesWithChangesGH13590(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("symlinks on Windows") } + + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + baseLayer, err := ioutil.TempDir("", "docker-changes-test.") defer os.RemoveAll(baseLayer) diff --git a/pkg/authorization/authz_unix_test.go b/pkg/authorization/authz_unix_test.go index 1c6dc8a1..93f2eaec 100644 --- a/pkg/authorization/authz_unix_test.go +++ b/pkg/authorization/authz_unix_test.go @@ -28,6 +28,10 @@ import ( const pluginAddress = "authzplugin.sock" func TestAuthZRequestPluginError(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + server := authZPluginTestServer{t: t} go server.start() defer server.stop() @@ -59,6 +63,10 @@ func TestAuthZRequestPluginError(t *testing.T) { } func TestAuthZRequestPlugin(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + server := authZPluginTestServer{t: t} go server.start() defer server.stop() @@ -91,6 +99,10 @@ func TestAuthZRequestPlugin(t *testing.T) { } func TestAuthZResponsePlugin(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + server := authZPluginTestServer{t: t} go server.start() defer server.stop() diff --git a/pkg/chrootarchive/archive_test.go b/pkg/chrootarchive/archive_test.go index 5fbe2084..9b60805a 100644 --- a/pkg/chrootarchive/archive_test.go +++ b/pkg/chrootarchive/archive_test.go @@ -22,7 +22,15 @@ func init() { reexec.Init() } +func shortSkip(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } +} + func TestChrootTarUntar(t *testing.T) { + shortSkip(t) + tmpdir, err := ioutil.TempDir("", "docker-TestChrootTarUntar") if err != nil { t.Fatal(err) @@ -54,6 +62,8 @@ func TestChrootTarUntar(t *testing.T) { // gh#10426: Verify the fix for having a huge excludes list (like on `docker load` with large # of // local images) func TestChrootUntarWithHugeExcludesList(t *testing.T) { + shortSkip(t) + tmpdir, err := ioutil.TempDir("", "docker-TestChrootUntarHugeExcludes") if err != nil { t.Fatal(err) @@ -88,6 +98,8 @@ func TestChrootUntarWithHugeExcludesList(t *testing.T) { } func TestChrootUntarEmptyArchive(t *testing.T) { + shortSkip(t) + tmpdir, err := ioutil.TempDir("", "docker-TestChrootUntarEmptyArchive") if err != nil { t.Fatal(err) @@ -152,6 +164,8 @@ func compareFiles(src string, dest string) error { } func TestChrootTarUntarWithSymlink(t *testing.T) { + shortSkip(t) + // TODO Windows: Figure out why this is failing if runtime.GOOS == "windows" { t.Skip("Failing on Windows") @@ -178,6 +192,8 @@ func TestChrootTarUntarWithSymlink(t *testing.T) { } func TestChrootCopyWithTar(t *testing.T) { + shortSkip(t) + // TODO Windows: Figure out why this is failing if runtime.GOOS == "windows" { t.Skip("Failing on Windows") @@ -228,6 +244,8 @@ func TestChrootCopyWithTar(t *testing.T) { } func TestChrootCopyFileWithTar(t *testing.T) { + shortSkip(t) + tmpdir, err := ioutil.TempDir("", "docker-TestChrootCopyFileWithTar") if err != nil { t.Fatal(err) @@ -271,6 +289,8 @@ func TestChrootCopyFileWithTar(t *testing.T) { } func TestChrootUntarPath(t *testing.T) { + shortSkip(t) + // TODO Windows: Figure out why this is failing if runtime.GOOS == "windows" { t.Skip("Failing on Windows") @@ -336,6 +356,8 @@ func (s *slowEmptyTarReader) Read(p []byte) (int, error) { } func TestChrootUntarEmptyArchiveFromSlowReader(t *testing.T) { + shortSkip(t) + tmpdir, err := ioutil.TempDir("", "docker-TestChrootUntarEmptyArchiveFromSlowReader") if err != nil { t.Fatal(err) @@ -352,6 +374,8 @@ func TestChrootUntarEmptyArchiveFromSlowReader(t *testing.T) { } func TestChrootApplyEmptyArchiveFromSlowReader(t *testing.T) { + shortSkip(t) + tmpdir, err := ioutil.TempDir("", "docker-TestChrootApplyEmptyArchiveFromSlowReader") if err != nil { t.Fatal(err) @@ -368,6 +392,8 @@ func TestChrootApplyEmptyArchiveFromSlowReader(t *testing.T) { } func TestChrootApplyDotDotFile(t *testing.T) { + shortSkip(t) + tmpdir, err := ioutil.TempDir("", "docker-TestChrootApplyDotDotFile") if err != nil { t.Fatal(err) diff --git a/pkg/idtools/idtools_unix_test.go b/pkg/idtools/idtools_unix_test.go index 540d3079..14e0c82e 100644 --- a/pkg/idtools/idtools_unix_test.go +++ b/pkg/idtools/idtools_unix_test.go @@ -17,6 +17,10 @@ type node struct { } func TestMkdirAllAs(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + dirName, err := ioutil.TempDir("", "mkdirall") if err != nil { t.Fatalf("Couldn't create temp dir: %v", err) @@ -77,6 +81,9 @@ func TestMkdirAllAs(t *testing.T) { } func TestMkdirAllNewAs(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } dirName, err := ioutil.TempDir("", "mkdirnew") if err != nil { @@ -137,6 +144,9 @@ func TestMkdirAllNewAs(t *testing.T) { } func TestMkdirAs(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } dirName, err := ioutil.TempDir("", "mkdir") if err != nil { diff --git a/pkg/mount/mount_unix_test.go b/pkg/mount/mount_unix_test.go index d45fbc1b..378e3d21 100644 --- a/pkg/mount/mount_unix_test.go +++ b/pkg/mount/mount_unix_test.go @@ -25,6 +25,10 @@ func TestMountOptionsParsing(t *testing.T) { } func TestMounted(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + tmp := path.Join(os.TempDir(), "mount-tests") if err := os.MkdirAll(tmp, 0777); err != nil { t.Fatal(err) @@ -76,6 +80,10 @@ func TestMounted(t *testing.T) { } func TestMountReadonly(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + tmp := path.Join(os.TempDir(), "mount-tests") if err := os.MkdirAll(tmp, 0777); err != nil { t.Fatal(err) @@ -121,6 +129,9 @@ func TestMountReadonly(t *testing.T) { } func TestGetMounts(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } mounts, err := GetMounts() if err != nil { t.Fatal(err) diff --git a/pkg/mount/sharedsubtree_linux_test.go b/pkg/mount/sharedsubtree_linux_test.go index c1837942..19c65ccf 100644 --- a/pkg/mount/sharedsubtree_linux_test.go +++ b/pkg/mount/sharedsubtree_linux_test.go @@ -11,6 +11,10 @@ import ( // nothing is propagated in or out func TestSubtreePrivate(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + tmp := path.Join(os.TempDir(), "mount-tests") if err := os.MkdirAll(tmp, 0777); err != nil { t.Fatal(err) @@ -109,6 +113,10 @@ func TestSubtreePrivate(t *testing.T) { // Testing that when a target is a shared mount, // then child mounts propagate to the source func TestSubtreeShared(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + tmp := path.Join(os.TempDir(), "mount-tests") if err := os.MkdirAll(tmp, 0777); err != nil { t.Fatal(err) @@ -177,6 +185,10 @@ func TestSubtreeShared(t *testing.T) { // testing that mounts to a shared source show up in the slave target, // and that mounts into a slave target do _not_ show up in the shared source func TestSubtreeSharedSlave(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + tmp := path.Join(os.TempDir(), "mount-tests") if err := os.MkdirAll(tmp, 0777); err != nil { t.Fatal(err) @@ -281,6 +293,10 @@ func TestSubtreeSharedSlave(t *testing.T) { } func TestSubtreeUnbindable(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + tmp := path.Join(os.TempDir(), "mount-tests") if err := os.MkdirAll(tmp, 0777); err != nil { t.Fatal(err) diff --git a/pkg/sysinfo/sysinfo_linux_test.go b/pkg/sysinfo/sysinfo_linux_test.go index fae0fdff..26802d32 100644 --- a/pkg/sysinfo/sysinfo_linux_test.go +++ b/pkg/sysinfo/sysinfo_linux_test.go @@ -9,6 +9,10 @@ import ( ) func TestReadProcBool(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + tmpDir, err := ioutil.TempDir("", "test-sysinfo-proc") if err != nil { t.Fatal(err) diff --git a/volume/local/local_test.go b/volume/local/local_test.go index 1baa0854..94d6b618 100644 --- a/volume/local/local_test.go +++ b/volume/local/local_test.go @@ -11,6 +11,9 @@ import ( ) func TestRemove(t *testing.T) { + if testing.Short() { t.Skip("Skipping privileged test in short mode") + } + // TODO Windows: Investigate why this test fails on Windows under CI // but passes locally. if runtime.GOOS == "windows" { @@ -58,6 +61,10 @@ func TestRemove(t *testing.T) { } func TestInitializeWithVolumes(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + rootDir, err := ioutil.TempDir("", "local-volume-test") if err != nil { t.Fatal(err) @@ -90,6 +97,10 @@ func TestInitializeWithVolumes(t *testing.T) { } func TestCreate(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + rootDir, err := ioutil.TempDir("", "local-volume-test") if err != nil { t.Fatal(err) @@ -156,6 +167,10 @@ func TestValidateName(t *testing.T) { } func TestCreateWithOpts(t *testing.T) { + if testing.Short() { + t.Skip("Skipping privileged test in short mode") + } + if runtime.GOOS == "windows" { t.Skip() }