1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Setup tests

Signed-off-by: Tibor Vass <tibor@docker.com>
This commit is contained in:
Tibor Vass 2019-08-09 00:38:35 +00:00
parent fd0ed80ff2
commit 8b40da168b
10 changed files with 54 additions and 73 deletions

View file

@ -2,12 +2,14 @@ package main
import ( import (
"context" "context"
"flag"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http/httptest" "net/http/httptest"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"runtime"
"strconv" "strconv"
"sync" "sync"
"syscall" "syscall"
@ -22,6 +24,7 @@ import (
"github.com/docker/docker/internal/test/fakestorage" "github.com/docker/docker/internal/test/fakestorage"
"github.com/docker/docker/internal/test/fixtures/plugin" "github.com/docker/docker/internal/test/fixtures/plugin"
"github.com/docker/docker/internal/test/registry" "github.com/docker/docker/internal/test/registry"
"github.com/docker/docker/internal/test/suite"
"github.com/docker/docker/pkg/reexec" "github.com/docker/docker/pkg/reexec"
"gotest.tools/assert" "gotest.tools/assert"
) )
@ -57,6 +60,9 @@ func init() {
} }
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
flag.Parse()
// Global set up
dockerBinary = testEnv.DockerBinary() dockerBinary = testEnv.DockerBinary()
err := ienv.EnsureFrozenImagesLinux(&testEnv.Execution) err := ienv.EnsureFrozenImagesLinux(&testEnv.Execution)
if err != nil { if err != nil {
@ -72,11 +78,21 @@ func Test(t *testing.T) {
cli.SetTestEnvironment(testEnv) cli.SetTestEnvironment(testEnv)
fakestorage.SetTestEnvironment(&testEnv.Execution) fakestorage.SetTestEnvironment(&testEnv.Execution)
ienv.ProtectAll(t, &testEnv.Execution) ienv.ProtectAll(t, &testEnv.Execution)
/*check.TestingT(t)*/ suite.Run(t, &DockerSuite{})
} suite.Run(t, &DockerRegistrySuite{ds: &DockerSuite{}})
suite.Run(t, &DockerSchema1RegistrySuite{ds: &DockerSuite{}})
func init() { suite.Run(t, &DockerRegistryAuthHtpasswdSuite{ds: &DockerSuite{}})
/*check.Suite(&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 { type DockerSuite struct {
@ -107,10 +123,6 @@ func (s *DockerSuite) TearDownTest(c *testing.T) {
testEnv.Clean(c) testEnv.Clean(c)
} }
func init() {
/*check.Suite(&DockerRegistrySuite{ds: &DockerSuite{}})*/
}
type DockerRegistrySuite struct { type DockerRegistrySuite struct {
ds *DockerSuite ds *DockerSuite
reg *registry.V2 reg *registry.V2
@ -138,10 +150,6 @@ func (s *DockerRegistrySuite) TearDownTest(c *testing.T) {
s.ds.TearDownTest(c) s.ds.TearDownTest(c)
} }
func init() {
/*check.Suite(&DockerSchema1RegistrySuite{ds: &DockerSuite{}})*/
}
type DockerSchema1RegistrySuite struct { type DockerSchema1RegistrySuite struct {
ds *DockerSuite ds *DockerSuite
reg *registry.V2 reg *registry.V2
@ -169,10 +177,6 @@ func (s *DockerSchema1RegistrySuite) TearDownTest(c *testing.T) {
s.ds.TearDownTest(c) s.ds.TearDownTest(c)
} }
func init() {
/*check.Suite(&DockerRegistryAuthHtpasswdSuite{ds: &DockerSuite{}})*/
}
type DockerRegistryAuthHtpasswdSuite struct { type DockerRegistryAuthHtpasswdSuite struct {
ds *DockerSuite ds *DockerSuite
reg *registry.V2 reg *registry.V2
@ -202,10 +206,6 @@ func (s *DockerRegistryAuthHtpasswdSuite) TearDownTest(c *testing.T) {
s.ds.TearDownTest(c) s.ds.TearDownTest(c)
} }
func init() {
/*check.Suite(&DockerRegistryAuthTokenSuite{ds: &DockerSuite{}})*/
}
type DockerRegistryAuthTokenSuite struct { type DockerRegistryAuthTokenSuite struct {
ds *DockerSuite ds *DockerSuite
reg *registry.V2 reg *registry.V2
@ -241,10 +241,6 @@ func (s *DockerRegistryAuthTokenSuite) setupRegistryWithTokenService(c *testing.
s.reg.WaitReady(c) s.reg.WaitReady(c)
} }
func init() {
/*check.Suite(&DockerDaemonSuite{ds: &DockerSuite{}})*/
}
type DockerDaemonSuite struct { type DockerDaemonSuite struct {
ds *DockerSuite ds *DockerSuite
d *daemon.Daemon d *daemon.Daemon
@ -284,10 +280,6 @@ func (s *DockerDaemonSuite) TearDownSuite(c *testing.T) {
const defaultSwarmPort = 2477 const defaultSwarmPort = 2477
func init() {
/*check.Suite(&DockerSwarmSuite{ds: &DockerSuite{}})*/
}
type DockerSwarmSuite struct { type DockerSwarmSuite struct {
server *httptest.Server server *httptest.Server
ds *DockerSuite ds *DockerSuite
@ -346,10 +338,6 @@ func (s *DockerSwarmSuite) TearDownTest(c *testing.T) {
s.ds.TearDownTest(c) s.ds.TearDownTest(c)
} }
func init() {
/*check.Suite(&DockerPluginSuite{ds: &DockerSuite{}})*/
}
type DockerPluginSuite struct { type DockerPluginSuite struct {
ds *DockerSuite ds *DockerSuite
registry *registry.V2 registry *registry.V2

View file

@ -1,5 +1,3 @@
// +build !windows
package main package main
import ( import (
@ -26,10 +24,6 @@ import (
const volumePluginName = "test-external-volume-driver" const volumePluginName = "test-external-volume-driver"
func init() {
/*check.Suite(&DockerExternalVolumeSuite{ds: &DockerSuite{}})*/
}
type eventCounter struct { type eventCounter struct {
activations int activations int
creations int creations int

View file

@ -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
}

View file

@ -37,16 +37,6 @@ const dummyIPAMDriver = "dummy-ipam-driver"
var remoteDriverNetworkRequest remoteapi.CreateNetworkRequest 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) { func (s *DockerNetworkSuite) SetUpTest(c *testing.T) {
s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution)) s.d = daemon.New(c, dockerBinary, dockerdBinary, testdaemon.WithEnvironment(testEnv.Execution))
} }

View file

@ -3,7 +3,6 @@ package main
import ( import (
"fmt" "fmt"
"os/exec" "os/exec"
"runtime"
"strings" "strings"
"testing" "testing"
@ -12,14 +11,6 @@ import (
"gotest.tools/assert" "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 // DockerHubPullSuite provides an isolated daemon that doesn't have all the
// images that are baked into our 'global' test environment daemon (e.g., // images that are baked into our 'global' test environment daemon (e.g.,
// busybox, httpserver, ...). // busybox, httpserver, ...).

View file

@ -3,16 +3,17 @@ package discovery // import "github.com/docker/docker/pkg/discovery"
import ( import (
"testing" "testing"
"github.com/docker/docker/internal/test/suite"
"gotest.tools/assert" "gotest.tools/assert"
) )
// Hook up gocheck into the "go test" runner. // 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{} type DiscoverySuite struct{}
/*check.Suite(&DiscoverySuite{})*/
func (s *DiscoverySuite) TestNewEntry(c *testing.T) { func (s *DiscoverySuite) TestNewEntry(c *testing.T) {
entry, err := NewEntry("127.0.0.1:2375") entry, err := NewEntry("127.0.0.1:2375")
assert.Assert(c, err == nil) assert.Assert(c, err == nil)

View file

@ -5,17 +5,18 @@ import (
"os" "os"
"testing" "testing"
"github.com/docker/docker/internal/test/suite"
"github.com/docker/docker/pkg/discovery" "github.com/docker/docker/pkg/discovery"
"gotest.tools/assert" "gotest.tools/assert"
) )
// Hook up gocheck into the "go test" runner. // 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{} type DiscoverySuite struct{}
/*check.Suite(&DiscoverySuite{})*/
func (s *DiscoverySuite) TestInitialize(c *testing.T) { func (s *DiscoverySuite) TestInitialize(c *testing.T) {
d := &Discovery{} d := &Discovery{}
d.Initialize("/path/to/file", 1000, 0, nil) d.Initialize("/path/to/file", 1000, 0, nil)

View file

@ -8,6 +8,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/docker/docker/internal/test/suite"
"github.com/docker/docker/pkg/discovery" "github.com/docker/docker/pkg/discovery"
"github.com/docker/libkv" "github.com/docker/libkv"
"github.com/docker/libkv/store" "github.com/docker/libkv/store"
@ -15,12 +16,12 @@ import (
) )
// Hook up gocheck into the "go test" runner. // 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{} type DiscoverySuite struct{}
/*check.Suite(&DiscoverySuite{})*/
func (ds *DiscoverySuite) TestInitialize(c *testing.T) { func (ds *DiscoverySuite) TestInitialize(c *testing.T) {
storeMock := &FakeStore{ storeMock := &FakeStore{
Endpoints: []string{"127.0.0.1"}, Endpoints: []string{"127.0.0.1"},

View file

@ -3,17 +3,18 @@ package memory // import "github.com/docker/docker/pkg/discovery/memory"
import ( import (
"testing" "testing"
"github.com/docker/docker/internal/test/suite"
"github.com/docker/docker/pkg/discovery" "github.com/docker/docker/pkg/discovery"
"gotest.tools/assert" "gotest.tools/assert"
) )
// Hook up gocheck into the "go test" runner. // 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{} type discoverySuite struct{}
/*check.Suite(&discoverySuite{})*/
func (s *discoverySuite) TestWatch(c *testing.T) { func (s *discoverySuite) TestWatch(c *testing.T) {
d := &Discovery{} d := &Discovery{}
d.Initialize("foo", 1000, 0, nil) d.Initialize("foo", 1000, 0, nil)

View file

@ -3,17 +3,18 @@ package nodes // import "github.com/docker/docker/pkg/discovery/nodes"
import ( import (
"testing" "testing"
"github.com/docker/docker/internal/test/suite"
"github.com/docker/docker/pkg/discovery" "github.com/docker/docker/pkg/discovery"
"gotest.tools/assert" "gotest.tools/assert"
) )
// Hook up gocheck into the "go test" runner. // 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{} type DiscoverySuite struct{}
/*check.Suite(&DiscoverySuite{})*/
func (s *DiscoverySuite) TestInitialize(c *testing.T) { func (s *DiscoverySuite) TestInitialize(c *testing.T) {
d := &Discovery{} d := &Discovery{}
d.Initialize("1.1.1.1:1111,2.2.2.2:2222", 0, 0, nil) d.Initialize("1.1.1.1:1111,2.2.2.2:2222", 0, 0, nil)