Browse code

Enabled more test on Windows, API and Build

Signed-off-by: Darren Stahl <darst@microsoft.com>

Darren Stahl authored on 2016/10/07 09:18:42
Showing 2 changed files
... ...
@@ -125,7 +125,7 @@ func (s *DockerSuite) TestContainerAPIPsOmitFields(c *check.C) {
125 125
 }
126 126
 
127 127
 func (s *DockerSuite) TestContainerAPIGetExport(c *check.C) {
128
-	// TODO: Investigate why this fails on Windows to Windows CI
128
+	// Not supported on Windows as Windows does not support docker export
129 129
 	testRequires(c, DaemonIsLinux)
130 130
 	name := "exportcontainer"
131 131
 	dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test")
... ...
@@ -371,7 +371,6 @@ func (s *DockerSuite) TestContainerAPIPause(c *check.C) {
371 371
 }
372 372
 
373 373
 func (s *DockerSuite) TestContainerAPITop(c *check.C) {
374
-	// Problematic on Windows as Windows does not support top
375 374
 	testRequires(c, DaemonIsLinux)
376 375
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "/bin/sh", "-c", "top")
377 376
 	id := strings.TrimSpace(string(out))
... ...
@@ -396,6 +395,40 @@ func (s *DockerSuite) TestContainerAPITop(c *check.C) {
396 396
 	c.Assert(top.Processes[1][10], checker.Equals, "top")
397 397
 }
398 398
 
399
+func (s *DockerSuite) TestContainerAPITopWindows(c *check.C) {
400
+	testRequires(c, DaemonIsWindows)
401
+	out, _ := runSleepingContainer(c, "-d")
402
+	id := strings.TrimSpace(string(out))
403
+	c.Assert(waitRun(id), checker.IsNil)
404
+
405
+	type topResp struct {
406
+		Titles    []string
407
+		Processes [][]string
408
+	}
409
+	var top topResp
410
+	status, b, err := sockRequest("GET", "/containers/"+id+"/top", nil)
411
+	c.Assert(err, checker.IsNil)
412
+	c.Assert(status, checker.Equals, http.StatusOK)
413
+	c.Assert(json.Unmarshal(b, &top), checker.IsNil)
414
+	c.Assert(top.Titles, checker.HasLen, 4, check.Commentf("expected 4 titles, found %d: %v", len(top.Titles), top.Titles))
415
+
416
+	if top.Titles[0] != "Name" || top.Titles[3] != "Private Working Set" {
417
+		c.Fatalf("expected `Name` at `Titles[0]` and `Private Working Set` at Titles[3]: %v", top.Titles)
418
+	}
419
+	c.Assert(len(top.Processes), checker.GreaterOrEqualThan, 2, check.Commentf("expected at least 2 processes, found %d: %v", len(top.Processes), top.Processes))
420
+
421
+	foundProcess := false
422
+	expectedProcess := "busybox.exe"
423
+	for _, process := range top.Processes {
424
+		if process[0] == expectedProcess {
425
+			foundProcess = true
426
+			break
427
+		}
428
+	}
429
+
430
+	c.Assert(foundProcess, checker.Equals, true, check.Commentf("expected to find %s: %v", expectedProcess, top.Processes))
431
+}
432
+
399 433
 func (s *DockerSuite) TestContainerAPICommit(c *check.C) {
400 434
 	cName := "testapicommit"
401 435
 	dockerCmd(c, "run", "--name="+cName, "busybox", "/bin/sh", "-c", "touch /test")
... ...
@@ -848,29 +881,25 @@ func (s *DockerSuite) TestContainerAPIKill(c *check.C) {
848 848
 }
849 849
 
850 850
 func (s *DockerSuite) TestContainerAPIRestart(c *check.C) {
851
-	// TODO Windows to Windows CI. This is flaky due to the timing
852
-	testRequires(c, DaemonIsLinux)
853 851
 	name := "test-api-restart"
854
-	dockerCmd(c, "run", "-di", "--name", name, "busybox", "top")
852
+	runSleepingContainer(c, "-di", "--name", name)
855 853
 
856 854
 	status, _, err := sockRequest("POST", "/containers/"+name+"/restart?t=1", nil)
857 855
 	c.Assert(err, checker.IsNil)
858 856
 	c.Assert(status, checker.Equals, http.StatusNoContent)
859
-	c.Assert(waitInspect(name, "{{ .State.Restarting  }} {{ .State.Running  }}", "false true", 5*time.Second), checker.IsNil)
857
+	c.Assert(waitInspect(name, "{{ .State.Restarting  }} {{ .State.Running  }}", "false true", 15*time.Second), checker.IsNil)
860 858
 }
861 859
 
862 860
 func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *check.C) {
863
-	// TODO Windows to Windows CI. This is flaky due to the timing
864
-	testRequires(c, DaemonIsLinux)
865 861
 	name := "test-api-restart-no-timeout-param"
866
-	out, _ := dockerCmd(c, "run", "-di", "--name", name, "busybox", "top")
862
+	out, _ := runSleepingContainer(c, "-di", "--name", name)
867 863
 	id := strings.TrimSpace(out)
868 864
 	c.Assert(waitRun(id), checker.IsNil)
869 865
 
870 866
 	status, _, err := sockRequest("POST", "/containers/"+name+"/restart", nil)
871 867
 	c.Assert(err, checker.IsNil)
872 868
 	c.Assert(status, checker.Equals, http.StatusNoContent)
873
-	c.Assert(waitInspect(name, "{{ .State.Restarting  }} {{ .State.Running  }}", "false true", 5*time.Second), checker.IsNil)
869
+	c.Assert(waitInspect(name, "{{ .State.Restarting  }} {{ .State.Running  }}", "false true", 15*time.Second), checker.IsNil)
874 870
 }
875 871
 
876 872
 func (s *DockerSuite) TestContainerAPIStart(c *check.C) {
... ...
@@ -5143,7 +5143,6 @@ func (s *DockerSuite) TestBuildSpaces(c *check.C) {
5143 5143
 }
5144 5144
 
5145 5145
 func (s *DockerSuite) TestBuildSpacesWithQuotes(c *check.C) {
5146
-	testRequires(c, DaemonIsLinux)
5147 5146
 	// Test to make sure that spaces in quotes aren't lost
5148 5147
 	name := "testspacesquotes"
5149 5148
 
... ...
@@ -5157,6 +5156,10 @@ RUN echo "  \
5157 5157
 	}
5158 5158
 
5159 5159
 	expecting := "\n    foo  \n"
5160
+	// Windows uses the builtin echo, which preserves quotes
5161
+	if daemonPlatform == "windows" {
5162
+		expecting = "\"    foo  \""
5163
+	}
5160 5164
 	if !strings.Contains(out, expecting) {
5161 5165
 		c.Fatalf("Bad output: %q expecting to contain %q", out, expecting)
5162 5166
 	}
... ...
@@ -6252,7 +6255,6 @@ func (s *DockerSuite) TestBuildFollowSymlinkToDir(c *check.C) {
6252 6252
 // TestBuildSymlinkBasename tests that target file gets basename from symlink,
6253 6253
 // not from the target file.
6254 6254
 func (s *DockerSuite) TestBuildSymlinkBasename(c *check.C) {
6255
-	testRequires(c, DaemonIsLinux)
6256 6255
 	name := "testbuildbrokensymlink"
6257 6256
 	ctx, err := fakeContext(`
6258 6257
 	FROM busybox