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 (
"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

View File

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

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

View File

@ -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, ...).

View File

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

View File

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

View File

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

View File

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

View File

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