Rewrite TestSaveMultipleNames and TestSaveSingleTag so that they don't
use legacy `repositories` file (which isn't present in the OCI
archives).
`docker save` output is now OCI compatible, so we don't need
to use the legacy file.
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
|
| 12 | 12 |
"github.com/docker/docker/integration-cli/cli/build" |
| 13 | 13 |
"gotest.tools/v3/assert" |
| 14 |
+ is "gotest.tools/v3/assert/cmp" |
|
| 14 | 15 |
"gotest.tools/v3/icmd" |
| 15 | 16 |
) |
| 16 | 17 |
|
| ... | ... |
@@ -93,11 +94,15 @@ func (s *DockerCLISaveLoadSuite) TestSaveSingleTag(c *testing.T) {
|
| 93 | 93 |
out, _ := dockerCmd(c, "images", "-q", "--no-trunc", repoName) |
| 94 | 94 |
cleanedImageID := strings.TrimSpace(out) |
| 95 | 95 |
|
| 96 |
+ filesFilter := fmt.Sprintf("(^manifest.json$|%v)", cleanedImageID)
|
|
| 97 |
+ if testEnv.UsingSnapshotter() {
|
|
| 98 |
+ filesFilter = fmt.Sprintf("(^index.json$|^manifest.json$|%v)", cleanedImageID)
|
|
| 99 |
+ } |
|
| 96 | 100 |
out, err := RunCommandPipelineWithOutput( |
| 97 | 101 |
exec.Command(dockerBinary, "save", fmt.Sprintf("%v:latest", repoName)),
|
| 98 | 102 |
exec.Command("tar", "t"),
|
| 99 |
- exec.Command("grep", "-E", fmt.Sprintf("(^repositories$|%v)", cleanedImageID)))
|
|
| 100 |
- assert.NilError(c, err, "failed to save repo with image ID and 'repositories' file: %s, %v", out, err) |
|
| 103 |
+ exec.Command("grep", "-E", filesFilter))
|
|
| 104 |
+ assert.NilError(c, err, "failed to save repo with image ID and index files: %s, %v", out, err) |
|
| 101 | 105 |
} |
| 102 | 106 |
|
| 103 | 107 |
func (s *DockerCLISaveLoadSuite) TestSaveImageId(c *testing.T) {
|
| ... | ... |
@@ -174,18 +179,20 @@ func (s *DockerCLISaveLoadSuite) TestSaveMultipleNames(c *testing.T) {
|
| 174 | 174 |
testRequires(c, DaemonIsLinux) |
| 175 | 175 |
repoName := "foobar-save-multi-name-test" |
| 176 | 176 |
|
| 177 |
- // Make one image |
|
| 178 |
- dockerCmd(c, "tag", "emptyfs:latest", fmt.Sprintf("%v-one:latest", repoName))
|
|
| 177 |
+ oneTag := fmt.Sprintf("%v-one:latest", repoName)
|
|
| 178 |
+ twoTag := fmt.Sprintf("%v-two:latest", repoName)
|
|
| 179 | 179 |
|
| 180 |
- // Make two images |
|
| 181 |
- dockerCmd(c, "tag", "emptyfs:latest", fmt.Sprintf("%v-two:latest", repoName))
|
|
| 180 |
+ dockerCmd(c, "tag", "emptyfs:latest", oneTag) |
|
| 181 |
+ dockerCmd(c, "tag", "emptyfs:latest", twoTag) |
|
| 182 | 182 |
|
| 183 | 183 |
out, err := RunCommandPipelineWithOutput( |
| 184 |
- exec.Command(dockerBinary, "save", fmt.Sprintf("%v-one", repoName), fmt.Sprintf("%v-two:latest", repoName)),
|
|
| 185 |
- exec.Command("tar", "xO", "repositories"),
|
|
| 186 |
- exec.Command("grep", "-q", "-E", "(-one|-two)"),
|
|
| 184 |
+ exec.Command(dockerBinary, "save", strings.TrimSuffix(oneTag, ":latest"), twoTag), |
|
| 185 |
+ exec.Command("tar", "xO", "index.json"),
|
|
| 187 | 186 |
) |
| 188 | 187 |
assert.NilError(c, err, "failed to save multiple repos: %s, %v", out, err) |
| 188 |
+ |
|
| 189 |
+ assert.Check(c, is.Contains(out, oneTag)) |
|
| 190 |
+ assert.Check(c, is.Contains(out, twoTag)) |
|
| 189 | 191 |
} |
| 190 | 192 |
|
| 191 | 193 |
// Test loading a weird image where one of the layers is of zero size. |