This test checks to make sure both v1.12 and v1.13 client against v1.13 daemon get correct `Size` after the fix.
This test is related to 30027.
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
| ... | ... |
@@ -128,3 +128,39 @@ func (s *DockerSuite) TestAPIImagesSearchJSONContentType(c *check.C) {
|
| 128 | 128 |
c.Assert(res.StatusCode, checker.Equals, http.StatusOK) |
| 129 | 129 |
c.Assert(res.Header.Get("Content-Type"), checker.Equals, "application/json")
|
| 130 | 130 |
} |
| 131 |
+ |
|
| 132 |
+// Test case for 30027: image size reported as -1 in v1.12 client against v1.13 daemon. |
|
| 133 |
+// This test checks to make sure both v1.12 and v1.13 client against v1.13 daemon get correct `Size` after the fix. |
|
| 134 |
+func (s *DockerSuite) TestAPIImagesSizeCompatibility(c *check.C) {
|
|
| 135 |
+ status, b, err := request.SockRequest("GET", "/images/json", nil, daemonHost())
|
|
| 136 |
+ c.Assert(err, checker.IsNil) |
|
| 137 |
+ c.Assert(status, checker.Equals, http.StatusOK) |
|
| 138 |
+ var images []types.ImageSummary |
|
| 139 |
+ err = json.Unmarshal(b, &images) |
|
| 140 |
+ c.Assert(err, checker.IsNil) |
|
| 141 |
+ c.Assert(len(images), checker.Not(checker.Equals), 0) |
|
| 142 |
+ for _, image := range images {
|
|
| 143 |
+ c.Assert(image.Size, checker.Not(checker.Equals), int64(-1)) |
|
| 144 |
+ } |
|
| 145 |
+ |
|
| 146 |
+ type v124Image struct {
|
|
| 147 |
+ ID string `json:"Id"` |
|
| 148 |
+ ParentID string `json:"ParentId"` |
|
| 149 |
+ RepoTags []string |
|
| 150 |
+ RepoDigests []string |
|
| 151 |
+ Created int64 |
|
| 152 |
+ Size int64 |
|
| 153 |
+ VirtualSize int64 |
|
| 154 |
+ Labels map[string]string |
|
| 155 |
+ } |
|
| 156 |
+ status, b, err = request.SockRequest("GET", "/v1.24/images/json", nil, daemonHost())
|
|
| 157 |
+ c.Assert(err, checker.IsNil) |
|
| 158 |
+ c.Assert(status, checker.Equals, http.StatusOK) |
|
| 159 |
+ var v124Images []v124Image |
|
| 160 |
+ err = json.Unmarshal(b, &v124Images) |
|
| 161 |
+ c.Assert(err, checker.IsNil) |
|
| 162 |
+ c.Assert(len(v124Images), checker.Not(checker.Equals), 0) |
|
| 163 |
+ for _, image := range v124Images {
|
|
| 164 |
+ c.Assert(image.Size, checker.Not(checker.Equals), int64(-1)) |
|
| 165 |
+ } |
|
| 166 |
+} |