Browse code

Merge pull request #19822 from Microsoft/jjh/testexeccli

Windows CI: Initial porting CLI TestExec*

Vincent Demeester authored on 2016/02/02 16:32:28
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 = inspectField(c, id, "ExecIDs")
... ...
@@ -293,7 +302,7 @@ func (s *DockerSuite) TestInspectExecID(c *check.C) {
293 293
 
294 294
 	// Start an exec, have it block waiting so we can do some checking
295 295
 	cmd := exec.Command(dockerBinary, "exec", id, "sh", "-c",
296
-		"while ! test -e /tmp/execid1; do sleep 1; done")
296
+		"while ! test -e /execid1; do sleep 1; done")
297 297
 
298 298
 	err := cmd.Start()
299 299
 	c.Assert(err, checker.IsNil, check.Commentf("failed to start the exec cmd"))
... ...
@@ -318,7 +327,7 @@ func (s *DockerSuite) TestInspectExecID(c *check.C) {
318 318
 
319 319
 	// End the exec by creating the missing file
320 320
 	err = exec.Command(dockerBinary, "exec", id,
321
-		"sh", "-c", "touch /tmp/execid1").Run()
321
+		"sh", "-c", "touch /execid1").Run()
322 322
 
323 323
 	c.Assert(err, checker.IsNil, check.Commentf("failed to run the 2nd exec cmd"))
324 324
 
... ...
@@ -344,6 +353,7 @@ func (s *DockerSuite) TestInspectExecID(c *check.C) {
344 344
 }
345 345
 
346 346
 func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *check.C) {
347
+	// Problematic on Windows as Windows does not support links
347 348
 	testRequires(c, DaemonIsLinux)
348 349
 	var out string
349 350
 	out, _ = dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
... ...
@@ -358,12 +368,17 @@ func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *check.C) {
358 358
 	dockerCmd(c, "exec", "container2", "ping", "-c", "1", "alias1", "-W", "1")
359 359
 }
360 360
 
361
-func (s *DockerSuite) TestRunExecDir(c *check.C) {
361
+func (s *DockerSuite) TestExecDir(c *check.C) {
362
+	// TODO Windows CI. This requires some work to port as it uses execDriverPath
363
+	// which is currently (and incorrectly) hard coded as a string assuming
364
+	// the daemon is running Linux :(
362 365
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
363 366
 
364
-	out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
367
+	out, _ := runSleepingContainer(c, "-d")
365 368
 	id := strings.TrimSpace(out)
369
+
366 370
 	execDir := filepath.Join(execDriverPath, id)
371
+	fmt.Println(execDriverPath)
367 372
 	stateFile := filepath.Join(execDir, "state.json")
368 373
 
369 374
 	{
... ...
@@ -406,6 +421,7 @@ func (s *DockerSuite) TestRunExecDir(c *check.C) {
406 406
 }
407 407
 
408 408
 func (s *DockerSuite) TestRunMutableNetworkFiles(c *check.C) {
409
+	// Not applicable on Windows to Windows CI.
409 410
 	testRequires(c, SameHostDaemon, DaemonIsLinux)
410 411
 	for _, fn := range []string{"resolv.conf", "hosts"} {
411 412
 		deleteAllContainers()
... ...
@@ -444,6 +460,8 @@ func (s *DockerSuite) TestRunMutableNetworkFiles(c *check.C) {
444 444
 }
445 445
 
446 446
 func (s *DockerSuite) TestExecWithUser(c *check.C) {
447
+	// TODO Windows CI: This may be fixable in the future once Windows
448
+	// supports users
447 449
 	testRequires(c, DaemonIsLinux)
448 450
 	dockerCmd(c, "run", "-d", "--name", "parent", "busybox", "top")
449 451
 
... ...
@@ -455,6 +473,7 @@ func (s *DockerSuite) TestExecWithUser(c *check.C) {
455 455
 }
456 456
 
457 457
 func (s *DockerSuite) TestExecWithPrivileged(c *check.C) {
458
+	// Not applicable on Windows
458 459
 	testRequires(c, DaemonIsLinux, NotUserNamespace)
459 460
 	// Start main loop which attempts mknod repeatedly
460 461
 	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`)
... ...
@@ -488,6 +507,7 @@ func (s *DockerSuite) TestExecWithPrivileged(c *check.C) {
488 488
 }
489 489
 
490 490
 func (s *DockerSuite) TestExecWithImageUser(c *check.C) {
491
+	// Not applicable on Windows
491 492
 	testRequires(c, DaemonIsLinux)
492 493
 	name := "testbuilduser"
493 494
 	_, err := buildImage(name,
... ...
@@ -504,6 +524,7 @@ func (s *DockerSuite) TestExecWithImageUser(c *check.C) {
504 504
 }
505 505
 
506 506
 func (s *DockerSuite) TestExecOnReadonlyContainer(c *check.C) {
507
+	// Windows does not support read-only
507 508
 	// --read-only + userns has remount issues
508 509
 	testRequires(c, DaemonIsLinux, NotUserNamespace)
509 510
 	dockerCmd(c, "run", "-d", "--read-only", "--name", "parent", "busybox", "top")
... ...
@@ -512,9 +533,11 @@ func (s *DockerSuite) TestExecOnReadonlyContainer(c *check.C) {
512 512
 
513 513
 // #15750
514 514
 func (s *DockerSuite) TestExecStartFails(c *check.C) {
515
+	// TODO Windows CI. This test should be portable. Figure out why it fails
516
+	// currently.
515 517
 	testRequires(c, DaemonIsLinux)
516 518
 	name := "exec-15750"
517
-	dockerCmd(c, "run", "-d", "--name", name, "busybox", "top")
519
+	runSleepingContainer(c, "-d", "--name", name)
518 520
 	c.Assert(waitRun(name), checker.IsNil)
519 521
 
520 522
 	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