check_test.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. package main
  2. import (
  3. "fmt"
  4. "testing"
  5. "github.com/docker/docker/pkg/reexec"
  6. "github.com/go-check/check"
  7. )
  8. func Test(t *testing.T) {
  9. reexec.Init() // This is required for external graphdriver tests
  10. if !isLocalDaemon {
  11. fmt.Println("INFO: Testing against a remote daemon")
  12. } else {
  13. fmt.Println("INFO: Testing against a local daemon")
  14. }
  15. check.TestingT(t)
  16. }
  17. func init() {
  18. check.Suite(&DockerSuite{})
  19. }
  20. type DockerSuite struct {
  21. }
  22. func (s *DockerSuite) TearDownTest(c *check.C) {
  23. unpauseAllContainers()
  24. deleteAllContainers()
  25. deleteAllImages()
  26. deleteAllVolumes()
  27. deleteAllNetworks()
  28. }
  29. func init() {
  30. check.Suite(&DockerRegistrySuite{
  31. ds: &DockerSuite{},
  32. })
  33. }
  34. type DockerRegistrySuite struct {
  35. ds *DockerSuite
  36. reg *testRegistryV2
  37. d *Daemon
  38. }
  39. func (s *DockerRegistrySuite) SetUpTest(c *check.C) {
  40. testRequires(c, DaemonIsLinux, RegistryHosting)
  41. s.reg = setupRegistry(c, false, false)
  42. s.d = NewDaemon(c)
  43. }
  44. func (s *DockerRegistrySuite) TearDownTest(c *check.C) {
  45. if s.reg != nil {
  46. s.reg.Close()
  47. }
  48. if s.d != nil {
  49. s.d.Stop()
  50. }
  51. s.ds.TearDownTest(c)
  52. }
  53. func init() {
  54. check.Suite(&DockerSchema1RegistrySuite{
  55. ds: &DockerSuite{},
  56. })
  57. }
  58. type DockerSchema1RegistrySuite struct {
  59. ds *DockerSuite
  60. reg *testRegistryV2
  61. d *Daemon
  62. }
  63. func (s *DockerSchema1RegistrySuite) SetUpTest(c *check.C) {
  64. testRequires(c, DaemonIsLinux, RegistryHosting)
  65. s.reg = setupRegistry(c, true, false)
  66. s.d = NewDaemon(c)
  67. }
  68. func (s *DockerSchema1RegistrySuite) TearDownTest(c *check.C) {
  69. if s.reg != nil {
  70. s.reg.Close()
  71. }
  72. if s.d != nil {
  73. s.d.Stop()
  74. }
  75. s.ds.TearDownTest(c)
  76. }
  77. func init() {
  78. check.Suite(&DockerRegistryAuthSuite{
  79. ds: &DockerSuite{},
  80. })
  81. }
  82. type DockerRegistryAuthSuite struct {
  83. ds *DockerSuite
  84. reg *testRegistryV2
  85. d *Daemon
  86. }
  87. func (s *DockerRegistryAuthSuite) SetUpTest(c *check.C) {
  88. testRequires(c, DaemonIsLinux, RegistryHosting)
  89. s.reg = setupRegistry(c, false, true)
  90. s.d = NewDaemon(c)
  91. }
  92. func (s *DockerRegistryAuthSuite) TearDownTest(c *check.C) {
  93. if s.reg != nil {
  94. out, err := s.d.Cmd("logout", privateRegistryURL)
  95. c.Assert(err, check.IsNil, check.Commentf(out))
  96. s.reg.Close()
  97. }
  98. if s.d != nil {
  99. s.d.Stop()
  100. }
  101. s.ds.TearDownTest(c)
  102. }
  103. func init() {
  104. check.Suite(&DockerDaemonSuite{
  105. ds: &DockerSuite{},
  106. })
  107. }
  108. type DockerDaemonSuite struct {
  109. ds *DockerSuite
  110. d *Daemon
  111. }
  112. func (s *DockerDaemonSuite) SetUpTest(c *check.C) {
  113. testRequires(c, DaemonIsLinux)
  114. s.d = NewDaemon(c)
  115. }
  116. func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
  117. testRequires(c, DaemonIsLinux)
  118. if s.d != nil {
  119. s.d.Stop()
  120. }
  121. s.ds.TearDownTest(c)
  122. }
  123. func init() {
  124. check.Suite(&DockerTrustSuite{
  125. ds: &DockerSuite{},
  126. })
  127. }
  128. type DockerTrustSuite struct {
  129. ds *DockerSuite
  130. reg *testRegistryV2
  131. not *testNotary
  132. }
  133. func (s *DockerTrustSuite) SetUpTest(c *check.C) {
  134. testRequires(c, RegistryHosting, NotaryHosting)
  135. s.reg = setupRegistry(c, false, false)
  136. s.not = setupNotary(c)
  137. }
  138. func (s *DockerTrustSuite) TearDownTest(c *check.C) {
  139. if s.reg != nil {
  140. s.reg.Close()
  141. }
  142. if s.not != nil {
  143. s.not.Close()
  144. }
  145. s.ds.TearDownTest(c)
  146. }