Skip to content

Commit a9379b4

Browse files
author
John Howard
committed
Windows CI: Initial porting CLI TestExec*
Signed-off-by: John Howard <jhoward@microsoft.com>
1 parent 5ee4ad1 commit a9379b4

File tree

2 files changed

+42
-15
lines changed

2 files changed

+42
-15
lines changed

integration-cli/docker_cli_exec_test.go

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ func (s *DockerSuite) TestExecInteractive(c *check.C) {
6666
}
6767

6868
func (s *DockerSuite) TestExecAfterContainerRestart(c *check.C) {
69-
testRequires(c, DaemonIsLinux)
70-
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
69+
out, _ := runSleepingContainer(c, "-d")
7170
cleanedContainerID := strings.TrimSpace(out)
7271
c.Assert(waitRun(cleanedContainerID), check.IsNil)
7372
dockerCmd(c, "restart", cleanedContainerID)
@@ -79,6 +78,7 @@ func (s *DockerSuite) TestExecAfterContainerRestart(c *check.C) {
7978
}
8079

8180
func (s *DockerDaemonSuite) TestExecAfterDaemonRestart(c *check.C) {
81+
// TODO Windows CI: Requires a little work to get this ported.
8282
testRequires(c, DaemonIsLinux)
8383
testRequires(c, SameHostDaemon)
8484

@@ -103,9 +103,12 @@ func (s *DockerDaemonSuite) TestExecAfterDaemonRestart(c *check.C) {
103103

104104
// Regression test for #9155, #9044
105105
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/
106110
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")
109112
c.Assert(waitRun("testing"), check.IsNil)
110113

111114
out, _ := dockerCmd(c, "exec", "testing", "env")
@@ -115,8 +118,7 @@ func (s *DockerSuite) TestExecEnv(c *check.C) {
115118
}
116119

117120
func (s *DockerSuite) TestExecExitStatus(c *check.C) {
118-
testRequires(c, DaemonIsLinux)
119-
dockerCmd(c, "run", "-d", "--name", "top", "busybox", "top")
121+
runSleepingContainer(c, "-d", "--name", "top")
120122

121123
// Test normal (non-detached) case first
122124
cmd := exec.Command(dockerBinary, "exec", "top", "sh", "-c", "exit 23")
@@ -125,6 +127,7 @@ func (s *DockerSuite) TestExecExitStatus(c *check.C) {
125127
}
126128

127129
func (s *DockerSuite) TestExecPausedContainer(c *check.C) {
130+
// Windows does not support pause
128131
testRequires(c, DaemonIsLinux)
129132
defer unpauseAllContainers()
130133

@@ -141,6 +144,7 @@ func (s *DockerSuite) TestExecPausedContainer(c *check.C) {
141144

142145
// regression test for #9476
143146
func (s *DockerSuite) TestExecTTYCloseStdin(c *check.C) {
147+
// TODO Windows CI: This requires some work to port to Windows.
144148
testRequires(c, DaemonIsLinux)
145149
dockerCmd(c, "run", "-d", "-it", "--name", "exec_tty_stdin", "busybox")
146150

@@ -161,6 +165,7 @@ func (s *DockerSuite) TestExecTTYCloseStdin(c *check.C) {
161165
}
162166

163167
func (s *DockerSuite) TestExecTTYWithoutStdin(c *check.C) {
168+
// TODO Windows CI: This requires some work to port to Windows.
164169
testRequires(c, DaemonIsLinux)
165170
out, _ := dockerCmd(c, "run", "-d", "-ti", "busybox")
166171
id := strings.TrimSpace(out)
@@ -195,6 +200,8 @@ func (s *DockerSuite) TestExecTTYWithoutStdin(c *check.C) {
195200
}
196201

197202
func (s *DockerSuite) TestExecParseError(c *check.C) {
203+
// TODO Windows CI: Requires some extra work. Consider copying the
204+
// runSleepingContainer helper to have an exec version.
198205
testRequires(c, DaemonIsLinux)
199206
dockerCmd(c, "run", "-d", "--name", "top", "busybox", "top")
200207

@@ -206,6 +213,8 @@ func (s *DockerSuite) TestExecParseError(c *check.C) {
206213
}
207214

208215
func (s *DockerSuite) TestExecStopNotHanging(c *check.C) {
216+
// TODO Windows CI: Requires some extra work. Consider copying the
217+
// runSleepingContainer helper to have an exec version.
209218
testRequires(c, DaemonIsLinux)
210219
dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "top")
211220

@@ -232,6 +241,7 @@ func (s *DockerSuite) TestExecStopNotHanging(c *check.C) {
232241
}
233242

234243
func (s *DockerSuite) TestExecCgroup(c *check.C) {
244+
// Not applicable on Windows - using Linux specific functionality
235245
testRequires(c, NotUserNamespace)
236246
testRequires(c, DaemonIsLinux)
237247
dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "top")
@@ -283,9 +293,8 @@ func (s *DockerSuite) TestExecCgroup(c *check.C) {
283293
}
284294
}
285295

286-
func (s *DockerSuite) TestInspectExecID(c *check.C) {
287-
testRequires(c, DaemonIsLinux)
288-
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
296+
func (s *DockerSuite) TestExecInspectID(c *check.C) {
297+
out, _ := runSleepingContainer(c, "-d")
289298
id := strings.TrimSuffix(out, "\n")
290299

291300
out, err := inspectField(id, "ExecIDs")
@@ -294,7 +303,7 @@ func (s *DockerSuite) TestInspectExecID(c *check.C) {
294303

295304
// Start an exec, have it block waiting so we can do some checking
296305
cmd := exec.Command(dockerBinary, "exec", id, "sh", "-c",
297-
"while ! test -e /tmp/execid1; do sleep 1; done")
306+
"while ! test -e /execid1; do sleep 1; done")
298307

299308
err = cmd.Start()
300309
c.Assert(err, checker.IsNil, check.Commentf("failed to start the exec cmd"))
@@ -320,7 +329,7 @@ func (s *DockerSuite) TestInspectExecID(c *check.C) {
320329

321330
// End the exec by creating the missing file
322331
err = exec.Command(dockerBinary, "exec", id,
323-
"sh", "-c", "touch /tmp/execid1").Run()
332+
"sh", "-c", "touch /execid1").Run()
324333

325334
c.Assert(err, checker.IsNil, check.Commentf("failed to run the 2nd exec cmd"))
326335

@@ -347,6 +356,7 @@ func (s *DockerSuite) TestInspectExecID(c *check.C) {
347356
}
348357

349358
func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *check.C) {
359+
// Problematic on Windows as Windows does not support links
350360
testRequires(c, DaemonIsLinux)
351361
var out string
352362
out, _ = dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
@@ -361,12 +371,17 @@ func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *check.C) {
361371
dockerCmd(c, "exec", "container2", "ping", "-c", "1", "alias1", "-W", "1")
362372
}
363373

364-
func (s *DockerSuite) TestRunExecDir(c *check.C) {
374+
func (s *DockerSuite) TestExecDir(c *check.C) {
375+
// TODO Windows CI. This requires some work to port as it uses execDriverPath
376+
// which is currently (and incorrectly) hard coded as a string assuming
377+
// the daemon is running Linux :(
365378
testRequires(c, SameHostDaemon, DaemonIsLinux)
366379

367-
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
380+
out, _ := runSleepingContainer(c, "-d")
368381
id := strings.TrimSpace(out)
382+
369383
execDir := filepath.Join(execDriverPath, id)
384+
fmt.Println(execDriverPath)
370385
stateFile := filepath.Join(execDir, "state.json")
371386

372387
{
@@ -409,6 +424,7 @@ func (s *DockerSuite) TestRunExecDir(c *check.C) {
409424
}
410425

411426
func (s *DockerSuite) TestRunMutableNetworkFiles(c *check.C) {
427+
// Not applicable on Windows to Windows CI.
412428
testRequires(c, SameHostDaemon, DaemonIsLinux)
413429
for _, fn := range []string{"resolv.conf", "hosts"} {
414430
deleteAllContainers()
@@ -447,6 +463,8 @@ func (s *DockerSuite) TestRunMutableNetworkFiles(c *check.C) {
447463
}
448464

449465
func (s *DockerSuite) TestExecWithUser(c *check.C) {
466+
// TODO Windows CI: This may be fixable in the future once Windows
467+
// supports users
450468
testRequires(c, DaemonIsLinux)
451469
dockerCmd(c, "run", "-d", "--name", "parent", "busybox", "top")
452470

@@ -458,6 +476,7 @@ func (s *DockerSuite) TestExecWithUser(c *check.C) {
458476
}
459477

460478
func (s *DockerSuite) TestExecWithPrivileged(c *check.C) {
479+
// Not applicable on Windows
461480
testRequires(c, DaemonIsLinux, NotUserNamespace)
462481
// Start main loop which attempts mknod repeatedly
463482
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) {
491510
}
492511

493512
func (s *DockerSuite) TestExecWithImageUser(c *check.C) {
513+
// Not applicable on Windows
494514
testRequires(c, DaemonIsLinux)
495515
name := "testbuilduser"
496516
_, err := buildImage(name,
@@ -507,6 +527,7 @@ func (s *DockerSuite) TestExecWithImageUser(c *check.C) {
507527
}
508528

509529
func (s *DockerSuite) TestExecOnReadonlyContainer(c *check.C) {
530+
// Windows does not support read-only
510531
// --read-only + userns has remount issues
511532
testRequires(c, DaemonIsLinux, NotUserNamespace)
512533
dockerCmd(c, "run", "-d", "--read-only", "--name", "parent", "busybox", "top")
@@ -515,9 +536,11 @@ func (s *DockerSuite) TestExecOnReadonlyContainer(c *check.C) {
515536

516537
// #15750
517538
func (s *DockerSuite) TestExecStartFails(c *check.C) {
539+
// TODO Windows CI. This test should be portable. Figure out why it fails
540+
// currently.
518541
testRequires(c, DaemonIsLinux)
519542
name := "exec-15750"
520-
dockerCmd(c, "run", "-d", "--name", name, "busybox", "top")
543+
runSleepingContainer(c, "-d", "--name", name)
521544
c.Assert(waitRun(name), checker.IsNil)
522545

523546
out, _, err := dockerCmdWithError("exec", name, "no-such-cmd")

integration-cli/docker_test_vars.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ var (
1919
// the private registry to use for tests
2020
privateRegistryURL = "127.0.0.1:5000"
2121

22+
// TODO Windows CI. These are incorrect and need fixing into
23+
// platform specific pieces.
2224
runtimePath = "/var/run/docker"
2325
execDriverPath = runtimePath + "/execdriver/native"
2426

@@ -84,7 +86,7 @@ func init() {
8486
// to evaluate whether the daemon is local or remote is not possible through
8587
// a build tag.
8688
//
87-
// For example Windows CI under Jenkins test the 64-bit
89+
// For example Windows to Linux CI under Jenkins tests the 64-bit
8890
// Windows binary build with the daemon build tag, but calls a remote
8991
// Linux daemon.
9092
//
@@ -99,6 +101,8 @@ func init() {
99101
isLocalDaemon = true
100102
}
101103

104+
// TODO Windows CI. This are incorrect and need fixing into
105+
// platform specific pieces.
102106
// This is only used for a tests with local daemon true (Linux-only today)
103107
// default is "/var/lib/docker", but we'll try and ask the
104108
// /info endpoint for the specific root dir

0 commit comments

Comments
 (0)