podman

Форк
0
/
load_test.go 
290 строк · 9.8 Кб
1
package integration
2

3
import (
4
	"fmt"
5
	"path/filepath"
6

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"
11
)
12

13
var _ = Describe("Podman load", func() {
14

15
	BeforeEach(func() {
16
		podmanTest.AddImageToRWStore(ALPINE)
17
	})
18

19
	It("podman load input flag", func() {
20
		outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
21

22
		images := podmanTest.Podman([]string{"images"})
23
		images.WaitWithDefaultTimeout()
24
		GinkgoWriter.Println(images.OutputToStringArray())
25

26
		save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, ALPINE})
27
		save.WaitWithDefaultTimeout()
28
		Expect(save).Should(ExitCleanly())
29

30
		rmi := podmanTest.Podman([]string{"rmi", ALPINE})
31
		rmi.WaitWithDefaultTimeout()
32
		Expect(rmi).Should(ExitCleanly())
33

34
		result := podmanTest.Podman([]string{"load", "-q", "-i", outfile})
35
		result.WaitWithDefaultTimeout()
36
		Expect(result).Should(ExitCleanly())
37
	})
38

39
	It("podman load compressed tar file", func() {
40
		outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
41

42
		save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, ALPINE})
43
		save.WaitWithDefaultTimeout()
44
		Expect(save).Should(ExitCleanly())
45

46
		compress := SystemExec("gzip", []string{outfile})
47
		Expect(compress).Should(ExitCleanly())
48
		outfile += ".gz"
49

50
		rmi := podmanTest.Podman([]string{"rmi", ALPINE})
51
		rmi.WaitWithDefaultTimeout()
52
		Expect(rmi).Should(ExitCleanly())
53

54
		result := podmanTest.Podman([]string{"load", "-q", "-i", outfile})
55
		result.WaitWithDefaultTimeout()
56
		Expect(result).Should(ExitCleanly())
57
	})
58

59
	It("podman load oci-archive image", func() {
60
		outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
61

62
		save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, "--format", "oci-archive", ALPINE})
63
		save.WaitWithDefaultTimeout()
64
		Expect(save).Should(ExitCleanly())
65

66
		rmi := podmanTest.Podman([]string{"rmi", ALPINE})
67
		rmi.WaitWithDefaultTimeout()
68
		Expect(rmi).Should(ExitCleanly())
69

70
		result := podmanTest.Podman([]string{"load", "-q", "-i", outfile})
71
		result.WaitWithDefaultTimeout()
72
		Expect(result).Should(ExitCleanly())
73
	})
74

75
	It("podman load oci-archive with signature", func() {
76
		outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
77

78
		save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, "--format", "oci-archive", ALPINE})
79
		save.WaitWithDefaultTimeout()
80
		Expect(save).Should(ExitCleanly())
81

82
		rmi := podmanTest.Podman([]string{"rmi", ALPINE})
83
		rmi.WaitWithDefaultTimeout()
84
		Expect(rmi).Should(ExitCleanly())
85

86
		result := podmanTest.Podman([]string{"load", "-q", "--signature-policy", "/etc/containers/policy.json", "-i", outfile})
87
		result.WaitWithDefaultTimeout()
88
		if IsRemote() {
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())
94
		} else {
95
			Expect(result).Should(ExitCleanly())
96
		}
97
	})
98

99
	It("podman load with quiet flag", func() {
100
		outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
101

102
		save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, ALPINE})
103
		save.WaitWithDefaultTimeout()
104
		Expect(save).Should(ExitCleanly())
105

106
		rmi := podmanTest.Podman([]string{"rmi", ALPINE})
107
		rmi.WaitWithDefaultTimeout()
108
		Expect(rmi).Should(ExitCleanly())
109

110
		result := podmanTest.Podman([]string{"load", "-q", "-i", outfile})
111
		result.WaitWithDefaultTimeout()
112
		Expect(result).Should(ExitCleanly())
113
	})
114

115
	It("podman load directory", func() {
116
		SkipIfRemote("Remote does not support loading directories")
117
		outdir := filepath.Join(podmanTest.TempDir, "alpine")
118

119
		save := podmanTest.Podman([]string{"save", "-q", "--format", "oci-dir", "-o", outdir, ALPINE})
120
		save.WaitWithDefaultTimeout()
121
		Expect(save).Should(ExitCleanly())
122

123
		rmi := podmanTest.Podman([]string{"rmi", ALPINE})
124
		rmi.WaitWithDefaultTimeout()
125
		Expect(rmi).Should(ExitCleanly())
126

127
		result := podmanTest.Podman([]string{"load", "-q", "-i", outdir})
128
		result.WaitWithDefaultTimeout()
129
		Expect(result).Should(ExitCleanly())
130
	})
131

132
	It("podman-remote load directory", func() {
133
		// Remote-only test looking for the specific remote error
134
		// message when trying to load a directory.
135
		if !IsRemote() {
136
			Skip("Remote only test")
137
		}
138

139
		result := podmanTest.Podman([]string{"load", "-i", podmanTest.TempDir})
140
		result.WaitWithDefaultTimeout()
141
		Expect(result).Should(Exit(125))
142

143
		errMsg := fmt.Sprintf("remote client supports archives only but %q is a directory", podmanTest.TempDir)
144
		Expect(result.ErrorToString()).To(ContainSubstring(errMsg))
145
	})
146

147
	It("podman load bogus file", func() {
148
		save := podmanTest.Podman([]string{"load", "-i", "foobar.tar"})
149
		save.WaitWithDefaultTimeout()
150
		Expect(save).To(ExitWithError())
151
	})
152

153
	It("podman load multiple tags", func() {
154
		if podmanTest.Host.Arch == "ppc64le" {
155
			Skip("skip on ppc64le")
156
		}
157
		outfile := filepath.Join(podmanTest.TempDir, "alpine.tar")
158
		alpVersion := "quay.io/libpod/alpine:3.2"
159

160
		pull := podmanTest.Podman([]string{"pull", "-q", alpVersion})
161
		pull.WaitWithDefaultTimeout()
162
		Expect(pull).Should(ExitCleanly())
163

164
		save := podmanTest.Podman([]string{"save", "-q", "-o", outfile, ALPINE, alpVersion})
165
		save.WaitWithDefaultTimeout()
166
		Expect(save).Should(ExitCleanly())
167

168
		rmi := podmanTest.Podman([]string{"rmi", ALPINE, alpVersion})
169
		rmi.WaitWithDefaultTimeout()
170
		Expect(rmi).Should(ExitCleanly())
171

172
		result := podmanTest.Podman([]string{"load", "-q", "-i", outfile})
173
		result.WaitWithDefaultTimeout()
174
		Expect(result).Should(ExitCleanly())
175

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())
182
	})
183

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())
189

190
		setup = podmanTest.Podman([]string{"save", "-q", "-o", outfile, "--format", "oci-archive", "hello:world"})
191
		setup.WaitWithDefaultTimeout()
192
		Expect(setup).Should(ExitCleanly())
193

194
		setup = podmanTest.Podman([]string{"rmi", "hello:world"})
195
		setup.WaitWithDefaultTimeout()
196
		Expect(setup).Should(ExitCleanly())
197

198
		load := podmanTest.Podman([]string{"load", "-q", "-i", outfile})
199
		load.WaitWithDefaultTimeout()
200
		Expect(load).Should(ExitCleanly())
201

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"))
206
	})
207

208
	It("podman load localhost registry from scratch and :latest", func() {
209
		outfile := filepath.Join(podmanTest.TempDir, "load_test.tar.gz")
210

211
		setup := podmanTest.Podman([]string{"tag", ALPINE, "hello"})
212
		setup.WaitWithDefaultTimeout()
213
		Expect(setup).Should(ExitCleanly())
214

215
		setup = podmanTest.Podman([]string{"save", "-q", "-o", outfile, "--format", "oci-archive", "hello"})
216
		setup.WaitWithDefaultTimeout()
217
		Expect(setup).Should(ExitCleanly())
218

219
		setup = podmanTest.Podman([]string{"rmi", "hello"})
220
		setup.WaitWithDefaultTimeout()
221
		Expect(setup).Should(ExitCleanly())
222

223
		load := podmanTest.Podman([]string{"load", "-q", "-i", outfile})
224
		load.WaitWithDefaultTimeout()
225
		Expect(load).Should(ExitCleanly())
226

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"))
231
	})
232

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")
236

237
		setup := podmanTest.Podman([]string{"tag", ALPINE, "hello:world"})
238
		setup.WaitWithDefaultTimeout()
239
		Expect(setup).Should(ExitCleanly())
240

241
		setup = podmanTest.Podman([]string{"save", "-q", "-o", outfile, "--format", "oci-dir", "hello:world"})
242
		setup.WaitWithDefaultTimeout()
243
		Expect(setup).Should(ExitCleanly())
244

245
		setup = podmanTest.Podman([]string{"rmi", "hello:world"})
246
		setup.WaitWithDefaultTimeout()
247
		Expect(setup).Should(ExitCleanly())
248

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:"))
253
	})
254

255
	It("podman load xz compressed image", func() {
256
		outfile := filepath.Join(podmanTest.TempDir, "alp.tar")
257

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())
263

264
		rmi := podmanTest.Podman([]string{"rmi", ALPINE})
265
		rmi.WaitWithDefaultTimeout()
266
		Expect(rmi).Should(ExitCleanly())
267

268
		result := podmanTest.Podman([]string{"load", "-q", "-i", outfile + ".xz"})
269
		result.WaitWithDefaultTimeout()
270
		Expect(result).Should(ExitCleanly())
271
	})
272

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"))
279

280
		stderr := result.ErrorToString()
281
		if IsRemote() {
282
			Expect(stderr).To(BeEmpty(), "no stderr when running remote")
283
		} else {
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:"))
288
		}
289
	})
290
})
291

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.