Browse code

Fixing win2lin builds by adding a testRequires to DockerDaemonSuite

The success of the win2lin CI before was really "by chance" on the
DockerDaemonSuite : the DockerDaemonSuite was panicking when starting
the daemon on the first non-skipped test.The suite panicked but as
the error returned from `StartWithBusybox` was nil, the test kept
going and was OK because the client had all the correct environment
variables set up to discuss with the remote daemon.

Then, as the suite panicked, no more test attached on the
DockerDaemonSuite ran (that's why on win2lin, `DockerDaemonSuite` was
only composed by 5 tests !). The really bad thing is, we didn't get
any report of the panic on the suite (go-check hiding something
somewhere).

As DockerDaemonSuite needs to run test on the same host as it's
running, this adds a `SameHostDaemon` requirement to the Suite.

This changes also make sure `TestRestartContainerWithRestartPolicy`
does left weirdies behind it.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Vincent Demeester authored on 2016/12/13 20:04:53
Showing 3 changed files
... ...
@@ -217,14 +217,14 @@ func (s *DockerDaemonSuite) OnTimeout(c *check.C) {
217 217
 }
218 218
 
219 219
 func (s *DockerDaemonSuite) SetUpTest(c *check.C) {
220
-	testRequires(c, DaemonIsLinux)
220
+	testRequires(c, DaemonIsLinux, SameHostDaemon)
221 221
 	s.d = daemon.New(c, dockerBinary, dockerdBinary, daemon.Config{
222 222
 		Experimental: experimentalDaemon,
223 223
 	})
224 224
 }
225 225
 
226 226
 func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
227
-	testRequires(c, DaemonIsLinux)
227
+	testRequires(c, DaemonIsLinux, SameHostDaemon)
228 228
 	if s.d != nil {
229 229
 		s.d.Stop(c)
230 230
 	}
... ...
@@ -195,7 +195,6 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
195 195
 	if err != nil {
196 196
 		return errors.Wrapf(err, "[%s] could not find docker binary in $PATH", d.id)
197 197
 	}
198
-
199 198
 	args := append(d.GlobalFlags,
200 199
 		"--containerd", "/var/run/docker/libcontainerd/docker-containerd.sock",
201 200
 		"--graph", d.Root,
... ...
@@ -259,10 +259,19 @@ func (s *DockerSuite) TestRestartContainerwithRestartPolicy(c *check.C) {
259 259
 	dockerCmd(c, "restart", id1)
260 260
 	dockerCmd(c, "restart", id2)
261 261
 
262
+	// Make sure we can stop/start (regression test from a705e166cf3bcca62543150c2b3f9bfeae45ecfa)
262 263
 	dockerCmd(c, "stop", id1)
263 264
 	dockerCmd(c, "stop", id2)
264 265
 	dockerCmd(c, "start", id1)
265 266
 	dockerCmd(c, "start", id2)
267
+
268
+	// Kill the containers, making sure the are stopped at the end of the test
269
+	dockerCmd(c, "kill", id1)
270
+	dockerCmd(c, "kill", id2)
271
+	err = waitInspect(id1, "{{ .State.Restarting }} {{ .State.Running }}", "false false", waitTimeout)
272
+	c.Assert(err, checker.IsNil)
273
+	err = waitInspect(id2, "{{ .State.Restarting }} {{ .State.Running }}", "false false", waitTimeout)
274
+	c.Assert(err, checker.IsNil)
266 275
 }
267 276
 
268 277
 func (s *DockerSuite) TestRestartAutoRemoveContainer(c *check.C) {