From 4ec3b64c84411aaceb2dee9fe4c1fd073867f566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Mon, 19 Sep 2016 21:36:00 +0200 Subject: [PATCH] Add an integration tests for compression during upload Sadly, most of the cases are disabled for now; hopefully this will get fixed soon. --- integration/copy_test.go | 55 +++++++++++++++++- ...e55424f8f5eb6b679c865eec6e59adfe304710.tar | Bin 0 -> 2048 bytes .../uncompressed-image-s1/manifest.json | 32 ++++++++++ ...e55424f8f5eb6b679c865eec6e59adfe304710.tar | Bin 0 -> 2048 bytes ...9d18b7c6832596916e7f654e08377b5a67b4ff.tar | 1 + .../uncompressed-image-s2/manifest.json | 16 +++++ 6 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 integration/fixtures/uncompressed-image-s1/160d823fdc48e62f97ba62df31e55424f8f5eb6b679c865eec6e59adfe304710.tar create mode 100644 integration/fixtures/uncompressed-image-s1/manifest.json create mode 100644 integration/fixtures/uncompressed-image-s2/160d823fdc48e62f97ba62df31e55424f8f5eb6b679c865eec6e59adfe304710.tar create mode 100644 integration/fixtures/uncompressed-image-s2/86ce150e65c72b30f885c261449d18b7c6832596916e7f654e08377b5a67b4ff.tar create mode 100644 integration/fixtures/uncompressed-image-s2/manifest.json diff --git a/integration/copy_test.go b/integration/copy_test.go index f7e337e1..9100543c 100644 --- a/integration/copy_test.go +++ b/integration/copy_test.go @@ -15,9 +15,12 @@ func init() { check.Suite(&CopySuite{}) } +const v2DockerRegistryURL = "localhost:5555" + type CopySuite struct { - cluster *openshiftCluster - gpgHome string + cluster *openshiftCluster + registry *testRegistryV2 + gpgHome string } func (s *CopySuite) SetUpSuite(c *check.C) { @@ -27,7 +30,7 @@ func (s *CopySuite) SetUpSuite(c *check.C) { s.cluster = startOpenshiftCluster(c) // FIXME: Set up TLS for the docker registry port instead of using "--tls-verify=false" all over the place. - for _, stream := range []string{"unsigned", "personal", "official", "naming", "cosigned"} { + for _, stream := range []string{"unsigned", "personal", "official", "naming", "cosigned", "compression"} { isJSON := fmt.Sprintf(`{ "kind": "ImageStream", "apiVersion": "v1", @@ -39,6 +42,8 @@ func (s *CopySuite) SetUpSuite(c *check.C) { runCommandWithInput(c, isJSON, "oc", "create", "-f", "-") } + s.registry = setupRegistryV2At(c, v2DockerRegistryURL, false, false) // FIXME: Set up TLS for the docker registry port instead of using "--tls-verify=false" all over the place. + gpgHome, err := ioutil.TempDir("", "skopeo-gpg") c.Assert(err, check.IsNil) s.gpgHome = gpgHome @@ -60,6 +65,9 @@ func (s *CopySuite) TearDownSuite(c *check.C) { if s.gpgHome != "" { os.RemoveAll(s.gpgHome) } + if s.registry != nil { + s.registry.Close() + } if s.cluster != nil { s.cluster.tearDown() } @@ -242,3 +250,44 @@ func (s *CopySuite) TestCopyDirSignatures(c *check.C) { assertSkopeoFails(c, ".*Source image rejected: .*Signature for identity localhost:5000/myns/personal:dirstaging2 is not accepted.*", "--policy", policy, "copy", topDirDest+"/restricted/badidentity", topDirDest+"/dest") } + +// Compression during copy +func (s *CopySuite) TestCopyCompression(c *check.C) { + const uncompresssedLayerFile = "160d823fdc48e62f97ba62df31e55424f8f5eb6b679c865eec6e59adfe304710.tar" + + topDir, err := ioutil.TempDir("", "compression-top") + c.Assert(err, check.IsNil) + defer os.RemoveAll(topDir) + + for i, t := range []struct{ fixture, remote string }{ + //{"uncompressed-image-s1", "docker://" + v2DockerRegistryURL + "/compression/compression:s1"}, // FIXME: depends on push to tag working + //{"uncompressed-image-s2", "docker://" + v2DockerRegistryURL + "/compression/compression:s2"}, // FIXME: depends on push to tag working + {"uncompressed-image-s1", "atomic:localhost:5000/myns/compression:s1"}, + //{"uncompressed-image-s2", "atomic:localhost:5000/myns/compression:s2"}, // FIXME: The unresolved "MANIFEST_UNKNOWN"/"unexpected end of JSON input" failure + } { + dir := filepath.Join(topDir, fmt.Sprintf("case%d", i)) + err := os.MkdirAll(dir, 0755) + c.Assert(err, check.IsNil) + + assertSkopeoSucceeds(c, "", "--tls-verify=false", "copy", "dir:fixtures/"+t.fixture, t.remote) + assertSkopeoSucceeds(c, "", "--tls-verify=false", "copy", t.remote, "dir:"+dir) + + // The original directory contained an uncompressed file, the copy after pushing and pulling doesn't (we use a different name for the compressed file). + _, err = os.Lstat(filepath.Join("fixtures", t.fixture, uncompresssedLayerFile)) + c.Assert(err, check.IsNil) + _, err = os.Lstat(filepath.Join(dir, uncompresssedLayerFile)) + c.Assert(err, check.NotNil) + c.Assert(os.IsNotExist(err), check.Equals, true) + + // All pulled layers are smaller than the uncompressed size of uncompresssedLayerFile. (Note that this includes the manifest in s2, but that works out OK). + dirf, err := os.Open(dir) + c.Assert(err, check.IsNil) + fis, err := dirf.Readdir(-1) + c.Assert(err, check.IsNil) + for _, fi := range fis { + if strings.HasSuffix(fi.Name(), ".tar") { + c.Assert(fi.Size() < 2048, check.Equals, true) + } + } + } +} diff --git a/integration/fixtures/uncompressed-image-s1/160d823fdc48e62f97ba62df31e55424f8f5eb6b679c865eec6e59adfe304710.tar b/integration/fixtures/uncompressed-image-s1/160d823fdc48e62f97ba62df31e55424f8f5eb6b679c865eec6e59adfe304710.tar new file mode 100644 index 0000000000000000000000000000000000000000..58342e8d8796a3a0dfd3191e2d63f8c62ed7cc03 GIT binary patch literal 2048 zcmc~SE-p=Fpe-;kG%zqTF<~%(0Cd{Gz}SSr(8%1}z`zKo%!~o3-q^^LLBW8w&Vra; zT3nJ?1auOmcA