2018-02-08 16:40:43 +00:00
|
|
|
package integration
|
|
|
|
|
|
|
|
import (
|
2019-05-14 19:28:50 +00:00
|
|
|
"fmt"
|
2018-02-08 16:40:43 +00:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
2020-07-28 12:23:45 +00:00
|
|
|
. "github.com/containers/podman/v2/test/utils"
|
2018-02-08 16:40:43 +00:00
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("Podman load", func() {
|
|
|
|
var (
|
|
|
|
tempdir string
|
|
|
|
err error
|
2018-10-29 06:56:07 +00:00
|
|
|
podmanTest *PodmanTestIntegration
|
2018-02-08 16:40:43 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
BeforeEach(func() {
|
|
|
|
tempdir, err = CreateTempDirInTempDir()
|
|
|
|
if err != nil {
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2018-10-29 06:56:07 +00:00
|
|
|
podmanTest = PodmanTestCreate(tempdir)
|
2019-03-06 16:29:11 +00:00
|
|
|
podmanTest.Setup()
|
2018-02-08 16:40:43 +00:00
|
|
|
podmanTest.RestoreAllArtifacts()
|
|
|
|
})
|
|
|
|
|
|
|
|
AfterEach(func() {
|
|
|
|
podmanTest.Cleanup()
|
2018-07-28 16:11:31 +00:00
|
|
|
f := CurrentGinkgoTestDescription()
|
2019-03-06 16:29:11 +00:00
|
|
|
processTestResult(f)
|
|
|
|
|
2018-02-08 16:40:43 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("podman load input flag", func() {
|
|
|
|
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
images := podmanTest.PodmanNoCache([]string{"images"})
|
|
|
|
images.WaitWithDefaultTimeout()
|
|
|
|
fmt.Println(images.OutputToStringArray())
|
|
|
|
|
|
|
|
save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINE})
|
2018-02-08 16:40:43 +00:00
|
|
|
save.WaitWithDefaultTimeout()
|
|
|
|
Expect(save.ExitCode()).To(Equal(0))
|
|
|
|
|
|
|
|
rmi := podmanTest.Podman([]string{"rmi", ALPINE})
|
|
|
|
rmi.WaitWithDefaultTimeout()
|
|
|
|
Expect(rmi.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
result := podmanTest.PodmanNoCache([]string{"load", "-i", outfile})
|
2018-02-08 16:40:43 +00:00
|
|
|
result.WaitWithDefaultTimeout()
|
|
|
|
Expect(result.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
2018-03-08 19:59:19 +00:00
|
|
|
It("podman load compressed tar file", func() {
|
|
|
|
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINE})
|
2018-03-08 19:59:19 +00:00
|
|
|
save.WaitWithDefaultTimeout()
|
|
|
|
Expect(save.ExitCode()).To(Equal(0))
|
|
|
|
|
2018-10-29 06:56:07 +00:00
|
|
|
compress := SystemExec("gzip", []string{outfile})
|
2019-02-28 14:38:02 +00:00
|
|
|
Expect(compress.ExitCode()).To(Equal(0))
|
2018-03-08 19:59:19 +00:00
|
|
|
outfile = outfile + ".gz"
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE})
|
2018-03-08 19:59:19 +00:00
|
|
|
rmi.WaitWithDefaultTimeout()
|
|
|
|
Expect(rmi.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
result := podmanTest.PodmanNoCache([]string{"load", "-i", outfile})
|
2018-03-08 19:59:19 +00:00
|
|
|
result.WaitWithDefaultTimeout()
|
|
|
|
Expect(result.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
2018-02-08 16:40:43 +00:00
|
|
|
It("podman load oci-archive image", func() {
|
|
|
|
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE})
|
2018-02-08 16:40:43 +00:00
|
|
|
save.WaitWithDefaultTimeout()
|
|
|
|
Expect(save.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE})
|
2018-02-08 16:40:43 +00:00
|
|
|
rmi.WaitWithDefaultTimeout()
|
|
|
|
Expect(rmi.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
result := podmanTest.PodmanNoCache([]string{"load", "-i", outfile})
|
2018-02-08 16:40:43 +00:00
|
|
|
result.WaitWithDefaultTimeout()
|
|
|
|
Expect(result.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman load oci-archive with signature", func() {
|
|
|
|
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-archive", ALPINE})
|
2018-02-08 16:40:43 +00:00
|
|
|
save.WaitWithDefaultTimeout()
|
|
|
|
Expect(save.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE})
|
2018-02-08 16:40:43 +00:00
|
|
|
rmi.WaitWithDefaultTimeout()
|
|
|
|
Expect(rmi.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
result := podmanTest.PodmanNoCache([]string{"load", "--signature-policy", "/etc/containers/policy.json", "-i", outfile})
|
2018-02-08 16:40:43 +00:00
|
|
|
result.WaitWithDefaultTimeout()
|
|
|
|
Expect(result.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman load with quiet flag", func() {
|
|
|
|
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINE})
|
2018-02-08 16:40:43 +00:00
|
|
|
save.WaitWithDefaultTimeout()
|
|
|
|
Expect(save.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE})
|
2018-02-08 16:40:43 +00:00
|
|
|
rmi.WaitWithDefaultTimeout()
|
|
|
|
Expect(rmi.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
result := podmanTest.PodmanNoCache([]string{"load", "-q", "-i", outfile})
|
2018-02-08 16:40:43 +00:00
|
|
|
result.WaitWithDefaultTimeout()
|
|
|
|
Expect(result.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman load directory", func() {
|
2020-09-23 07:57:38 +00:00
|
|
|
SkipIfRemote("Remote does not support loading directories")
|
2018-02-08 16:40:43 +00:00
|
|
|
outdir := filepath.Join(podmanTest.TempDir, "alpine")
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
save := podmanTest.PodmanNoCache([]string{"save", "--format", "oci-dir", "-o", outdir, ALPINE})
|
2018-02-08 16:40:43 +00:00
|
|
|
save.WaitWithDefaultTimeout()
|
|
|
|
Expect(save.ExitCode()).To(Equal(0))
|
|
|
|
|
|
|
|
rmi := podmanTest.Podman([]string{"rmi", ALPINE})
|
|
|
|
rmi.WaitWithDefaultTimeout()
|
|
|
|
Expect(rmi.ExitCode()).To(Equal(0))
|
|
|
|
|
|
|
|
result := podmanTest.Podman([]string{"load", "-i", outdir})
|
|
|
|
result.WaitWithDefaultTimeout()
|
|
|
|
Expect(result.ExitCode()).To(Equal(0))
|
|
|
|
})
|
|
|
|
|
2020-09-23 07:57:38 +00:00
|
|
|
It("podman-remote load directory", func() {
|
|
|
|
// Remote-only test looking for the specific remote error
|
|
|
|
// message when trying to load a directory.
|
|
|
|
if !IsRemote() {
|
|
|
|
Skip("Remote only test")
|
|
|
|
}
|
|
|
|
|
|
|
|
result := podmanTest.Podman([]string{"load", "-i", podmanTest.TempDir})
|
|
|
|
result.WaitWithDefaultTimeout()
|
|
|
|
Expect(result.ExitCode()).To(Equal(125))
|
|
|
|
|
|
|
|
errMsg := fmt.Sprintf("remote client supports archives only but %q is a directory", podmanTest.TempDir)
|
|
|
|
found, _ := result.ErrorGrepString(errMsg)
|
|
|
|
Expect(found).Should(BeTrue())
|
|
|
|
})
|
|
|
|
|
2018-02-08 16:40:43 +00:00
|
|
|
It("podman load bogus file", func() {
|
2019-05-14 19:28:50 +00:00
|
|
|
save := podmanTest.PodmanNoCache([]string{"load", "-i", "foobar.tar"})
|
2018-02-08 16:40:43 +00:00
|
|
|
save.WaitWithDefaultTimeout()
|
2019-10-04 17:09:24 +00:00
|
|
|
Expect(save).To(ExitWithError())
|
2018-02-08 16:40:43 +00:00
|
|
|
})
|
2018-05-21 17:53:19 +00:00
|
|
|
|
|
|
|
It("podman load multiple tags", func() {
|
2018-10-30 15:34:38 +00:00
|
|
|
if podmanTest.Host.Arch == "ppc64le" {
|
|
|
|
Skip("skip on ppc64le")
|
|
|
|
}
|
2018-05-21 17:53:19 +00:00
|
|
|
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
|
2020-10-27 10:47:35 +00:00
|
|
|
alpVersion := "quay.io/libpod/alpine:3.2"
|
2018-05-21 17:53:19 +00:00
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
pull := podmanTest.PodmanNoCache([]string{"pull", alpVersion})
|
2018-05-21 17:53:19 +00:00
|
|
|
pull.WaitWithDefaultTimeout()
|
|
|
|
Expect(pull.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, ALPINE, alpVersion})
|
2018-05-21 17:53:19 +00:00
|
|
|
save.WaitWithDefaultTimeout()
|
|
|
|
Expect(save.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
rmi := podmanTest.PodmanNoCache([]string{"rmi", ALPINE, alpVersion})
|
2018-05-21 17:53:19 +00:00
|
|
|
rmi.WaitWithDefaultTimeout()
|
|
|
|
Expect(rmi.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
result := podmanTest.PodmanNoCache([]string{"load", "-i", outfile})
|
2018-05-21 17:53:19 +00:00
|
|
|
result.WaitWithDefaultTimeout()
|
|
|
|
Expect(result.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
inspect := podmanTest.PodmanNoCache([]string{"inspect", ALPINE})
|
2018-05-21 17:53:19 +00:00
|
|
|
inspect.WaitWithDefaultTimeout()
|
|
|
|
Expect(result.ExitCode()).To(Equal(0))
|
2019-05-14 19:28:50 +00:00
|
|
|
inspect = podmanTest.PodmanNoCache([]string{"inspect", alpVersion})
|
2018-05-21 17:53:19 +00:00
|
|
|
inspect.WaitWithDefaultTimeout()
|
|
|
|
Expect(result.ExitCode()).To(Equal(0))
|
|
|
|
})
|
2018-07-13 21:45:55 +00:00
|
|
|
|
2018-07-23 16:56:24 +00:00
|
|
|
It("podman load localhost registry from scratch", func() {
|
2018-07-13 21:45:55 +00:00
|
|
|
outfile := filepath.Join(podmanTest.TempDir, "load_test.tar.gz")
|
2019-05-14 19:28:50 +00:00
|
|
|
setup := podmanTest.PodmanNoCache([]string{"tag", ALPINE, "hello:world"})
|
2018-07-13 21:45:55 +00:00
|
|
|
setup.WaitWithDefaultTimeout()
|
|
|
|
Expect(setup.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
setup = podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-archive", "hello:world"})
|
2018-07-13 21:45:55 +00:00
|
|
|
setup.WaitWithDefaultTimeout()
|
|
|
|
Expect(setup.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
setup = podmanTest.PodmanNoCache([]string{"rmi", "hello:world"})
|
2018-07-13 21:45:55 +00:00
|
|
|
setup.WaitWithDefaultTimeout()
|
|
|
|
Expect(setup.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
load := podmanTest.PodmanNoCache([]string{"load", "-i", outfile})
|
2018-07-13 21:45:55 +00:00
|
|
|
load.WaitWithDefaultTimeout()
|
|
|
|
Expect(load.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
result := podmanTest.PodmanNoCache([]string{"images", "hello:world"})
|
2018-07-13 21:45:55 +00:00
|
|
|
result.WaitWithDefaultTimeout()
|
|
|
|
Expect(result.LineInOutputContains("docker")).To(Not(BeTrue()))
|
|
|
|
Expect(result.LineInOutputContains("localhost")).To(BeTrue())
|
|
|
|
})
|
|
|
|
|
2018-07-23 16:56:24 +00:00
|
|
|
It("podman load localhost registry from scratch and :latest", func() {
|
2019-05-14 19:28:50 +00:00
|
|
|
podmanTest.RestoreArtifact(fedoraMinimal)
|
2018-07-23 16:56:24 +00:00
|
|
|
outfile := filepath.Join(podmanTest.TempDir, "load_test.tar.gz")
|
|
|
|
|
2020-02-12 22:45:03 +00:00
|
|
|
setup := podmanTest.PodmanNoCache([]string{"tag", fedoraMinimal, "hello"})
|
2018-07-23 16:56:24 +00:00
|
|
|
setup.WaitWithDefaultTimeout()
|
|
|
|
Expect(setup.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
setup = podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-archive", "hello"})
|
2018-07-23 16:56:24 +00:00
|
|
|
setup.WaitWithDefaultTimeout()
|
|
|
|
Expect(setup.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
setup = podmanTest.PodmanNoCache([]string{"rmi", "hello"})
|
2018-07-23 16:56:24 +00:00
|
|
|
setup.WaitWithDefaultTimeout()
|
|
|
|
Expect(setup.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
load := podmanTest.PodmanNoCache([]string{"load", "-i", outfile})
|
2018-07-23 16:56:24 +00:00
|
|
|
load.WaitWithDefaultTimeout()
|
|
|
|
Expect(load.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
result := podmanTest.PodmanNoCache([]string{"images", "hello:latest"})
|
2018-07-23 16:56:24 +00:00
|
|
|
result.WaitWithDefaultTimeout()
|
|
|
|
Expect(result.LineInOutputContains("docker")).To(Not(BeTrue()))
|
|
|
|
Expect(result.LineInOutputContains("localhost")).To(BeTrue())
|
|
|
|
})
|
|
|
|
|
|
|
|
It("podman load localhost registry from dir", func() {
|
2020-10-05 10:13:28 +00:00
|
|
|
SkipIfRemote("podman-remote does not support loading directories")
|
2018-07-13 21:45:55 +00:00
|
|
|
outfile := filepath.Join(podmanTest.TempDir, "load")
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
setup := podmanTest.PodmanNoCache([]string{"tag", BB, "hello:world"})
|
2018-07-13 21:45:55 +00:00
|
|
|
setup.WaitWithDefaultTimeout()
|
|
|
|
Expect(setup.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
setup = podmanTest.PodmanNoCache([]string{"save", "-o", outfile, "--format", "oci-dir", "hello:world"})
|
2018-07-13 21:45:55 +00:00
|
|
|
setup.WaitWithDefaultTimeout()
|
|
|
|
Expect(setup.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
setup = podmanTest.PodmanNoCache([]string{"rmi", "hello:world"})
|
2018-07-13 21:45:55 +00:00
|
|
|
setup.WaitWithDefaultTimeout()
|
|
|
|
Expect(setup.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
load := podmanTest.PodmanNoCache([]string{"load", "-i", outfile})
|
2018-07-13 21:45:55 +00:00
|
|
|
load.WaitWithDefaultTimeout()
|
|
|
|
Expect(load.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
result := podmanTest.PodmanNoCache([]string{"images", "load:latest"})
|
2018-07-13 21:45:55 +00:00
|
|
|
result.WaitWithDefaultTimeout()
|
|
|
|
Expect(result.LineInOutputContains("docker")).To(Not(BeTrue()))
|
|
|
|
Expect(result.LineInOutputContains("localhost")).To(BeTrue())
|
|
|
|
})
|
2018-07-23 15:46:43 +00:00
|
|
|
|
|
|
|
It("podman load xz compressed image", func() {
|
2018-07-31 14:05:48 +00:00
|
|
|
outfile := filepath.Join(podmanTest.TempDir, "bb.tar")
|
2018-07-23 15:46:43 +00:00
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
save := podmanTest.PodmanNoCache([]string{"save", "-o", outfile, BB})
|
2018-07-23 15:46:43 +00:00
|
|
|
save.WaitWithDefaultTimeout()
|
|
|
|
Expect(save.ExitCode()).To(Equal(0))
|
2018-10-29 06:56:07 +00:00
|
|
|
session := SystemExec("xz", []string{outfile})
|
2018-07-23 15:46:43 +00:00
|
|
|
Expect(session.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
rmi := podmanTest.PodmanNoCache([]string{"rmi", BB})
|
2018-07-23 15:46:43 +00:00
|
|
|
rmi.WaitWithDefaultTimeout()
|
|
|
|
Expect(rmi.ExitCode()).To(Equal(0))
|
|
|
|
|
2019-05-14 19:28:50 +00:00
|
|
|
result := podmanTest.PodmanNoCache([]string{"load", "-i", outfile + ".xz"})
|
2018-07-23 15:46:43 +00:00
|
|
|
result.WaitWithDefaultTimeout()
|
|
|
|
Expect(result.ExitCode()).To(Equal(0))
|
|
|
|
})
|
2020-07-31 07:27:21 +00:00
|
|
|
|
|
|
|
It("podman load multi-image archive", func() {
|
|
|
|
result := podmanTest.PodmanNoCache([]string{"load", "-i", "./testdata/image/docker-two-images.tar.xz"})
|
|
|
|
result.WaitWithDefaultTimeout()
|
|
|
|
Expect(result.ExitCode()).To(Equal(0))
|
|
|
|
Expect(result.LineInOutputContains("example.com/empty:latest")).To(BeTrue())
|
|
|
|
Expect(result.LineInOutputContains("example.com/empty/but:different")).To(BeTrue())
|
|
|
|
})
|
2018-02-08 16:40:43 +00:00
|
|
|
})
|