Browse code

Windows: Require REST 1.25 or later

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

John Howard authored on 2016/11/01 02:15:43
Showing 10 changed files
... ...
@@ -23,9 +23,6 @@ const (
23 23
 	// DefaultVersion of Current REST API
24 24
 	DefaultVersion string = "1.25"
25 25
 
26
-	// MinVersion represents Minimum REST API version supported
27
-	MinVersion string = "1.12"
28
-
29 26
 	// NoBaseImageSpecifier is the symbol used by the FROM
30 27
 	// command to specify that no base image is to be used.
31 28
 	NoBaseImageSpecifier string = "scratch"
32 29
new file mode 100644
... ...
@@ -0,0 +1,6 @@
0
+// +build !windows
1
+
2
+package api
3
+
4
+// MinVersion represents Minimum REST API version supported
5
+const MinVersion string = "1.12"
0 6
new file mode 100644
... ...
@@ -0,0 +1,4 @@
0
+package api
1
+
2
+// MinVersion represents Minimum REST API version supported
3
+const MinVersion string = "1.25"
... ...
@@ -976,7 +976,7 @@ func (s *DockerSuite) TestContainerAPICopyNotExistsAnyMore(c *check.C) {
976 976
 }
977 977
 
978 978
 func (s *DockerSuite) TestContainerAPICopyPre124(c *check.C) {
979
-
979
+	testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
980 980
 	name := "test-container-api-copy"
981 981
 	dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt")
982 982
 
... ...
@@ -1006,6 +1006,7 @@ func (s *DockerSuite) TestContainerAPICopyPre124(c *check.C) {
1006 1006
 }
1007 1007
 
1008 1008
 func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPr124(c *check.C) {
1009
+	testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
1009 1010
 	name := "test-container-api-copy-resource-empty"
1010 1011
 	dockerCmd(c, "run", "--name", name, "busybox", "touch", "/test.txt")
1011 1012
 
... ...
@@ -1020,6 +1021,7 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathEmptyPr124(c *check.C) {
1020 1020
 }
1021 1021
 
1022 1022
 func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *check.C) {
1023
+	testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
1023 1024
 	name := "test-container-api-copy-resource-not-found"
1024 1025
 	dockerCmd(c, "run", "--name", name, "busybox")
1025 1026
 
... ...
@@ -1034,6 +1036,7 @@ func (s *DockerSuite) TestContainerAPICopyResourcePathNotFoundPre124(c *check.C)
1034 1034
 }
1035 1035
 
1036 1036
 func (s *DockerSuite) TestContainerAPICopyContainerNotFoundPr124(c *check.C) {
1037
+	testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
1037 1038
 	postData := types.CopyConfig{
1038 1039
 		Resource: "/something",
1039 1040
 	}
... ...
@@ -1245,6 +1248,7 @@ func (s *DockerSuite) TestPostContainersCreateWithStringOrSliceCapAddDrop(c *che
1245 1245
 
1246 1246
 // #14915
1247 1247
 func (s *DockerSuite) TestContainerAPICreateNoHostConfig118(c *check.C) {
1248
+	testRequires(c, DaemonIsLinux) // Windows only support 1.25 or later
1248 1249
 	config := struct {
1249 1250
 		Image string
1250 1251
 	}{"busybox"}
... ...
@@ -90,6 +90,7 @@ func (s *DockerSuite) TestExecAPIStart(c *check.C) {
90 90
 }
91 91
 
92 92
 func (s *DockerSuite) TestExecAPIStartBackwardsCompatible(c *check.C) {
93
+	testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
93 94
 	runSleepingContainer(c, "-d", "--name", "test")
94 95
 	id := createExec(c, "test")
95 96
 
... ...
@@ -40,6 +40,7 @@ func (s *DockerSuite) TestInfoAPI(c *check.C) {
40 40
 }
41 41
 
42 42
 func (s *DockerSuite) TestInfoAPIVersioned(c *check.C) {
43
+	testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
43 44
 	endpoint := "/v1.20/info"
44 45
 
45 46
 	status, body, err := sockRequest("GET", endpoint, nil)
... ...
@@ -28,7 +28,7 @@ func (s *DockerSuite) TestInspectAPIContainerResponse(c *check.C) {
28 28
 
29 29
 	if daemonPlatform == "windows" {
30 30
 		cases = []acase{
31
-			{"v1.20", append(keysBase, "Mounts")},
31
+			{"v1.25", append(keysBase, "Mounts")},
32 32
 		}
33 33
 
34 34
 	} else {
... ...
@@ -84,23 +84,23 @@ func (s *DockerSuite) TestInspectAPIContainerVolumeDriver(c *check.C) {
84 84
 
85 85
 	cleanedContainerID := strings.TrimSpace(out)
86 86
 
87
-	body := getInspectBody(c, "v1.21", cleanedContainerID)
87
+	body := getInspectBody(c, "v1.25", cleanedContainerID)
88 88
 
89 89
 	var inspectJSON map[string]interface{}
90 90
 	err := json.Unmarshal(body, &inspectJSON)
91
-	c.Assert(err, checker.IsNil, check.Commentf("Unable to unmarshal body for version 1.21"))
91
+	c.Assert(err, checker.IsNil, check.Commentf("Unable to unmarshal body for version 1.25"))
92 92
 
93 93
 	config, ok := inspectJSON["Config"]
94 94
 	c.Assert(ok, checker.True, check.Commentf("Unable to find 'Config'"))
95 95
 	cfg := config.(map[string]interface{})
96 96
 	_, ok = cfg["VolumeDriver"]
97
-	c.Assert(ok, checker.False, check.Commentf("API version 1.21 expected to not include VolumeDriver in 'Config'"))
97
+	c.Assert(ok, checker.False, check.Commentf("API version 1.25 expected to not include VolumeDriver in 'Config'"))
98 98
 
99 99
 	config, ok = inspectJSON["HostConfig"]
100 100
 	c.Assert(ok, checker.True, check.Commentf("Unable to find 'HostConfig'"))
101 101
 	cfg = config.(map[string]interface{})
102 102
 	_, ok = cfg["VolumeDriver"]
103
-	c.Assert(ok, checker.True, check.Commentf("API version 1.21 expected to include VolumeDriver in 'HostConfig'"))
103
+	c.Assert(ok, checker.True, check.Commentf("API version 1.25 expected to include VolumeDriver in 'HostConfig'"))
104 104
 }
105 105
 
106 106
 func (s *DockerSuite) TestInspectAPIImageResponse(c *check.C) {
... ...
@@ -162,20 +162,15 @@ func (s *DockerSuite) TestAPIStatsNetworkStats(c *check.C) {
162 162
 }
163 163
 
164 164
 func (s *DockerSuite) TestAPIStatsNetworkStatsVersioning(c *check.C) {
165
-	testRequires(c, SameHostDaemon)
165
+	// Windows doesn't support API versions less than 1.25, so no point testing 1.17 .. 1.21
166
+	testRequires(c, SameHostDaemon, DaemonIsLinux)
166 167
 
167 168
 	out, _ := runSleepingContainer(c)
168 169
 	id := strings.TrimSpace(out)
169 170
 	c.Assert(waitRun(id), checker.IsNil)
170 171
 	wg := sync.WaitGroup{}
171 172
 
172
-	// Windows API versions prior to 1.21 doesn't support stats.
173
-	startAt := 17
174
-	if daemonPlatform == "windows" {
175
-		startAt = 21
176
-	}
177
-
178
-	for i := startAt; i <= 21; i++ {
173
+	for i := 17; i <= 21; i++ {
179 174
 		wg.Add(1)
180 175
 		go func(i int) {
181 176
 			defer wg.Done()
... ...
@@ -75,7 +75,7 @@ func (s *DockerSuite) TestAPIClientVersionOldNotSupported(c *check.C) {
75 75
 	c.Assert(err, checker.IsNil)
76 76
 	c.Assert(status, checker.Equals, http.StatusBadRequest)
77 77
 	expected := fmt.Sprintf("client version %s is too old. Minimum supported API version is %s, please upgrade your client to a newer version", version, api.MinVersion)
78
-	c.Assert(strings.TrimSpace(string(body)), checker.Equals, expected)
78
+	c.Assert(strings.TrimSpace(string(body)), checker.Contains, expected)
79 79
 }
80 80
 
81 81
 func (s *DockerSuite) TestAPIDockerAPIVersion(c *check.C) {
... ...
@@ -108,6 +108,9 @@ func (s *DockerSuite) TestAPIErrorJSON(c *check.C) {
108 108
 }
109 109
 
110 110
 func (s *DockerSuite) TestAPIErrorPlainText(c *check.C) {
111
+	// Windows requires API 1.25 or later. This test is validating a behaviour which was present
112
+	// in v1.23, but changed in 1.24, hence not applicable on Windows. See apiVersionSupportsJSONErrors
113
+	testRequires(c, DaemonIsLinux)
111 114
 	httpResp, body, err := sockRequestRaw("POST", "/v1.23/containers/create", strings.NewReader(`{}`), "application/json")
112 115
 	c.Assert(err, checker.IsNil)
113 116
 	c.Assert(httpResp.StatusCode, checker.Equals, http.StatusInternalServerError)
... ...
@@ -116,6 +116,7 @@ func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) {
116 116
 }
117 117
 
118 118
 func (s *DockerSuite) TestKillStoppedContainerAPIPre120(c *check.C) {
119
+	testRequires(c, DaemonIsLinux) // Windows only supports 1.25 or later
119 120
 	runSleepingContainer(c, "--name", "docker-kill-test-api", "-d")
120 121
 	dockerCmd(c, "stop", "docker-kill-test-api")
121 122