Browse code

Change related tests from DockerSuite to DockerDaemonSuite in `docker_cli_info_test.go`

This fix changes related tests from DockerSuite to DockerDaemonSuite
in `docker_cli_info_test.go`. Previously that was done through `NewDaemon()`.

This fix is related to the comments in:
https://github.com/docker/docker/pull/26115#discussion_r76784977
https://github.com/docker/docker/pull/24533#issuecomment-243420042

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

Yong Tang authored on 2016/08/31 02:11:01
Showing 1 changed files
... ...
@@ -63,17 +63,15 @@ func (s *DockerSuite) TestInfoFormat(c *check.C) {
63 63
 
64 64
 // TestInfoDiscoveryBackend verifies that a daemon run with `--cluster-advertise` and
65 65
 // `--cluster-store` properly show the backend's endpoint in info output.
66
-func (s *DockerSuite) TestInfoDiscoveryBackend(c *check.C) {
66
+func (s *DockerDaemonSuite) TestInfoDiscoveryBackend(c *check.C) {
67 67
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
68 68
 
69
-	d := NewDaemon(c)
70 69
 	discoveryBackend := "consul://consuladdr:consulport/some/path"
71 70
 	discoveryAdvertise := "1.1.1.1:2375"
72
-	err := d.Start(fmt.Sprintf("--cluster-store=%s", discoveryBackend), fmt.Sprintf("--cluster-advertise=%s", discoveryAdvertise))
71
+	err := s.d.Start(fmt.Sprintf("--cluster-store=%s", discoveryBackend), fmt.Sprintf("--cluster-advertise=%s", discoveryAdvertise))
73 72
 	c.Assert(err, checker.IsNil)
74
-	defer d.Stop()
75 73
 
76
-	out, err := d.Cmd("info")
74
+	out, err := s.d.Cmd("info")
77 75
 	c.Assert(err, checker.IsNil)
78 76
 	c.Assert(out, checker.Contains, fmt.Sprintf("Cluster Store: %s\n", discoveryBackend))
79 77
 	c.Assert(out, checker.Contains, fmt.Sprintf("Cluster Advertise: %s\n", discoveryAdvertise))
... ...
@@ -81,33 +79,30 @@ func (s *DockerSuite) TestInfoDiscoveryBackend(c *check.C) {
81 81
 
82 82
 // TestInfoDiscoveryInvalidAdvertise verifies that a daemon run with
83 83
 // an invalid `--cluster-advertise` configuration
84
-func (s *DockerSuite) TestInfoDiscoveryInvalidAdvertise(c *check.C) {
84
+func (s *DockerDaemonSuite) TestInfoDiscoveryInvalidAdvertise(c *check.C) {
85 85
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
86 86
 
87
-	d := NewDaemon(c)
88 87
 	discoveryBackend := "consul://consuladdr:consulport/some/path"
89 88
 
90 89
 	// --cluster-advertise with an invalid string is an error
91
-	err := d.Start(fmt.Sprintf("--cluster-store=%s", discoveryBackend), "--cluster-advertise=invalid")
90
+	err := s.d.Start(fmt.Sprintf("--cluster-store=%s", discoveryBackend), "--cluster-advertise=invalid")
92 91
 	c.Assert(err, checker.Not(checker.IsNil))
93 92
 
94 93
 	// --cluster-advertise without --cluster-store is also an error
95
-	err = d.Start("--cluster-advertise=1.1.1.1:2375")
94
+	err = s.d.Start("--cluster-advertise=1.1.1.1:2375")
96 95
 	c.Assert(err, checker.Not(checker.IsNil))
97 96
 }
98 97
 
99 98
 // TestInfoDiscoveryAdvertiseInterfaceName verifies that a daemon run with `--cluster-advertise`
100 99
 // configured with interface name properly show the advertise ip-address in info output.
101
-func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *check.C) {
100
+func (s *DockerDaemonSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *check.C) {
102 101
 	testRequires(c, SameHostDaemon, Network, DaemonIsLinux)
103 102
 
104
-	d := NewDaemon(c)
105 103
 	discoveryBackend := "consul://consuladdr:consulport/some/path"
106 104
 	discoveryAdvertise := "eth0"
107 105
 
108
-	err := d.Start(fmt.Sprintf("--cluster-store=%s", discoveryBackend), fmt.Sprintf("--cluster-advertise=%s:2375", discoveryAdvertise))
106
+	err := s.d.Start(fmt.Sprintf("--cluster-store=%s", discoveryBackend), fmt.Sprintf("--cluster-advertise=%s:2375", discoveryAdvertise))
109 107
 	c.Assert(err, checker.IsNil)
110
-	defer d.Stop()
111 108
 
112 109
 	iface, err := net.InterfaceByName(discoveryAdvertise)
113 110
 	c.Assert(err, checker.IsNil)
... ...
@@ -117,7 +112,7 @@ func (s *DockerSuite) TestInfoDiscoveryAdvertiseInterfaceName(c *check.C) {
117 117
 	ip, _, err := net.ParseCIDR(addrs[0].String())
118 118
 	c.Assert(err, checker.IsNil)
119 119
 
120
-	out, err := d.Cmd("info")
120
+	out, err := s.d.Cmd("info")
121 121
 	c.Assert(err, checker.IsNil)
122 122
 	c.Assert(out, checker.Contains, fmt.Sprintf("Cluster Store: %s\n", discoveryBackend))
123 123
 	c.Assert(out, checker.Contains, fmt.Sprintf("Cluster Advertise: %s:2375\n", ip.String()))
... ...
@@ -164,15 +159,13 @@ func (s *DockerSuite) TestInfoDisplaysStoppedContainers(c *check.C) {
164 164
 	c.Assert(out, checker.Contains, fmt.Sprintf(" Stopped: %d\n", 1))
165 165
 }
166 166
 
167
-func (s *DockerSuite) TestInfoDebug(c *check.C) {
167
+func (s *DockerDaemonSuite) TestInfoDebug(c *check.C) {
168 168
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
169 169
 
170
-	d := NewDaemon(c)
171
-	err := d.Start("--debug")
170
+	err := s.d.Start("--debug")
172 171
 	c.Assert(err, checker.IsNil)
173
-	defer d.Stop()
174 172
 
175
-	out, err := d.Cmd("--debug", "info")
173
+	out, err := s.d.Cmd("--debug", "info")
176 174
 	c.Assert(err, checker.IsNil)
177 175
 	c.Assert(out, checker.Contains, "Debug Mode (client): true\n")
178 176
 	c.Assert(out, checker.Contains, "Debug Mode (server): true\n")
... ...
@@ -183,18 +176,16 @@ func (s *DockerSuite) TestInfoDebug(c *check.C) {
183 183
 	c.Assert(out, checker.Contains, "Docker Root Dir")
184 184
 }
185 185
 
186
-func (s *DockerSuite) TestInsecureRegistries(c *check.C) {
186
+func (s *DockerDaemonSuite) TestInsecureRegistries(c *check.C) {
187 187
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
188 188
 
189 189
 	registryCIDR := "192.168.1.0/24"
190 190
 	registryHost := "insecurehost.com:5000"
191 191
 
192
-	d := NewDaemon(c)
193
-	err := d.Start("--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost)
192
+	err := s.d.Start("--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost)
194 193
 	c.Assert(err, checker.IsNil)
195
-	defer d.Stop()
196 194
 
197
-	out, err := d.Cmd("info")
195
+	out, err := s.d.Cmd("info")
198 196
 	c.Assert(err, checker.IsNil)
199 197
 	c.Assert(out, checker.Contains, "Insecure Registries:\n")
200 198
 	c.Assert(out, checker.Contains, fmt.Sprintf(" %s\n", registryHost))