podman

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

3
import (
4
	. "github.com/containers/podman/v5/test/utils"
5
	. "github.com/onsi/ginkgo/v2"
6
	. "github.com/onsi/gomega"
7
	. "github.com/onsi/gomega/gexec"
8
)
9

10
var _ = Describe("Podman run entrypoint", func() {
11

12
	It("podman run no command, entrypoint, or cmd", func() {
13
		dockerfile := `FROM quay.io/libpod/alpine:latest
14
ENTRYPOINT []
15
CMD []
16
`
17
		podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
18
		session := podmanTest.Podman([]string{"run", "foobar.com/entrypoint:latest"})
19
		session.WaitWithDefaultTimeout()
20
		Expect(session).Should(Or(Exit(126), Exit(127)))
21
	})
22

23
	It("podman run entrypoint == [\"\"]", func() {
24
		dockerfile := `FROM quay.io/libpod/alpine:latest
25
ENTRYPOINT [""]
26
CMD []
27
`
28
		podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
29
		session := podmanTest.Podman([]string{"run", "foobar.com/entrypoint:latest", "echo", "hello"})
30
		session.WaitWithDefaultTimeout()
31
		Expect(session).Should(ExitCleanly())
32
		Expect(session.OutputToString()).To(Equal("hello"))
33
	})
34

35
	It("podman run entrypoint", func() {
36
		dockerfile := `FROM quay.io/libpod/alpine:latest
37
ENTRYPOINT ["grep", "Alpine", "/etc/os-release"]
38
`
39
		podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
40
		session := podmanTest.Podman([]string{"run", "foobar.com/entrypoint:latest"})
41
		session.WaitWithDefaultTimeout()
42
		Expect(session).Should(ExitCleanly())
43
		Expect(session.OutputToStringArray()).To(HaveLen(2))
44
	})
45

46
	It("podman run entrypoint with cmd", func() {
47
		dockerfile := `FROM quay.io/libpod/alpine:latest
48
CMD [ "-v"]
49
ENTRYPOINT ["grep", "Alpine", "/etc/os-release"]
50
`
51
		podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
52
		session := podmanTest.Podman([]string{"run", "foobar.com/entrypoint:latest"})
53
		session.WaitWithDefaultTimeout()
54
		Expect(session).Should(ExitCleanly())
55
		Expect(session.OutputToStringArray()).To(HaveLen(4))
56
	})
57

58
	It("podman run entrypoint with user cmd overrides image cmd", func() {
59
		dockerfile := `FROM quay.io/libpod/alpine:latest
60
CMD [ "-v"]
61
ENTRYPOINT ["grep", "Alpine", "/etc/os-release"]
62
`
63
		podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
64
		session := podmanTest.Podman([]string{"run", "foobar.com/entrypoint:latest", "-i"})
65
		session.WaitWithDefaultTimeout()
66
		Expect(session).Should(ExitCleanly())
67
		Expect(session.OutputToStringArray()).To(HaveLen(5))
68
	})
69

70
	It("podman run entrypoint with user cmd no image cmd", func() {
71
		dockerfile := `FROM quay.io/libpod/alpine:latest
72
ENTRYPOINT ["grep", "Alpine", "/etc/os-release"]
73
`
74
		podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
75
		session := podmanTest.Podman([]string{"run", "foobar.com/entrypoint:latest", "-i"})
76
		session.WaitWithDefaultTimeout()
77
		Expect(session).Should(ExitCleanly())
78
		Expect(session.OutputToStringArray()).To(HaveLen(5))
79
	})
80

81
	It("podman run user entrypoint overrides image entrypoint and image cmd", func() {
82
		dockerfile := `FROM quay.io/libpod/alpine:latest
83
CMD ["-i"]
84
ENTRYPOINT ["grep", "Alpine", "/etc/os-release"]
85
`
86
		podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
87
		session := podmanTest.Podman([]string{"run", "--entrypoint=uname", "foobar.com/entrypoint:latest"})
88
		session.WaitWithDefaultTimeout()
89
		Expect(session).Should(ExitCleanly())
90
		Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("Linux")))
91

92
		session = podmanTest.Podman([]string{"run", "--entrypoint", "", "foobar.com/entrypoint:latest", "uname"})
93
		session.WaitWithDefaultTimeout()
94
		Expect(session).Should(ExitCleanly())
95
		Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("Linux")))
96
	})
97

98
	It("podman run user entrypoint with command overrides image entrypoint and image cmd", func() {
99
		dockerfile := `FROM quay.io/libpod/alpine:latest
100
CMD ["-i"]
101
ENTRYPOINT ["grep", "Alpine", "/etc/os-release"]
102
`
103
		podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
104
		session := podmanTest.Podman([]string{"run", "--entrypoint=uname", "foobar.com/entrypoint:latest", "-r"})
105
		session.WaitWithDefaultTimeout()
106
		Expect(session).Should(ExitCleanly())
107
		Expect(session.OutputToStringArray()).To(Not(ContainElement(HavePrefix("Linux"))))
108
	})
109
})
110

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

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

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

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