dc944ea7 |
package main
import ( |
b78e4216 |
"fmt" |
ca57f4e6 |
"os"
"path/filepath" |
dc944ea7 |
"testing"
|
ca57f4e6 |
"github.com/docker/docker/cliconfig" |
b78e4216 |
"github.com/docker/docker/pkg/reexec" |
dc944ea7 |
"github.com/go-check/check"
)
|
ecccfa82 |
func Test(t *testing.T) { |
b78e4216 |
reexec.Init() // This is required for external graphdriver tests
if !isLocalDaemon {
fmt.Println("INFO: Testing against a remote daemon")
} else {
fmt.Println("INFO: Testing against a local daemon")
}
|
ecccfa82 |
check.TestingT(t)
} |
dc944ea7 |
|
f696b107 |
func init() {
check.Suite(&DockerSuite{})
}
|
dc944ea7 |
type DockerSuite struct {
}
func (s *DockerSuite) TearDownTest(c *check.C) { |
e732f4e6 |
unpauseAllContainers() |
dc944ea7 |
deleteAllContainers() |
a9688cdc |
deleteAllImages() |
b3b7eb27 |
deleteAllVolumes() |
28ad7c58 |
deleteAllNetworks() |
dc944ea7 |
}
|
f696b107 |
func init() {
check.Suite(&DockerRegistrySuite{
ds: &DockerSuite{},
})
}
type DockerRegistrySuite struct {
ds *DockerSuite
reg *testRegistryV2 |
39f2f15a |
d *Daemon |
f696b107 |
}
func (s *DockerRegistrySuite) SetUpTest(c *check.C) { |
d800a4e1 |
testRequires(c, DaemonIsLinux, RegistryHosting) |
1b5c2e1d |
s.reg = setupRegistry(c, false, "", "") |
39f2f15a |
s.d = NewDaemon(c) |
f696b107 |
}
func (s *DockerRegistrySuite) TearDownTest(c *check.C) { |
3d6617ff |
if s.reg != nil {
s.reg.Close()
} |
11a95b95 |
if s.d != nil {
s.d.Stop() |
3d6617ff |
} |
11a95b95 |
s.ds.TearDownTest(c) |
f696b107 |
} |
57464c32 |
func init() { |
1fa2e311 |
check.Suite(&DockerSchema1RegistrySuite{
ds: &DockerSuite{},
})
}
type DockerSchema1RegistrySuite struct {
ds *DockerSuite
reg *testRegistryV2
d *Daemon
}
func (s *DockerSchema1RegistrySuite) SetUpTest(c *check.C) { |
d800a4e1 |
testRequires(c, DaemonIsLinux, RegistryHosting) |
1b5c2e1d |
s.reg = setupRegistry(c, true, "", "") |
1fa2e311 |
s.d = NewDaemon(c)
}
func (s *DockerSchema1RegistrySuite) TearDownTest(c *check.C) {
if s.reg != nil {
s.reg.Close()
} |
11a95b95 |
if s.d != nil {
s.d.Stop() |
1fa2e311 |
} |
11a95b95 |
s.ds.TearDownTest(c) |
1fa2e311 |
}
func init() { |
1b5c2e1d |
check.Suite(&DockerRegistryAuthHtpasswdSuite{ |
011b4f01 |
ds: &DockerSuite{},
})
}
|
1b5c2e1d |
type DockerRegistryAuthHtpasswdSuite struct { |
011b4f01 |
ds *DockerSuite
reg *testRegistryV2
d *Daemon
}
|
1b5c2e1d |
func (s *DockerRegistryAuthHtpasswdSuite) SetUpTest(c *check.C) { |
d800a4e1 |
testRequires(c, DaemonIsLinux, RegistryHosting) |
1b5c2e1d |
s.reg = setupRegistry(c, false, "htpasswd", "") |
011b4f01 |
s.d = NewDaemon(c)
}
|
1b5c2e1d |
func (s *DockerRegistryAuthHtpasswdSuite) TearDownTest(c *check.C) { |
011b4f01 |
if s.reg != nil {
out, err := s.d.Cmd("logout", privateRegistryURL)
c.Assert(err, check.IsNil, check.Commentf(out))
s.reg.Close()
}
if s.d != nil {
s.d.Stop()
}
s.ds.TearDownTest(c)
}
func init() { |
1b5c2e1d |
check.Suite(&DockerRegistryAuthTokenSuite{
ds: &DockerSuite{},
})
}
type DockerRegistryAuthTokenSuite struct {
ds *DockerSuite
reg *testRegistryV2
d *Daemon
}
func (s *DockerRegistryAuthTokenSuite) SetUpTest(c *check.C) {
testRequires(c, DaemonIsLinux, RegistryHosting)
s.d = NewDaemon(c)
}
func (s *DockerRegistryAuthTokenSuite) TearDownTest(c *check.C) {
if s.reg != nil {
out, err := s.d.Cmd("logout", privateRegistryURL)
c.Assert(err, check.IsNil, check.Commentf(out))
s.reg.Close()
}
if s.d != nil {
s.d.Stop()
}
s.ds.TearDownTest(c)
}
func (s *DockerRegistryAuthTokenSuite) setupRegistryWithTokenService(c *check.C, tokenURL string) {
if s == nil {
c.Fatal("registry suite isn't initialized")
}
s.reg = setupRegistry(c, false, "token", tokenURL)
}
func init() { |
57464c32 |
check.Suite(&DockerDaemonSuite{
ds: &DockerSuite{},
})
}
type DockerDaemonSuite struct {
ds *DockerSuite
d *Daemon
}
func (s *DockerDaemonSuite) SetUpTest(c *check.C) { |
f9a3558a |
testRequires(c, DaemonIsLinux) |
57464c32 |
s.d = NewDaemon(c)
}
func (s *DockerDaemonSuite) TearDownTest(c *check.C) { |
f9a3558a |
testRequires(c, DaemonIsLinux) |
11a95b95 |
if s.d != nil {
s.d.Stop()
} |
57464c32 |
s.ds.TearDownTest(c)
} |
58a1de9b |
func init() {
check.Suite(&DockerTrustSuite{
ds: &DockerSuite{},
})
}
type DockerTrustSuite struct {
ds *DockerSuite
reg *testRegistryV2
not *testNotary
}
func (s *DockerTrustSuite) SetUpTest(c *check.C) { |
db700a67 |
testRequires(c, RegistryHosting, NotaryServerHosting) |
1b5c2e1d |
s.reg = setupRegistry(c, false, "", "") |
58a1de9b |
s.not = setupNotary(c)
}
func (s *DockerTrustSuite) TearDownTest(c *check.C) { |
11a95b95 |
if s.reg != nil {
s.reg.Close()
}
if s.not != nil {
s.not.Close()
} |
ca57f4e6 |
// Remove trusted keys and metadata after test
os.RemoveAll(filepath.Join(cliconfig.ConfigDir(), "trust")) |
58a1de9b |
s.ds.TearDownTest(c)
} |