diff --git a/integration/copy_test.go b/integration/copy_test.go index 39235560..fcaa336b 100644 --- a/integration/copy_test.go +++ b/integration/copy_test.go @@ -186,6 +186,46 @@ func (s *CopySuite) TestCopyStreaming(c *check.C) { // FIXME: Also check pushing to docker:// } +// OCI round-trip testing. It's very important to make sure that OCI <-> Docker +// conversion works (while skopeo handles many things, one of the most obvious +// benefits of a tool like skopeo is that you can use OCI tooling to create an +// image and then as the final step convert the image to a non-standard format +// like Docker). But this only works if we _test_ it. +func (s *CopySuite) TestCopyOCIRoundTrip(c *check.C) { + const ourRegistry = "docker://" + v2DockerRegistryURL + "/" + + oci1, err := ioutil.TempDir("", "oci-1") + c.Assert(err, check.IsNil) + defer os.RemoveAll(oci1) + oci2, err := ioutil.TempDir("", "oci-2") + c.Assert(err, check.IsNil) + defer os.RemoveAll(oci2) + + // Docker -> OCI + assertSkopeoSucceeds(c, "", "--tls-verify=false", "--debug", "copy", "docker://busybox", "oci:"+oci1+":latest") + // OCI -> Docker + assertSkopeoSucceeds(c, "", "--tls-verify=false", "--debug", "copy", "oci:"+oci1+":latest", ourRegistry+"original/busybox:oci_copy") + // Docker -> OCI + assertSkopeoSucceeds(c, "", "--tls-verify=false", "--debug", "copy", ourRegistry+"original/busybox:oci_copy", "oci:"+oci2+":latest") + // OCI -> Docker + assertSkopeoSucceeds(c, "", "--tls-verify=false", "--debug", "copy", "oci:"+oci2+":latest", ourRegistry+"original/busybox:oci_copy2") + + // TODO: Add some more tags to output to and check those work properly. + + // First, make sure the OCI blobs are the same. This should _always_ be true. + out := combinedOutputOfCommand(c, "diff", "-urN", oci1+"/blobs", oci2+"/blobs") + c.Assert(out, check.Equals, "") + + // TODO: Verify using the upstream OCI image validator. + + // Now verify that everything is identical. Currently this is true, but + // because we recompute the manifests on-the-fly this doesn't necessarily + // always have to be true (but if this breaks in the future __PLEASE__ make + // sure that the breakage actually makes sense before removing this check). + out = combinedOutputOfCommand(c, "diff", "-urN", oci1, oci2) + c.Assert(out, check.Equals, "") +} + // --sign-by and --policy copy, primarily using atomic: func (s *CopySuite) TestCopySignatures(c *check.C) { dir, err := ioutil.TempDir("", "signatures-dest")