7
. "github.com/containers/podman/v5/test/utils"
8
. "github.com/onsi/ginkgo/v2"
9
. "github.com/onsi/gomega"
10
. "github.com/onsi/gomega/gexec"
13
var _ = Describe("Podman load", func() {
16
podmanTest.AddImageToRWStore(ALPINE)
19
It("podman load input flag", func() {
20
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
22
images := podmanTest.Podman([]string{"images"})
23
images.WaitWithDefaultTimeout()
24
GinkgoWriter.Println(images.OutputToStringArray())
26
save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, ALPINE})
27
save.WaitWithDefaultTimeout()
28
Expect(save).Should(ExitCleanly())
30
rmi := podmanTest.Podman([]string{"rmi", ALPINE})
31
rmi.WaitWithDefaultTimeout()
32
Expect(rmi).Should(ExitCleanly())
34
result := podmanTest.Podman([]string{"load", "-q", "-i", outfile})
35
result.WaitWithDefaultTimeout()
36
Expect(result).Should(ExitCleanly())
39
It("podman load compressed tar file", func() {
40
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
42
save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, ALPINE})
43
save.WaitWithDefaultTimeout()
44
Expect(save).Should(ExitCleanly())
46
compress := SystemExec("gzip", []string{outfile})
47
Expect(compress).Should(ExitCleanly())
50
rmi := podmanTest.Podman([]string{"rmi", ALPINE})
51
rmi.WaitWithDefaultTimeout()
52
Expect(rmi).Should(ExitCleanly())
54
result := podmanTest.Podman([]string{"load", "-q", "-i", outfile})
55
result.WaitWithDefaultTimeout()
56
Expect(result).Should(ExitCleanly())
59
It("podman load oci-archive image", func() {
60
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
62
save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, "--format", "oci-archive", ALPINE})
63
save.WaitWithDefaultTimeout()
64
Expect(save).Should(ExitCleanly())
66
rmi := podmanTest.Podman([]string{"rmi", ALPINE})
67
rmi.WaitWithDefaultTimeout()
68
Expect(rmi).Should(ExitCleanly())
70
result := podmanTest.Podman([]string{"load", "-q", "-i", outfile})
71
result.WaitWithDefaultTimeout()
72
Expect(result).Should(ExitCleanly())
75
It("podman load oci-archive with signature", func() {
76
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
78
save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, "--format", "oci-archive", ALPINE})
79
save.WaitWithDefaultTimeout()
80
Expect(save).Should(ExitCleanly())
82
rmi := podmanTest.Podman([]string{"rmi", ALPINE})
83
rmi.WaitWithDefaultTimeout()
84
Expect(rmi).Should(ExitCleanly())
86
result := podmanTest.Podman([]string{"load", "-q", "--signature-policy", "/etc/containers/policy.json", "-i", outfile})
87
result.WaitWithDefaultTimeout()
89
Expect(result).To(ExitWithError())
90
Expect(result.ErrorToString()).To(ContainSubstring("unknown flag"))
91
result = podmanTest.Podman([]string{"load", "-i", outfile})
92
result.WaitWithDefaultTimeout()
93
Expect(result).Should(ExitCleanly())
95
Expect(result).Should(ExitCleanly())
99
It("podman load with quiet flag", func() {
100
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
102
save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, ALPINE})
103
save.WaitWithDefaultTimeout()
104
Expect(save).Should(ExitCleanly())
106
rmi := podmanTest.Podman([]string{"rmi", ALPINE})
107
rmi.WaitWithDefaultTimeout()
108
Expect(rmi).Should(ExitCleanly())
110
result := podmanTest.Podman([]string{"load", "-q", "-i", outfile})
111
result.WaitWithDefaultTimeout()
112
Expect(result).Should(ExitCleanly())
115
It("podman load directory", func() {
116
SkipIfRemote("Remote does not support loading directories")
117
outdir := filepath.Join(podmanTest.TempDir, "alpine")
119
save := podmanTest.Podman([]string{"save", "-q", "--format", "oci-dir", "-o", outdir, ALPINE})
120
save.WaitWithDefaultTimeout()
121
Expect(save).Should(ExitCleanly())
123
rmi := podmanTest.Podman([]string{"rmi", ALPINE})
124
rmi.WaitWithDefaultTimeout()
125
Expect(rmi).Should(ExitCleanly())
127
result := podmanTest.Podman([]string{"load", "-q", "-i", outdir})
128
result.WaitWithDefaultTimeout()
129
Expect(result).Should(ExitCleanly())
132
It("podman-remote load directory", func() {
136
Skip("Remote only test")
139
result := podmanTest.Podman([]string{"load", "-i", podmanTest.TempDir})
140
result.WaitWithDefaultTimeout()
141
Expect(result).Should(Exit(125))
143
errMsg := fmt.Sprintf("remote client supports archives only but %q is a directory", podmanTest.TempDir)
144
Expect(result.ErrorToString()).To(ContainSubstring(errMsg))
147
It("podman load bogus file", func() {
148
save := podmanTest.Podman([]string{"load", "-i", "foobar.tar"})
149
save.WaitWithDefaultTimeout()
150
Expect(save).To(ExitWithError())
153
It("podman load multiple tags", func() {
154
if podmanTest.Host.Arch == "ppc64le" {
155
Skip("skip on ppc64le")
157
outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
158
alpVersion := "quay.io/libpod/alpine:3.2"
160
pull := podmanTest.Podman([]string{"pull", "-q", alpVersion})
161
pull.WaitWithDefaultTimeout()
162
Expect(pull).Should(ExitCleanly())
164
save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, ALPINE, alpVersion})
165
save.WaitWithDefaultTimeout()
166
Expect(save).Should(ExitCleanly())
168
rmi := podmanTest.Podman([]string{"rmi", ALPINE, alpVersion})
169
rmi.WaitWithDefaultTimeout()
170
Expect(rmi).Should(ExitCleanly())
172
result := podmanTest.Podman([]string{"load", "-q", "-i", outfile})
173
result.WaitWithDefaultTimeout()
174
Expect(result).Should(ExitCleanly())
176
inspect := podmanTest.Podman([]string{"inspect", ALPINE})
177
inspect.WaitWithDefaultTimeout()
178
Expect(result).Should(ExitCleanly())
179
inspect = podmanTest.Podman([]string{"inspect", alpVersion})
180
inspect.WaitWithDefaultTimeout()
181
Expect(result).Should(ExitCleanly())
184
It("podman load localhost registry from scratch", func() {
185
outfile := filepath.Join(podmanTest.TempDir, "load_test.tar.gz")
186
setup := podmanTest.Podman([]string{"tag", ALPINE, "hello:world"})
187
setup.WaitWithDefaultTimeout()
188
Expect(setup).Should(ExitCleanly())
190
setup = podmanTest.Podman([]string{"save", "-q", "-o", outfile, "--format", "oci-archive", "hello:world"})
191
setup.WaitWithDefaultTimeout()
192
Expect(setup).Should(ExitCleanly())
194
setup = podmanTest.Podman([]string{"rmi", "hello:world"})
195
setup.WaitWithDefaultTimeout()
196
Expect(setup).Should(ExitCleanly())
198
load := podmanTest.Podman([]string{"load", "-q", "-i", outfile})
199
load.WaitWithDefaultTimeout()
200
Expect(load).Should(ExitCleanly())
202
result := podmanTest.Podman([]string{"images", "hello:world"})
203
result.WaitWithDefaultTimeout()
204
Expect(result.OutputToString()).To(Not(ContainSubstring("docker")))
205
Expect(result.OutputToString()).To(ContainSubstring("localhost"))
208
It("podman load localhost registry from scratch and :latest", func() {
209
outfile := filepath.Join(podmanTest.TempDir, "load_test.tar.gz")
211
setup := podmanTest.Podman([]string{"tag", ALPINE, "hello"})
212
setup.WaitWithDefaultTimeout()
213
Expect(setup).Should(ExitCleanly())
215
setup = podmanTest.Podman([]string{"save", "-q", "-o", outfile, "--format", "oci-archive", "hello"})
216
setup.WaitWithDefaultTimeout()
217
Expect(setup).Should(ExitCleanly())
219
setup = podmanTest.Podman([]string{"rmi", "hello"})
220
setup.WaitWithDefaultTimeout()
221
Expect(setup).Should(ExitCleanly())
223
load := podmanTest.Podman([]string{"load", "-q", "-i", outfile})
224
load.WaitWithDefaultTimeout()
225
Expect(load).Should(ExitCleanly())
227
result := podmanTest.Podman([]string{"images", "hello:latest"})
228
result.WaitWithDefaultTimeout()
229
Expect(result.OutputToString()).To(Not(ContainSubstring("docker")))
230
Expect(result.OutputToString()).To(ContainSubstring("localhost"))
233
It("podman load localhost registry from dir", func() {
234
SkipIfRemote("podman-remote does not support loading directories")
235
outfile := filepath.Join(podmanTest.TempDir, "load")
237
setup := podmanTest.Podman([]string{"tag", ALPINE, "hello:world"})
238
setup.WaitWithDefaultTimeout()
239
Expect(setup).Should(ExitCleanly())
241
setup = podmanTest.Podman([]string{"save", "-q", "-o", outfile, "--format", "oci-dir", "hello:world"})
242
setup.WaitWithDefaultTimeout()
243
Expect(setup).Should(ExitCleanly())
245
setup = podmanTest.Podman([]string{"rmi", "hello:world"})
246
setup.WaitWithDefaultTimeout()
247
Expect(setup).Should(ExitCleanly())
249
load := podmanTest.Podman([]string{"load", "-q", "-i", outfile})
250
load.WaitWithDefaultTimeout()
251
Expect(load).Should(ExitCleanly())
252
Expect(load.OutputToString()).To(ContainSubstring("Loaded image: sha256:"))
255
It("podman load xz compressed image", func() {
256
outfile := filepath.Join(podmanTest.TempDir, "alp.tar")
258
save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, ALPINE})
259
save.WaitWithDefaultTimeout()
260
Expect(save).Should(ExitCleanly())
261
session := SystemExec("xz", []string{outfile})
262
Expect(session).Should(ExitCleanly())
264
rmi := podmanTest.Podman([]string{"rmi", ALPINE})
265
rmi.WaitWithDefaultTimeout()
266
Expect(rmi).Should(ExitCleanly())
268
result := podmanTest.Podman([]string{"load", "-q", "-i", outfile + ".xz"})
269
result.WaitWithDefaultTimeout()
270
Expect(result).Should(ExitCleanly())
273
It("podman load multi-image archive", func() {
274
result := podmanTest.Podman([]string{"load", "-i", "./testdata/docker-two-images.tar.xz"})
275
result.WaitWithDefaultTimeout()
276
Expect(result).Should(Exit(0))
277
Expect(result.OutputToString()).To(ContainSubstring("example.com/empty:latest"))
278
Expect(result.OutputToString()).To(ContainSubstring("example.com/empty/but:different"))
280
stderr := result.ErrorToString()
282
Expect(stderr).To(BeEmpty(), "no stderr when running remote")
284
Expect(stderr).To(ContainSubstring("Getting image source signatures"))
285
Expect(stderr).To(ContainSubstring("Copying blob"))
286
Expect(stderr).To(ContainSubstring("Writing manifest to image destination"))
287
Expect(stderr).To(ContainSubstring("Copying config sha256:"))