Browse code

Merge pull request #27037 from Microsoft/jjh/apistatsdatarace

Fix datarace in ApiStatsNetworkStatsVersioning

Alexander Morozov authored on 2016/10/06 05:06:40
Showing 1 changed files
... ...
@@ -169,9 +169,15 @@ func (s *DockerSuite) TestAPIStatsNetworkStatsVersioning(c *check.C) {
169 169
 	c.Assert(waitRun(id), checker.IsNil)
170 170
 	wg := sync.WaitGroup{}
171 171
 
172
-	for i := 17; i <= 21; i++ {
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 179
 		wg.Add(1)
174
-		go func() {
180
+		go func(i int) {
175 181
 			defer wg.Done()
176 182
 			apiVersion := fmt.Sprintf("v1.%d", i)
177 183
 			statsJSONBlob := getVersionedStats(c, id, apiVersion)
... ...
@@ -182,7 +188,7 @@ func (s *DockerSuite) TestAPIStatsNetworkStatsVersioning(c *check.C) {
182 182
 				c.Assert(jsonBlobHasGTE121NetworkStats(statsJSONBlob), checker.Equals, true,
183 183
 					check.Commentf("Stats JSON blob from API %s %#v does not look like a >=v1.21 API stats structure", apiVersion, statsJSONBlob))
184 184
 			}
185
-		}()
185
+		}(i)
186 186
 	}
187 187
 	wg.Wait()
188 188
 }