Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions integration/copy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,43 @@ func (s *CopySuite) TestCopySimple(c *check.C) {
c.Assert(err, check.IsNil)
}

// Make sure that docker-archive is identical to docker.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really describing the test… what would “a local file being identical to a remote repository” (or is it “to a daemon”) mean? And docker does nothing with OCI…

I guess, a test is a test is a test, and it is useful even if not explained, but knowing what is being tested could make it easier in the future to figure out whether a failure is a bug in the test or in the software being tested.

func (s *CopySuite) TestCopyArchive(c *check.C) {
ar1, err := ioutil.TempDir("", "ar-1")
c.Assert(err, check.IsNil)
defer os.RemoveAll(ar1)
ar2, err := ioutil.TempDir("", "ar-2")
c.Assert(err, check.IsNil)
defer os.RemoveAll(ar2)
dir1, err := ioutil.TempDir("", "copy-1")
c.Assert(err, check.IsNil)
defer os.RemoveAll(dir1)
dir2, err := ioutil.TempDir("", "copy-2")
c.Assert(err, check.IsNil)
defer os.RemoveAll(dir2)

// FIXME: It would be nice to use one of the local Docker registries instead of neeeding an Internet connection.
// "pull": docker: → docker-archive:
assertSkopeoSucceeds(c, "", "copy", "docker://busybox", "docker-archive:"+ar1+"/archive.tar:busybox")
// "copy": docker-archive: → dir:
assertSkopeoSucceeds(c, "", "copy", "docker-archive:"+ar1+"/archive.tar", "dir:"+dir1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it essential that this uncompressess the layers (per #279 and containers/image#193 ), or does it not matter here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does matter for the test below. However, since the original idea behind containers/image#193 was NACK'd, the current system will have the blobs decompressed in the docker-archive: case but I don't think it'll happen in the docker:// case.

But first lets get the other stuff merged and we can figure out how to make a nice integration test once the code works.

// "pull": docker: → dir:
assertSkopeoSucceeds(c, "", "copy", "docker://busybox", "dir:"+dir2)
out := combinedOutputOfCommand(c, "diff", "-urN", dir1, dir2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, layers should match (either uncompressed or unmodified); but why should we expect the manifest, which has been thrown away in the copy to docker-archive:ar1, and generated from scratch in the copy from it, to match (and keep matching) byte-for-byte the manifest stored in the remote docker://busybox repo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll split this test to look like #306, where we have a test that checks something that must be invariant but also an extra test that checks the things-that-should-be-the-same, with a comment explaining the situation.

c.Assert(out, check.Equals, "")

// docker-archive -> OCI image layout
ociDest := "busybox-latest"
defer os.RemoveAll(ociDest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this one not a TempDir as above? (Perhaps check how TestCopyDirSignature does this, with so many directories.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be a TempDir.

assertSkopeoSucceeds(c, "", "copy", "docker-archive:"+ar1+"/archive.tar", "oci:"+ociDest)
_, err = os.Stat(ociDest)
c.Assert(err, check.IsNil)

// OCI image layout -> docker-archive
assertSkopeoSucceeds(c, "", "copy", "oci:"+ociDest, "docker-archive:"+ar2+"/archive.tar")
c.Assert(err, check.IsNil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these two copies intended to be just a minimal smoke test, or is there a more specific kind of failure this is testing for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were a variety of failures that would happen if you tried to test going from OCI to Docker, back to OCI then back to Docker. This is a smoke test to ensure that at the very least we don't have asymmetric issues with one side of the conversion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, the most recent series of issues we've seen would've been caught by this smoke test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, I will add some extra round-trip style tests (like #306) once the two important PRs are merged. I'm not going to waste time writing lots of detailed tests until we all agree on the implementations (especially semantics like compression, which massively change what invariants we can test).

}

// Streaming (skopeo copy)
func (s *CopySuite) TestCopyStreaming(c *check.C) {
dir1, err := ioutil.TempDir("", "streaming-1")
Expand Down