podman

Форк
0
/
run_dns_test.go 
95 строк · 3.7 Кб
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
)
8

9
var _ = Describe("Podman run dns", func() {
10

11
	It("podman run add search domain", func() {
12
		session := podmanTest.Podman([]string{"run", "--dns-search=foobar.com", ALPINE, "cat", "/etc/resolv.conf"})
13
		session.WaitWithDefaultTimeout()
14
		Expect(session).Should(ExitCleanly())
15
		Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("search foobar.com")))
16
	})
17

18
	It("podman run remove all search domain", func() {
19
		session := podmanTest.Podman([]string{"run", "--dns-search=.", ALPINE, "cat", "/etc/resolv.conf"})
20
		session.WaitWithDefaultTimeout()
21
		Expect(session).Should(ExitCleanly())
22
		Expect(session.OutputToStringArray()).To(Not(ContainElement(HavePrefix("search"))))
23
	})
24

25
	It("podman run add bad dns server", func() {
26
		session := podmanTest.Podman([]string{"run", "--dns=foobar", ALPINE, "ls"})
27
		session.WaitWithDefaultTimeout()
28
		Expect(session).To(ExitWithError())
29
	})
30

31
	It("podman run add dns server", func() {
32
		session := podmanTest.Podman([]string{"run", "--dns=1.2.3.4", ALPINE, "cat", "/etc/resolv.conf"})
33
		session.WaitWithDefaultTimeout()
34
		Expect(session).Should(ExitCleanly())
35
		Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("nameserver 1.2.3.4")))
36

37
	})
38

39
	It("podman run add dns option", func() {
40
		session := podmanTest.Podman([]string{"run", "--dns-opt=debug", ALPINE, "cat", "/etc/resolv.conf"})
41
		session.WaitWithDefaultTimeout()
42
		Expect(session).Should(ExitCleanly())
43
		Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("options debug")))
44
	})
45

46
	It("podman run add bad host", func() {
47
		session := podmanTest.Podman([]string{"run", "--add-host=foo:1.2", ALPINE, "ls"})
48
		session.WaitWithDefaultTimeout()
49
		Expect(session).To(ExitWithError())
50
	})
51

52
	It("podman run add host", func() {
53
		session := podmanTest.Podman([]string{"run", "--add-host=foobar:1.1.1.1", "--add-host=foobaz:2001:db8::68", ALPINE, "cat", "/etc/hosts"})
54
		session.WaitWithDefaultTimeout()
55
		Expect(session).Should(ExitCleanly())
56
		Expect(session.OutputToStringArray()).To(ContainElements(HavePrefix("1.1.1.1\tfoobar"), HavePrefix("2001:db8::68\tfoobaz")))
57
	})
58

59
	It("podman run add hostname", func() {
60
		session := podmanTest.Podman([]string{"run", "--hostname=foobar", ALPINE, "cat", "/etc/hostname"})
61
		session.WaitWithDefaultTimeout()
62
		Expect(session).Should(ExitCleanly())
63
		Expect(session.OutputToString()).To(Equal("foobar"))
64

65
		session = podmanTest.Podman([]string{"run", "--hostname=foobar", ALPINE, "hostname"})
66
		session.WaitWithDefaultTimeout()
67
		Expect(session).Should(ExitCleanly())
68
		Expect(session.OutputToString()).To(Equal("foobar"))
69
	})
70

71
	It("podman run add hostname sets /etc/hosts", func() {
72
		session := podmanTest.Podman([]string{"run", "--hostname=foobar", ALPINE, "cat", "/etc/hosts"})
73
		session.WaitWithDefaultTimeout()
74
		Expect(session).Should(ExitCleanly())
75
		Expect(session.OutputToString()).To(ContainSubstring("foobar"))
76
	})
77

78
	It("podman run mutually excludes --dns* and --network", func() {
79
		session := podmanTest.Podman([]string{"run", "--dns=1.2.3.4", "--network", "container:ALPINE", ALPINE})
80
		session.WaitWithDefaultTimeout()
81
		Expect(session).To(ExitWithError())
82

83
		session = podmanTest.Podman([]string{"run", "--dns-opt=1.2.3.4", "--network", "container:ALPINE", ALPINE})
84
		session.WaitWithDefaultTimeout()
85
		Expect(session).To(ExitWithError())
86

87
		session = podmanTest.Podman([]string{"run", "--dns-search=foobar.com", "--network", "none", ALPINE})
88
		session.WaitWithDefaultTimeout()
89
		Expect(session).To(ExitWithError())
90

91
		session = podmanTest.Podman([]string{"run", "--dns=1.2.3.4", "--network", "host", ALPINE})
92
		session.WaitWithDefaultTimeout()
93
		Expect(session).Should(ExitCleanly())
94
	})
95
})
96

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

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

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

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