diff --git a/integration-cli/check_test.go b/integration-cli/check_test.go index 135c998693..530d853c2c 100644 --- a/integration-cli/check_test.go +++ b/integration-cli/check_test.go @@ -2,12 +2,14 @@ package main import ( "context" + "flag" "fmt" "io/ioutil" "net/http/httptest" "os" "path" "path/filepath" + "runtime" "strconv" "sync" "syscall" @@ -22,6 +24,7 @@ import ( "github.com/docker/docker/internal/test/fakestorage" "github.com/docker/docker/internal/test/fixtures/plugin" "github.com/docker/docker/internal/test/registry" + "github.com/docker/docker/internal/test/suite" "github.com/docker/docker/pkg/reexec" "gotest.tools/assert" ) @@ -57,6 +60,9 @@ func init() { } func TestMain(m *testing.M) { + flag.Parse() + + // Global set up dockerBinary = testEnv.DockerBinary() err := ienv.EnsureFrozenImagesLinux(&testEnv.Execution) if err != nil { @@ -72,11 +78,21 @@ func Test(t *testing.T) { cli.SetTestEnvironment(testEnv) fakestorage.SetTestEnvironment(&testEnv.Execution) ienv.ProtectAll(t, &testEnv.Execution) - /*check.TestingT(t)*/ -} - -func init() { - /*check.Suite(&DockerSuite{})*/ + suite.Run(t, &DockerSuite{}) + suite.Run(t, &DockerRegistrySuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerSchema1RegistrySuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerRegistryAuthHtpasswdSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerRegistryAuthTokenSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerDaemonSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerSwarmSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerPluginSuite{ds: &DockerSuite{}}) + if runtime.GOOS != "windows" { + suite.Run(t, &DockerExternalVolumeSuite{ds: &DockerSuite{}}) + suite.Run(t, &DockerNetworkSuite{ds: &DockerSuite{}}) + // FIXME. Temporarily turning this off for Windows as GH16039 was breaking + // Windows to Linux CI @icecrime + suite.Run(t, newDockerHubPullSuite()) + } } type DockerSuite struct { @@ -107,10 +123,6 @@ func (s *DockerSuite) TearDownTest(c *testing.T) { testEnv.Clean(c) } -func init() { - /*check.Suite(&DockerRegistrySuite{ds: &DockerSuite{}})*/ -} - type DockerRegistrySuite struct { ds *DockerSuite reg *registry.V2 @@ -138,10 +150,6 @@ func (s *DockerRegistrySuite) TearDownTest(c *testing.T) { s.ds.TearDownTest(c) } -func init() { - /*check.Suite(&DockerSchema1RegistrySuite{ds: &DockerSuite{}})*/ -} - type DockerSchema1RegistrySuite struct { ds *DockerSuite reg *registry.V2 @@ -169,10 +177,6 @@ func (s *DockerSchema1RegistrySuite) TearDownTest(c *testing.T) { s.ds.TearDownTest(c) } -func init() { - /*check.Suite(&DockerRegistryAuthHtpasswdSuite{ds: &DockerSuite{}})*/ -} - type DockerRegistryAuthHtpasswdSuite struct { ds *DockerSuite reg *registry.V2 @@ -202,10 +206,6 @@ func (s *DockerRegistryAuthHtpasswdSuite) TearDownTest(c *testing.T) { s.ds.TearDownTest(c) } -func init() { - /*check.Suite(&DockerRegistryAuthTokenSuite{ds: &DockerSuite{}})*/ -} - type DockerRegistryAuthTokenSuite struct { ds *DockerSuite reg *registry.V2 @@ -241,10 +241,6 @@ func (s *DockerRegistryAuthTokenSuite) setupRegistryWithTokenService(c *testing. s.reg.WaitReady(c) } -func init() { - /*check.Suite(&DockerDaemonSuite{ds: &DockerSuite{}})*/ -} - type DockerDaemonSuite struct { ds *DockerSuite d *daemon.Daemon @@ -284,10 +280,6 @@ func (s *DockerDaemonSuite) TearDownSuite(c *testing.T) { const defaultSwarmPort = 2477 -func init() { - /*check.Suite(&DockerSwarmSuite{ds: &DockerSuite{}})*/ -} - type DockerSwarmSuite struct { server *httptest.Server ds *DockerSuite @@ -346,10 +338,6 @@ func (s *DockerSwarmSuite) TearDownTest(c *testing.T) { s.ds.TearDownTest(c) } -func init() { - /*check.Suite(&DockerPluginSuite{ds: &DockerSuite{}})*/ -} - type DockerPluginSuite struct { ds *DockerSuite registry *registry.V2 diff --git a/integration-cli/docker_cli_external_volume_driver_unix_test.go b/integration-cli/docker_cli_external_volume_driver_test.go similarity index 99% rename from integration-cli/docker_cli_external_volume_driver_unix_test.go rename to integration-cli/docker_cli_external_volume_driver_test.go index ef388a7f25..e2ce30155b 100644 --- a/integration-cli/docker_cli_external_volume_driver_unix_test.go +++ b/integration-cli/docker_cli_external_volume_driver_test.go @@ -1,5 +1,3 @@ -// +build !windows - package main import ( @@ -26,10 +24,6 @@ import ( const volumePluginName = "test-external-volume-driver" -func init() { - /*check.Suite(&DockerExternalVolumeSuite{ds: &DockerSuite{}})*/ -} - type eventCounter struct { activations int creations int diff --git a/integration-cli/docker_cli_network_test.go b/integration-cli/docker_cli_network_test.go new file mode 100644 index 0000000000..ad1c95876f --- /dev/null +++ b/integration-cli/docker_cli_network_test.go @@ -0,0 +1,13 @@ +package main + +import ( + "net/http/httptest" + + "github.com/docker/docker/integration-cli/daemon" +) + +type DockerNetworkSuite struct { + server *httptest.Server + ds *DockerSuite + d *daemon.Daemon +} diff --git a/integration-cli/docker_cli_network_unix_test.go b/integration-cli/docker_cli_network_unix_test.go index 2fadf13f81..a47c78960a 100644 --- a/integration-cli/docker_cli_network_unix_test.go +++ b/integration-cli/docker_cli_network_unix_test.go @@ -37,16 +37,6 @@ const dummyIPAMDriver = "dummy-ipam-driver" var remoteDriverNetworkRequest remoteapi.CreateNetworkRequest -func init() { - /*check.Suite(&DockerNetworkSuite{ds: &DockerSuite{}})*/ -} - -type DockerNetworkSuite struct { - server *httptest.Server - ds *DockerSuite - d *daemon.Daemon -} - func (s *DockerNetworkSuite) SetUpTest(c *testing.T) { s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) } diff --git a/integration-cli/docker_hub_pull_suite_test.go b/integration-cli/docker_hub_pull_suite_test.go index cbf1b521bd..3da77e8339 100644 --- a/integration-cli/docker_hub_pull_suite_test.go +++ b/integration-cli/docker_hub_pull_suite_test.go @@ -3,7 +3,6 @@ package main import ( "fmt" "os/exec" - "runtime" "strings" "testing" @@ -12,14 +11,6 @@ import ( "gotest.tools/assert" ) -func init() { - // FIXME. Temporarily turning this off for Windows as GH16039 was breaking - // Windows to Linux CI @icecrime - if runtime.GOOS != "windows" { - /*check.Suite(newDockerHubPullSuite())*/ - } -} - // DockerHubPullSuite provides an isolated daemon that doesn't have all the // images that are baked into our 'global' test environment daemon (e.g., // busybox, httpserver, ...). diff --git a/pkg/discovery/discovery_test.go b/pkg/discovery/discovery_test.go index 7a0ce95988..8166d4afde 100644 --- a/pkg/discovery/discovery_test.go +++ b/pkg/discovery/discovery_test.go @@ -3,16 +3,17 @@ package discovery // import "github.com/docker/docker/pkg/discovery" import ( "testing" + "github.com/docker/docker/internal/test/suite" "gotest.tools/assert" ) // Hook up gocheck into the "go test" runner. -func Test(t *testing.T) { /*check.TestingT(t)*/ } +func Test(t *testing.T) { + suite.Run(t, &DiscoverySuite{}) +} type DiscoverySuite struct{} -/*check.Suite(&DiscoverySuite{})*/ - func (s *DiscoverySuite) TestNewEntry(c *testing.T) { entry, err := NewEntry("127.0.0.1:2375") assert.Assert(c, err == nil) diff --git a/pkg/discovery/file/file_test.go b/pkg/discovery/file/file_test.go index f896bfd39f..78a1798419 100644 --- a/pkg/discovery/file/file_test.go +++ b/pkg/discovery/file/file_test.go @@ -5,17 +5,18 @@ import ( "os" "testing" + "github.com/docker/docker/internal/test/suite" "github.com/docker/docker/pkg/discovery" "gotest.tools/assert" ) // Hook up gocheck into the "go test" runner. -func Test(t *testing.T) { /*check.TestingT(t)*/ } +func Test(t *testing.T) { + suite.Run(t, &DiscoverySuite{}) +} type DiscoverySuite struct{} -/*check.Suite(&DiscoverySuite{})*/ - func (s *DiscoverySuite) TestInitialize(c *testing.T) { d := &Discovery{} d.Initialize("/path/to/file", 1000, 0, nil) diff --git a/pkg/discovery/kv/kv_test.go b/pkg/discovery/kv/kv_test.go index 34d58fdb9d..5394038b04 100644 --- a/pkg/discovery/kv/kv_test.go +++ b/pkg/discovery/kv/kv_test.go @@ -8,6 +8,7 @@ import ( "testing" "time" + "github.com/docker/docker/internal/test/suite" "github.com/docker/docker/pkg/discovery" "github.com/docker/libkv" "github.com/docker/libkv/store" @@ -15,12 +16,12 @@ import ( ) // Hook up gocheck into the "go test" runner. -func Test(t *testing.T) { /*check.TestingT(t)*/ } +func Test(t *testing.T) { + suite.Run(t, &DiscoverySuite{}) +} type DiscoverySuite struct{} -/*check.Suite(&DiscoverySuite{})*/ - func (ds *DiscoverySuite) TestInitialize(c *testing.T) { storeMock := &FakeStore{ Endpoints: []string{"127.0.0.1"}, diff --git a/pkg/discovery/memory/memory_test.go b/pkg/discovery/memory/memory_test.go index 099a443c2f..f54807a552 100644 --- a/pkg/discovery/memory/memory_test.go +++ b/pkg/discovery/memory/memory_test.go @@ -3,17 +3,18 @@ package memory // import "github.com/docker/docker/pkg/discovery/memory" import ( "testing" + "github.com/docker/docker/internal/test/suite" "github.com/docker/docker/pkg/discovery" "gotest.tools/assert" ) // Hook up gocheck into the "go test" runner. -func Test(t *testing.T) { /*check.TestingT(t)*/ } +func Test(t *testing.T) { + suite.Run(t, &discoverySuite{}) +} type discoverySuite struct{} -/*check.Suite(&discoverySuite{})*/ - func (s *discoverySuite) TestWatch(c *testing.T) { d := &Discovery{} d.Initialize("foo", 1000, 0, nil) diff --git a/pkg/discovery/nodes/nodes_test.go b/pkg/discovery/nodes/nodes_test.go index efb0c67d4a..1212512fc9 100644 --- a/pkg/discovery/nodes/nodes_test.go +++ b/pkg/discovery/nodes/nodes_test.go @@ -3,17 +3,18 @@ package nodes // import "github.com/docker/docker/pkg/discovery/nodes" import ( "testing" + "github.com/docker/docker/internal/test/suite" "github.com/docker/docker/pkg/discovery" "gotest.tools/assert" ) // Hook up gocheck into the "go test" runner. -func Test(t *testing.T) { /*check.TestingT(t)*/ } +func Test(t *testing.T) { + suite.Run(t, &DiscoverySuite{}) +} type DiscoverySuite struct{} -/*check.Suite(&DiscoverySuite{})*/ - func (s *DiscoverySuite) TestInitialize(c *testing.T) { d := &Discovery{} d.Initialize("1.1.1.1:1111,2.2.2.2:2222", 0, 0, nil)