github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/test/e2e/pull_test.go (about) 1 // +build !remoteclient 2 3 package integration 4 5 import ( 6 "os" 7 8 "fmt" 9 "path/filepath" 10 "strings" 11 12 . "github.com/containers/libpod/test/utils" 13 . "github.com/onsi/ginkgo" 14 . "github.com/onsi/gomega" 15 ) 16 17 var _ = Describe("Podman pull", func() { 18 var ( 19 tempdir string 20 err error 21 podmanTest *PodmanTestIntegration 22 ) 23 24 BeforeEach(func() { 25 tempdir, err = CreateTempDirInTempDir() 26 if err != nil { 27 os.Exit(1) 28 } 29 podmanTest = PodmanTestCreate(tempdir) 30 podmanTest.Setup() 31 }) 32 33 AfterEach(func() { 34 podmanTest.Cleanup() 35 f := CurrentGinkgoTestDescription() 36 processTestResult(f) 37 38 }) 39 40 It("podman pull from docker a not existing image", func() { 41 session := podmanTest.PodmanNoCache([]string{"pull", "ibetthisdoesntexistthere:foo"}) 42 session.WaitWithDefaultTimeout() 43 Expect(session).To(ExitWithError()) 44 }) 45 46 It("podman pull from docker with tag", func() { 47 session := podmanTest.PodmanNoCache([]string{"pull", "busybox:glibc"}) 48 session.WaitWithDefaultTimeout() 49 Expect(session.ExitCode()).To(Equal(0)) 50 51 session = podmanTest.PodmanNoCache([]string{"rmi", "busybox:glibc"}) 52 session.WaitWithDefaultTimeout() 53 Expect(session.ExitCode()).To(Equal(0)) 54 }) 55 56 It("podman pull from docker without tag", func() { 57 session := podmanTest.PodmanNoCache([]string{"pull", "busybox"}) 58 session.WaitWithDefaultTimeout() 59 Expect(session.ExitCode()).To(Equal(0)) 60 61 session = podmanTest.PodmanNoCache([]string{"rmi", "busybox"}) 62 session.WaitWithDefaultTimeout() 63 Expect(session.ExitCode()).To(Equal(0)) 64 }) 65 66 It("podman pull from alternate registry with tag", func() { 67 session := podmanTest.PodmanNoCache([]string{"pull", nginx}) 68 session.WaitWithDefaultTimeout() 69 Expect(session.ExitCode()).To(Equal(0)) 70 71 session = podmanTest.PodmanNoCache([]string{"rmi", nginx}) 72 session.WaitWithDefaultTimeout() 73 Expect(session.ExitCode()).To(Equal(0)) 74 }) 75 76 It("podman pull from alternate registry without tag", func() { 77 session := podmanTest.PodmanNoCache([]string{"pull", "quay.io/libpod/alpine_nginx"}) 78 session.WaitWithDefaultTimeout() 79 Expect(session.ExitCode()).To(Equal(0)) 80 81 session = podmanTest.PodmanNoCache([]string{"rmi", "quay.io/libpod/alpine_nginx"}) 82 session.WaitWithDefaultTimeout() 83 Expect(session.ExitCode()).To(Equal(0)) 84 }) 85 86 It("podman pull by digest", func() { 87 session := podmanTest.PodmanNoCache([]string{"pull", "alpine@sha256:1072e499f3f655a032e88542330cf75b02e7bdf673278f701d7ba61629ee3ebe"}) 88 session.WaitWithDefaultTimeout() 89 Expect(session.ExitCode()).To(Equal(0)) 90 91 session = podmanTest.PodmanNoCache([]string{"rmi", "alpine:none"}) 92 session.WaitWithDefaultTimeout() 93 Expect(session.ExitCode()).To(Equal(0)) 94 }) 95 96 It("podman pull by digest (image list)", func() { 97 session := podmanTest.PodmanNoCache([]string{"pull", "--override-arch=arm64", ALPINELISTDIGEST}) 98 session.WaitWithDefaultTimeout() 99 Expect(session.ExitCode()).To(Equal(0)) 100 // inspect using the digest of the list 101 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINELISTDIGEST}) 102 session.WaitWithDefaultTimeout() 103 Expect(session.ExitCode()).To(Equal(0)) 104 Expect(string(session.Out.Contents())).To(HavePrefix("[]")) 105 // inspect using the digest of the list 106 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINELISTDIGEST}) 107 session.WaitWithDefaultTimeout() 108 Expect(session.ExitCode()).To(Equal(0)) 109 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST)) 110 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) 111 // inspect using the digest of the arch-specific image's manifest 112 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64DIGEST}) 113 session.WaitWithDefaultTimeout() 114 Expect(session.ExitCode()).To(Equal(0)) 115 Expect(string(session.Out.Contents())).To(HavePrefix("[]")) 116 // inspect using the digest of the arch-specific image's manifest 117 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64DIGEST}) 118 session.WaitWithDefaultTimeout() 119 Expect(session.ExitCode()).To(Equal(0)) 120 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST)) 121 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) 122 // inspect using the image ID 123 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64ID}) 124 session.WaitWithDefaultTimeout() 125 Expect(session.ExitCode()).To(Equal(0)) 126 Expect(string(session.Out.Contents())).To(HavePrefix("[]")) 127 // inspect using the image ID 128 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64ID}) 129 session.WaitWithDefaultTimeout() 130 Expect(session.ExitCode()).To(Equal(0)) 131 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST)) 132 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) 133 // remove using the digest of the list 134 session = podmanTest.PodmanNoCache([]string{"rmi", ALPINELISTDIGEST}) 135 session.WaitWithDefaultTimeout() 136 Expect(session.ExitCode()).To(Equal(0)) 137 }) 138 139 It("podman pull by instance digest (image list)", func() { 140 session := podmanTest.PodmanNoCache([]string{"pull", "--override-arch=arm64", ALPINEARM64DIGEST}) 141 session.WaitWithDefaultTimeout() 142 Expect(session.ExitCode()).To(Equal(0)) 143 // inspect using the digest of the list 144 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINELISTDIGEST}) 145 session.WaitWithDefaultTimeout() 146 Expect(session.ExitCode()).To(Not(Equal(0))) 147 // inspect using the digest of the list 148 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINELISTDIGEST}) 149 session.WaitWithDefaultTimeout() 150 Expect(session.ExitCode()).To(Not(Equal(0))) 151 // inspect using the digest of the arch-specific image's manifest 152 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64DIGEST}) 153 session.WaitWithDefaultTimeout() 154 Expect(session.ExitCode()).To(Equal(0)) 155 Expect(string(session.Out.Contents())).To(HavePrefix("[]")) 156 // inspect using the digest of the arch-specific image's manifest 157 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64DIGEST}) 158 session.WaitWithDefaultTimeout() 159 Expect(session.ExitCode()).To(Equal(0)) 160 Expect(string(session.Out.Contents())).To(Not(ContainSubstring(ALPINELISTDIGEST))) 161 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) 162 // inspect using the image ID 163 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64ID}) 164 session.WaitWithDefaultTimeout() 165 Expect(session.ExitCode()).To(Equal(0)) 166 Expect(string(session.Out.Contents())).To(HavePrefix("[]")) 167 // inspect using the image ID 168 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64ID}) 169 session.WaitWithDefaultTimeout() 170 Expect(session.ExitCode()).To(Equal(0)) 171 Expect(string(session.Out.Contents())).To(Not(ContainSubstring(ALPINELISTDIGEST))) 172 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) 173 // remove using the digest of the instance 174 session = podmanTest.PodmanNoCache([]string{"rmi", ALPINEARM64DIGEST}) 175 session.WaitWithDefaultTimeout() 176 Expect(session.ExitCode()).To(Equal(0)) 177 }) 178 179 It("podman pull by tag (image list)", func() { 180 session := podmanTest.PodmanNoCache([]string{"pull", "--override-arch=arm64", ALPINELISTTAG}) 181 session.WaitWithDefaultTimeout() 182 Expect(session.ExitCode()).To(Equal(0)) 183 // inspect using the tag we used for pulling 184 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINELISTTAG}) 185 session.WaitWithDefaultTimeout() 186 Expect(session.ExitCode()).To(Equal(0)) 187 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTTAG)) 188 // inspect using the tag we used for pulling 189 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINELISTTAG}) 190 session.WaitWithDefaultTimeout() 191 Expect(session.ExitCode()).To(Equal(0)) 192 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST)) 193 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) 194 // inspect using the digest of the list 195 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINELISTDIGEST}) 196 session.WaitWithDefaultTimeout() 197 Expect(session.ExitCode()).To(Equal(0)) 198 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTTAG)) 199 // inspect using the digest of the list 200 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINELISTDIGEST}) 201 session.WaitWithDefaultTimeout() 202 Expect(session.ExitCode()).To(Equal(0)) 203 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST)) 204 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) 205 // inspect using the digest of the arch-specific image's manifest 206 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64DIGEST}) 207 session.WaitWithDefaultTimeout() 208 Expect(session.ExitCode()).To(Equal(0)) 209 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTTAG)) 210 // inspect using the digest of the arch-specific image's manifest 211 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64DIGEST}) 212 session.WaitWithDefaultTimeout() 213 Expect(session.ExitCode()).To(Equal(0)) 214 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST)) 215 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) 216 // inspect using the image ID 217 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoTags}}", ALPINEARM64ID}) 218 session.WaitWithDefaultTimeout() 219 Expect(session.ExitCode()).To(Equal(0)) 220 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTTAG)) 221 // inspect using the image ID 222 session = podmanTest.PodmanNoCache([]string{"inspect", "--format", "{{.RepoDigests}}", ALPINEARM64ID}) 223 session.WaitWithDefaultTimeout() 224 Expect(session.ExitCode()).To(Equal(0)) 225 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINELISTDIGEST)) 226 Expect(string(session.Out.Contents())).To(ContainSubstring(ALPINEARM64DIGEST)) 227 // remove using the tag 228 session = podmanTest.PodmanNoCache([]string{"rmi", ALPINELISTTAG}) 229 session.WaitWithDefaultTimeout() 230 Expect(session.ExitCode()).To(Equal(0)) 231 }) 232 233 It("podman pull bogus image", func() { 234 session := podmanTest.PodmanNoCache([]string{"pull", "umohnani/get-started"}) 235 session.WaitWithDefaultTimeout() 236 Expect(session).To(ExitWithError()) 237 }) 238 239 It("podman pull from docker-archive", func() { 240 podmanTest.RestoreArtifact(ALPINE) 241 tarfn := filepath.Join(podmanTest.TempDir, "alp.tar") 242 session := podmanTest.PodmanNoCache([]string{"save", "-o", tarfn, "alpine"}) 243 session.WaitWithDefaultTimeout() 244 245 Expect(session.ExitCode()).To(Equal(0)) 246 session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) 247 session.WaitWithDefaultTimeout() 248 Expect(session.ExitCode()).To(Equal(0)) 249 session = podmanTest.PodmanNoCache([]string{"pull", fmt.Sprintf("docker-archive:%s", tarfn)}) 250 session.WaitWithDefaultTimeout() 251 Expect(session.ExitCode()).To(Equal(0)) 252 session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) 253 session.WaitWithDefaultTimeout() 254 Expect(session.ExitCode()).To(Equal(0)) 255 }) 256 257 It("podman pull from oci-archive", func() { 258 podmanTest.RestoreArtifact(ALPINE) 259 tarfn := filepath.Join(podmanTest.TempDir, "oci-alp.tar") 260 session := podmanTest.PodmanNoCache([]string{"save", "--format", "oci-archive", "-o", tarfn, "alpine"}) 261 session.WaitWithDefaultTimeout() 262 263 Expect(session.ExitCode()).To(Equal(0)) 264 session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) 265 session.WaitWithDefaultTimeout() 266 Expect(session.ExitCode()).To(Equal(0)) 267 session = podmanTest.PodmanNoCache([]string{"pull", fmt.Sprintf("oci-archive:%s", tarfn)}) 268 session.WaitWithDefaultTimeout() 269 Expect(session.ExitCode()).To(Equal(0)) 270 session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) 271 session.WaitWithDefaultTimeout() 272 Expect(session.ExitCode()).To(Equal(0)) 273 }) 274 275 It("podman pull from local directory", func() { 276 podmanTest.RestoreArtifact(ALPINE) 277 dirpath := filepath.Join(podmanTest.TempDir, "alpine") 278 os.MkdirAll(dirpath, os.ModePerm) 279 imgPath := fmt.Sprintf("dir:%s", dirpath) 280 281 session := podmanTest.PodmanNoCache([]string{"push", "alpine", imgPath}) 282 session.WaitWithDefaultTimeout() 283 Expect(session.ExitCode()).To(Equal(0)) 284 session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) 285 session.WaitWithDefaultTimeout() 286 Expect(session.ExitCode()).To(Equal(0)) 287 session = podmanTest.PodmanNoCache([]string{"pull", imgPath}) 288 session.WaitWithDefaultTimeout() 289 Expect(session.ExitCode()).To(Equal(0)) 290 session = podmanTest.PodmanNoCache([]string{"images"}) 291 session.WaitWithDefaultTimeout() 292 Expect(session.ExitCode()).To(Equal(0)) 293 Expect(session.LineInOutputContainsTag(filepath.Join("localhost", dirpath), "latest")).To(BeTrue()) 294 session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) 295 session.WaitWithDefaultTimeout() 296 Expect(session.ExitCode()).To(Equal(0)) 297 }) 298 299 It("podman pull from local OCI directory", func() { 300 podmanTest.RestoreArtifact(ALPINE) 301 dirpath := filepath.Join(podmanTest.TempDir, "alpine") 302 os.MkdirAll(dirpath, os.ModePerm) 303 imgPath := fmt.Sprintf("oci:%s", dirpath) 304 305 session := podmanTest.PodmanNoCache([]string{"push", "alpine", imgPath}) 306 session.WaitWithDefaultTimeout() 307 Expect(session.ExitCode()).To(Equal(0)) 308 session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) 309 session.WaitWithDefaultTimeout() 310 Expect(session.ExitCode()).To(Equal(0)) 311 session = podmanTest.PodmanNoCache([]string{"pull", imgPath}) 312 session.WaitWithDefaultTimeout() 313 Expect(session.ExitCode()).To(Equal(0)) 314 session = podmanTest.PodmanNoCache([]string{"images"}) 315 session.WaitWithDefaultTimeout() 316 Expect(session.ExitCode()).To(Equal(0)) 317 Expect(session.LineInOutputContainsTag(filepath.Join("localhost", dirpath), "latest")).To(BeTrue()) 318 session = podmanTest.PodmanNoCache([]string{"rmi", "alpine"}) 319 session.WaitWithDefaultTimeout() 320 Expect(session.ExitCode()).To(Equal(0)) 321 }) 322 323 It("podman pull check quiet", func() { 324 podmanTest.RestoreArtifact(ALPINE) 325 setup := podmanTest.PodmanNoCache([]string{"images", ALPINE, "-q", "--no-trunc"}) 326 setup.WaitWithDefaultTimeout() 327 Expect(setup.ExitCode()).To(Equal(0)) 328 shortImageId := strings.Split(setup.OutputToString(), ":")[1] 329 330 rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE}) 331 rmi.WaitWithDefaultTimeout() 332 Expect(rmi.ExitCode()).To(Equal(0)) 333 334 pull := podmanTest.PodmanNoCache([]string{"pull", "-q", ALPINE}) 335 pull.WaitWithDefaultTimeout() 336 Expect(pull.ExitCode()).To(Equal(0)) 337 338 Expect(pull.OutputToString()).To(ContainSubstring(shortImageId)) 339 }) 340 341 It("podman pull check all tags", func() { 342 session := podmanTest.PodmanNoCache([]string{"pull", "--all-tags", "k8s.gcr.io/pause"}) 343 session.WaitWithDefaultTimeout() 344 Expect(session.ExitCode()).To(Equal(0)) 345 Expect(session.LineInOuputStartsWith("Pulled Images:")).To(BeTrue()) 346 347 session = podmanTest.PodmanNoCache([]string{"images"}) 348 session.WaitWithDefaultTimeout() 349 Expect(session.ExitCode()).To(Equal(0)) 350 Expect(len(session.OutputToStringArray())).To(BeNumerically(">", 4)) 351 }) 352 353 It("podman pull from docker with nonexist --authfile", func() { 354 SkipIfRemote() 355 session := podmanTest.PodmanNoCache([]string{"pull", "--authfile", "/tmp/nonexist", ALPINE}) 356 session.WaitWithDefaultTimeout() 357 Expect(session.ExitCode()).To(Not(Equal(0))) 358 }) 359 })