podman

Форк
0
/
runlabel_test.go 
109 строк · 3.8 Кб
1
package integration
2

3
import (
4
	"fmt"
5

6
	. "github.com/containers/podman/v5/test/utils"
7
	. "github.com/onsi/ginkgo/v2"
8
	. "github.com/onsi/gomega"
9
)
10

11
var PodmanDockerfile = fmt.Sprintf(`
12
FROM  %s
13
LABEL RUN podman --version`, ALPINE)
14

15
var LsDockerfile = fmt.Sprintf(`
16
FROM  %s
17
LABEL RUN ls -la`, ALPINE)
18

19
var PodmanRunlabelNameDockerfile = fmt.Sprintf(`
20
FROM  %s
21
LABEL RUN podman run --name NAME IMAGE`, ALPINE)
22

23
var _ = Describe("podman container runlabel", func() {
24

25
	BeforeEach(func() {
26
		SkipIfRemote("runlabel is not supported for remote connections")
27
	})
28

29
	It("podman container runlabel (podman --version)", func() {
30
		image := "podman-runlabel-test:podman"
31
		podmanTest.BuildImage(PodmanDockerfile, image, "false")
32

33
		result := podmanTest.Podman([]string{"container", "runlabel", "RUN", image})
34
		result.WaitWithDefaultTimeout()
35
		Expect(result).Should(ExitCleanly())
36

37
		result = podmanTest.Podman([]string{"rmi", image})
38
		result.WaitWithDefaultTimeout()
39
		Expect(result).Should(ExitCleanly())
40
	})
41

42
	It("podman container runlabel (ls -la)", func() {
43
		image := "podman-runlabel-test:ls"
44
		podmanTest.BuildImage(LsDockerfile, image, "false")
45

46
		result := podmanTest.Podman([]string{"container", "runlabel", "RUN", image})
47
		result.WaitWithDefaultTimeout()
48
		Expect(result).Should(ExitCleanly())
49

50
		result = podmanTest.Podman([]string{"rmi", image})
51
		result.WaitWithDefaultTimeout()
52
		Expect(result).Should(ExitCleanly())
53
	})
54
	It("podman container runlabel --display", func() {
55
		image := "podman-runlabel-test:ls"
56
		podmanTest.BuildImage(LsDockerfile, image, "false")
57

58
		result := podmanTest.Podman([]string{"container", "runlabel", "--display", "RUN", image})
59
		result.WaitWithDefaultTimeout()
60
		Expect(result).Should(ExitCleanly())
61
		Expect(result.OutputToString()).To(ContainSubstring(podmanTest.PodmanBinary + " -la"))
62

63
		result = podmanTest.Podman([]string{"rmi", image})
64
		result.WaitWithDefaultTimeout()
65
		Expect(result).Should(ExitCleanly())
66
	})
67
	It("podman container runlabel bogus label should result in non-zero exit code", func() {
68
		result := podmanTest.Podman([]string{"container", "runlabel", "RUN", ALPINE})
69
		result.WaitWithDefaultTimeout()
70
		Expect(result).To(ExitWithError())
71
		// should not panic when label missing the value or don't have the label
72
		Expect(result.OutputToString()).To(Not(ContainSubstring("panic")))
73
	})
74
	It("podman container runlabel bogus label in remote image should result in non-zero exit", func() {
75
		result := podmanTest.Podman([]string{"container", "runlabel", "RUN", "docker.io/library/ubuntu:latest"})
76
		result.WaitWithDefaultTimeout()
77
		Expect(result).To(ExitWithError())
78
		// should not panic when label missing the value or don't have the label
79
		Expect(result.OutputToString()).To(Not(ContainSubstring("panic")))
80
	})
81

82
	It("runlabel should fail with nonexistent authfile", func() {
83
		image := "podman-runlabel-test:podman"
84
		podmanTest.BuildImage(PodmanDockerfile, image, "false")
85

86
		// runlabel should fail with nonexistent authfile
87
		result := podmanTest.Podman([]string{"container", "runlabel", "--authfile", "/tmp/nonexistent", "RUN", image})
88
		result.WaitWithDefaultTimeout()
89
		Expect(result).To(ExitWithError())
90

91
		result = podmanTest.Podman([]string{"rmi", image})
92
		result.WaitWithDefaultTimeout()
93
		Expect(result).Should(ExitCleanly())
94
	})
95

96
	It("podman container runlabel name removes tag from image", func() {
97
		image := "podman-runlabel-name:sometag"
98
		podmanTest.BuildImage(PodmanRunlabelNameDockerfile, image, "false")
99

100
		result := podmanTest.Podman([]string{"container", "runlabel", "--display", "RUN", image})
101
		result.WaitWithDefaultTimeout()
102
		Expect(result).Should(ExitCleanly())
103
		Expect(result.OutputToString()).To(Equal("command: " + podmanTest.PodmanBinary + " run --name podman-runlabel-name localhost/" + image))
104

105
		result = podmanTest.Podman([]string{"rmi", image})
106
		result.WaitWithDefaultTimeout()
107
		Expect(result).Should(ExitCleanly())
108
	})
109
})
110

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

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

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

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