check_test.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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)
  41. s.reg = setupRegistry(c, 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)
  65. s.reg = setupRegistry(c, true)
  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(&DockerDaemonSuite{
  79. ds: &DockerSuite{},
  80. })
  81. }
  82. type DockerDaemonSuite struct {
  83. ds *DockerSuite
  84. d *Daemon
  85. }
  86. func (s *DockerDaemonSuite) SetUpTest(c *check.C) {
  87. testRequires(c, DaemonIsLinux)
  88. s.d = NewDaemon(c)
  89. }
  90. func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
  91. testRequires(c, DaemonIsLinux)
  92. if s.d != nil {
  93. s.d.Stop()
  94. }
  95. s.ds.TearDownTest(c)
  96. }
  97. func init() {
  98. check.Suite(&DockerTrustSuite{
  99. ds: &DockerSuite{},
  100. })
  101. }
  102. type DockerTrustSuite struct {
  103. ds *DockerSuite
  104. reg *testRegistryV2
  105. not *testNotary
  106. }
  107. func (s *DockerTrustSuite) SetUpTest(c *check.C) {
  108. testRequires(c, NotArm)
  109. s.reg = setupRegistry(c, false)
  110. s.not = setupNotary(c)
  111. }
  112. func (s *DockerTrustSuite) TearDownTest(c *check.C) {
  113. if s.reg != nil {
  114. s.reg.Close()
  115. }
  116. if s.not != nil {
  117. s.not.Close()
  118. }
  119. s.ds.TearDownTest(c)
  120. }