Browse code

Windows CI: Initial porting CLI TestExec*

Signed-off-by: John Howard <jhoward@microsoft.com>

John Howard authored on 2016/01/29 11:22:24
Showing 2 changed files
... ...
@@ -66,8 +66,7 @@ func (s *DockerSuite) TestExecInteractive(c *check.C) {
66 66
 }
67 67
 
68 68
 func (s *DockerSuite) TestExecAfterContainerRestart(c *check.C) {
69
-	testRequires(c, DaemonIsLinux)
70
-	out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
69
+	out, _ := runSleepingContainer(c, "-d")
71 70
 	cleanedContainerID := strings.TrimSpace(out)
72 71
 	c.Assert(waitRun(cleanedContainerID), check.IsNil)
73 72
 	dockerCmd(c, "restart", cleanedContainerID)
... ...
@@ -79,6 +78,7 @@ func (s *DockerSuite) TestExecAfterContainerRestart(c *check.C) {
79 79
 }
80 80
 
81 81
 func (s *DockerDaemonSuite) TestExecAfterDaemonRestart(c *check.C) {
82
+	// TODO Windows CI: Requires a little work to get this ported.
82 83
 	testRequires(c, DaemonIsLinux)
83 84
 	testRequires(c, SameHostDaemon)
84 85
 
... ...
@@ -103,9 +103,12 @@ func (s *DockerDaemonSuite) TestExecAfterDaemonRestart(c *check.C) {
103 103
 
104 104
 // Regression test for #9155, #9044
105 105
 func (s *DockerSuite) TestExecEnv(c *check.C) {
106
+	// TODO Windows CI: This one is interesting and may just end up being a feature
107
+	// difference between Windows and Linux. On Windows, the environment is passed
108
+	// into the process that is launched, not into the machine environment. Hence
109
+	// a subsequent exec will not have LALA set/
106 110
 	testRequires(c, DaemonIsLinux)
107
-	dockerCmd(c, "run", "-e", "LALA=value1", "-e", "LALA=value2",
108
-		"-d", "--name", "testing", "busybox", "top")
111
+	runSleepingContainer(c, "-e", "LALA=value1", "-e", "LALA=value2", "-d", "--name", "testing")
109 112
 	c.Assert(waitRun("testing"), check.IsNil)
110 113
 
111 114
 	out, _ := dockerCmd(c, "exec", "testing", "env")
... ...
@@ -115,8 +118,7 @@ func (s *DockerSuite) TestExecEnv(c *check.C) {
115 115
 }
116 116
 
117 117
 func (s *DockerSuite) TestExecExitStatus(c *check.C) {
118
-	testRequires(c, DaemonIsLinux)
119
-	dockerCmd(c, "run", "-d", "--name", "top", "busybox", "top")
118
+	runSleepingContainer(c, "-d", "--name", "top")
120 119
 
121 120
 	// Test normal (non-detached) case first
122 121
 	cmd := exec.Command(dockerBinary, "exec", "top", "sh", "-c", "exit 23")
... ...
@@ -125,6 +127,7 @@ func (s *DockerSuite) TestExecExitStatus(c *check.C) {
125 125
 }
126 126
 
127 127
 func (s *DockerSuite) TestExecPausedContainer(c *check.C) {
128
+	// Windows does not support pause
128 129
 	testRequires(c, DaemonIsLinux)
129 130
 	defer unpauseAllContainers()
130 131
 
... ...
@@ -141,6 +144,7 @@ func (s *DockerSuite) TestExecPausedContainer(c *check.C) {
141 141
 
142 142
 // regression test for #9476
143 143
 func (s *DockerSuite) TestExecTTYCloseStdin(c *check.C) {
144
+	// TODO Windows CI: This requires some work to port to Windows.
144 145
 	testRequires(c, DaemonIsLinux)
145 146
 	dockerCmd(c, "run", "-d", "-it", "--name", "exec_tty_stdin", "busybox")
146 147
 
... ...
@@ -161,6 +165,7 @@ func (s *DockerSuite) TestExecTTYCloseStdin(c *check.C) {
161 161
 }
162 162
 
163 163
 func (s *DockerSuite) TestExecTTYWithoutStdin(c *check.C) {
164
+	// TODO Windows CI: This requires some work to port to Windows.
164 165
 	testRequires(c, DaemonIsLinux)
165 166
 	out, _ := dockerCmd(c, "run", "-d", "-ti", "busybox")
166 167
 	id := strings.TrimSpace(out)
... ...
@@ -195,6 +200,8 @@ func (s *DockerSuite) TestExecTTYWithoutStdin(c *check.C) {
195 195
 }
196 196
 
197 197
 func (s *DockerSuite) TestExecParseError(c *check.C) {
198
+	// TODO Windows CI: Requires some extra work. Consider copying the
199
+	// runSleepingContainer helper to have an exec version.
198 200
 	testRequires(c, DaemonIsLinux)
199 201
 	dockerCmd(c, "run", "-d", "--name", "top", "busybox", "top")
200 202
 
... ...
@@ -206,6 +213,8 @@ func (s *DockerSuite) TestExecParseError(c *check.C) {
206 206
 }
207 207
 
208 208
 func (s *DockerSuite) TestExecStopNotHanging(c *check.C) {
209
+	// TODO Windows CI: Requires some extra work. Consider copying the
210
+	// runSleepingContainer helper to have an exec version.
209 211
 	testRequires(c, DaemonIsLinux)
210 212
 	dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "top")
211 213
 
... ...
@@ -232,6 +241,7 @@ func (s *DockerSuite) TestExecStopNotHanging(c *check.C) {
232 232
 }
233 233
 
234 234
 func (s *DockerSuite) TestExecCgroup(c *check.C) {
235
+	// Not applicable on Windows - using Linux specific functionality
235 236
 	testRequires(c, NotUserNamespace)
236 237
 	testRequires(c, DaemonIsLinux)
237 238
 	dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "top")
... ...
@@ -283,9 +293,8 @@ func (s *DockerSuite) TestExecCgroup(c *check.C) {
283 283
 	}
284 284
 }
285 285
 
286
-func (s *DockerSuite) TestInspectExecID(c *check.C) {
287
-	testRequires(c, DaemonIsLinux)
288
-	out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
286
+func (s *DockerSuite) TestExecInspectID(c *check.C) {
287
+	out, _ := runSleepingContainer(c, "-d")
289 288
 	id := strings.TrimSuffix(out, "\n")
290 289
 
291 290
 	out, err := inspectField(id, "ExecIDs")
... ...
@@ -294,7 +303,7 @@ func (s *DockerSuite) TestInspectExecID(c *check.C) {
294 294
 
295 295
 	// Start an exec, have it block waiting so we can do some checking
296 296
 	cmd := exec.Command(dockerBinary, "exec", id, "sh", "-c",
297
-		"while ! test -e /tmp/execid1; do sleep 1; done")
297
+		"while ! test -e /execid1; do sleep 1; done")
298 298
 
299 299
 	err = cmd.Start()
300 300
 	c.Assert(err, checker.IsNil, check.Commentf("failed to start the exec cmd"))
... ...
@@ -320,7 +329,7 @@ func (s *DockerSuite) TestInspectExecID(c *check.C) {
320 320
 
321 321
 	// End the exec by creating the missing file
322 322
 	err = exec.Command(dockerBinary, "exec", id,
323
-		"sh", "-c", "touch /tmp/execid1").Run()
323
+		"sh", "-c", "touch /execid1").Run()
324 324
 
325 325
 	c.Assert(err, checker.IsNil, check.Commentf("failed to run the 2nd exec cmd"))
326 326
 
... ...
@@ -347,6 +356,7 @@ func (s *DockerSuite) TestInspectExecID(c *check.C) {
347 347
 }
348 348
 
349 349
 func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *check.C) {
350
+	// Problematic on Windows as Windows does not support links
350 351
 	testRequires(c, DaemonIsLinux)
351 352
 	var out string
352 353
 	out, _ = dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
... ...
@@ -361,12 +371,17 @@ func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *check.C) {
361 361
 	dockerCmd(c, "exec", "container2", "ping", "-c", "1", "alias1", "-W", "1")
362 362
 }
363 363
 
364
-func (s *DockerSuite) TestRunExecDir(c *check.C) {
364
+func (s *DockerSuite) TestExecDir(c *check.C) {
365
+	// TODO Windows CI. This requires some work to port as it uses execDriverPath
366
+	// which is currently (and incorrectly) hard coded as a string assuming
367
+	// the daemon is running Linux :(
365 368
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
366 369
 
367
-	out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
370
+	out, _ := runSleepingContainer(c, "-d")
368 371
 	id := strings.TrimSpace(out)
372
+
369 373
 	execDir := filepath.Join(execDriverPath, id)
374
+	fmt.Println(execDriverPath)
370 375
 	stateFile := filepath.Join(execDir, "state.json")
371 376
 
372 377
 	{
... ...
@@ -409,6 +424,7 @@ func (s *DockerSuite) TestRunExecDir(c *check.C) {
409 409
 }
410 410
 
411 411
 func (s *DockerSuite) TestRunMutableNetworkFiles(c *check.C) {
412
+	// Not applicable on Windows to Windows CI.
412 413
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
413 414
 	for _, fn := range []string{"resolv.conf", "hosts"} {
414 415
 		deleteAllContainers()
... ...
@@ -447,6 +463,8 @@ func (s *DockerSuite) TestRunMutableNetworkFiles(c *check.C) {
447 447
 }
448 448
 
449 449
 func (s *DockerSuite) TestExecWithUser(c *check.C) {
450
+	// TODO Windows CI: This may be fixable in the future once Windows
451
+	// supports users
450 452
 	testRequires(c, DaemonIsLinux)
451 453
 	dockerCmd(c, "run", "-d", "--name", "parent", "busybox", "top")
452 454
 
... ...
@@ -458,6 +476,7 @@ func (s *DockerSuite) TestExecWithUser(c *check.C) {
458 458
 }
459 459
 
460 460
 func (s *DockerSuite) TestExecWithPrivileged(c *check.C) {
461
+	// Not applicable on Windows
461 462
 	testRequires(c, DaemonIsLinux, NotUserNamespace)
462 463
 	// Start main loop which attempts mknod repeatedly
463 464
 	dockerCmd(c, "run", "-d", "--name", "parent", "--cap-drop=ALL", "busybox", "sh", "-c", `while (true); do if [ -e /exec_priv ]; then cat /exec_priv && mknod /tmp/sda b 8 0 && echo "Success"; else echo "Privileged exec has not run yet"; fi; usleep 10000; done`)
... ...
@@ -491,6 +510,7 @@ func (s *DockerSuite) TestExecWithPrivileged(c *check.C) {
491 491
 }
492 492
 
493 493
 func (s *DockerSuite) TestExecWithImageUser(c *check.C) {
494
+	// Not applicable on Windows
494 495
 	testRequires(c, DaemonIsLinux)
495 496
 	name := "testbuilduser"
496 497
 	_, err := buildImage(name,
... ...
@@ -507,6 +527,7 @@ func (s *DockerSuite) TestExecWithImageUser(c *check.C) {
507 507
 }
508 508
 
509 509
 func (s *DockerSuite) TestExecOnReadonlyContainer(c *check.C) {
510
+	// Windows does not support read-only
510 511
 	// --read-only + userns has remount issues
511 512
 	testRequires(c, DaemonIsLinux, NotUserNamespace)
512 513
 	dockerCmd(c, "run", "-d", "--read-only", "--name", "parent", "busybox", "top")
... ...
@@ -515,9 +536,11 @@ func (s *DockerSuite) TestExecOnReadonlyContainer(c *check.C) {
515 515
 
516 516
 // #15750
517 517
 func (s *DockerSuite) TestExecStartFails(c *check.C) {
518
+	// TODO Windows CI. This test should be portable. Figure out why it fails
519
+	// currently.
518 520
 	testRequires(c, DaemonIsLinux)
519 521
 	name := "exec-15750"
520
-	dockerCmd(c, "run", "-d", "--name", name, "busybox", "top")
522
+	runSleepingContainer(c, "-d", "--name", name)
521 523
 	c.Assert(waitRun(name), checker.IsNil)
522 524
 
523 525
 	out, _, err := dockerCmdWithError("exec", name, "no-such-cmd")
... ...
@@ -19,6 +19,8 @@ var (
19 19
 	// the private registry to use for tests
20 20
 	privateRegistryURL = "127.0.0.1:5000"
21 21
 
22
+	// TODO Windows CI. These are incorrect and need fixing into
23
+	// platform specific pieces.
22 24
 	runtimePath    = "/var/run/docker"
23 25
 	execDriverPath = runtimePath + "/execdriver/native"
24 26
 
... ...
@@ -84,7 +86,7 @@ func init() {
84 84
 	// to evaluate whether the daemon is local or remote is not possible through
85 85
 	// a build tag.
86 86
 	//
87
-	// For example Windows CI under Jenkins test the 64-bit
87
+	// For example Windows to Linux CI under Jenkins tests the 64-bit
88 88
 	// Windows binary build with the daemon build tag, but calls a remote
89 89
 	// Linux daemon.
90 90
 	//
... ...
@@ -99,6 +101,8 @@ func init() {
99 99
 		isLocalDaemon = true
100 100
 	}
101 101
 
102
+	// TODO Windows CI. This are incorrect and need fixing into
103
+	// platform specific pieces.
102 104
 	// This is only used for a tests with local daemon true (Linux-only today)
103 105
 	// default is "/var/lib/docker", but we'll try and ask the
104 106
 	// /info endpoint for the specific root dir