Skip to content

Commit fd61b79

Browse files
committed
add tests for ingress
1 parent f7b2d16 commit fd61b79

File tree

1 file changed

+192
-0
lines changed

1 file changed

+192
-0
lines changed

tests/unit/ingress_test.yaml

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
---
2+
suite: Ingress
3+
templates:
4+
# primary template files
5+
- ingress.yaml
6+
7+
tests:
8+
- it: Ingress not present if disabled
9+
set:
10+
ingress:
11+
enabled: false
12+
asserts:
13+
- hasDocuments:
14+
count: 0
15+
16+
- it: Ingress is present when enabled without hosts (older k8s)
17+
capabilities:
18+
majorVersion: 1
19+
minorVersion: 18
20+
set:
21+
ingress:
22+
enabled: true
23+
hosts: []
24+
tls: []
25+
st2web:
26+
service:
27+
hostname: &st2web_hostname some-host-name
28+
release:
29+
name: st2ha
30+
asserts:
31+
- hasDocuments:
32+
count: 1
33+
- equal:
34+
path: kind
35+
value: Ingress
36+
# no ingress.hosts, so only st2web.hostname
37+
- equal: &st2web_rules_host
38+
path: spec.rules[0].host
39+
value: *st2web_hostname
40+
- contains: &one_host_path
41+
path: spec.rules[0].http.paths
42+
count: 1
43+
- equal: &host_path_is_root
44+
path: spec.rules[0].http.paths[0].path
45+
value: "/"
46+
- isNull:
47+
path: spec.rules[0].http.paths[0].pathType
48+
- equal:
49+
path: spec.rules[0].http.paths[0].backend
50+
value:
51+
serviceName: st2ha-st2web
52+
servicePort: 80
53+
54+
- it: Ingress is present when enabled without hosts (newer k8s)
55+
capabilities:
56+
# introduced in 1.19, stable in 1.22
57+
majorVersion: 1
58+
minorVersion: 19
59+
set:
60+
ingress:
61+
enabled: true
62+
hosts: []
63+
tls: []
64+
st2web:
65+
service:
66+
hostname: some-host-name
67+
release:
68+
name: st2ha
69+
asserts:
70+
- hasDocuments:
71+
count: 1
72+
- equal:
73+
path: kind
74+
value: Ingress
75+
# no ingress.hosts, so only st2web.hostname
76+
- equal: *st2web_rules_host
77+
- contains: *one_host_path
78+
- equal: *host_path_is_root
79+
- equal:
80+
path: spec.rules[0].http.paths[0].pathType
81+
value: Preix
82+
- equal:
83+
path: spec.rules[0].http.paths[0].backend
84+
value:
85+
service:
86+
name: st2ha-st2web
87+
port:
88+
number: 80
89+
90+
- it: Ingress is present when enabled with hosts (older k8s)
91+
capabilities:
92+
majorVersion: 1
93+
minorVersion: 18
94+
set:
95+
ingress:
96+
enabled: true
97+
hosts: &hosts
98+
- host: hostname.domain.tld
99+
paths:
100+
- serviceName: st2ha-st2web
101+
servicePort: 80
102+
- path: /fancy-sensor
103+
serviceName: fancy-sensor
104+
servicePort: 8080
105+
tls: []
106+
st2web:
107+
service:
108+
hostname: *st2web_hostname
109+
release:
110+
name: st2ha
111+
asserts:
112+
- hasDocuments:
113+
count: 1
114+
- equal:
115+
path: kind
116+
value: Ingress
117+
# no ingress.hosts, so only st2web.hostname
118+
- equal: *st2web_rules_host
119+
- contains: &two_host_paths
120+
path: spec.rules[0].http.paths
121+
count: 2
122+
- equal: &host_path_is_root_glob
123+
path: spec.rules[0].http.paths[0].path
124+
value: "/*"
125+
- isNull:
126+
path: spec.rules[0].http.paths[0].pathType
127+
- equal:
128+
path: spec.rules[0].http.paths[0].backend
129+
value:
130+
serviceName: st2ha-st2web
131+
servicePort: 80
132+
133+
- equal:
134+
path: spec.rules[0].http.paths[1].path
135+
value: "/fancy-sensor"
136+
- isNull:
137+
path: spec.rules[0].http.paths[1].pathType
138+
- equal:
139+
path: spec.rules[0].http.paths[1].backend
140+
value:
141+
serviceName: fancy-sensor
142+
servicePort: 8080
143+
144+
- it: Ingress is present when enabled with hosts (newer k8s)
145+
capabilities:
146+
# introduced in 1.19, stable in 1.22
147+
majorVersion: 1
148+
minorVersion: 19
149+
set:
150+
ingress:
151+
enabled: true
152+
hosts: *hosts
153+
tls: []
154+
st2web:
155+
service:
156+
hostname: some-host-name
157+
release:
158+
name: st2ha
159+
asserts:
160+
- hasDocuments:
161+
count: 1
162+
- equal:
163+
path: kind
164+
value: Ingress
165+
# no ingress.hosts, so only st2web.hostname
166+
- equal: *st2web_rules_host
167+
- contains: *two_host_paths
168+
- equal: *host_path_is_root_glob
169+
- equal:
170+
path: spec.rules[0].http.paths[0].pathType
171+
value: Preix
172+
- equal:
173+
path: spec.rules[0].http.paths[0].backend
174+
value:
175+
service:
176+
name: st2ha-st2web
177+
port:
178+
number: 80
179+
180+
- equal:
181+
path: spec.rules[0].http.paths[1].path
182+
value: "/fancy-sensor"
183+
- equal:
184+
path: spec.rules[0].http.paths[1].pathType
185+
value: Preix
186+
- equal:
187+
path: spec.rules[0].http.paths[1].backend
188+
value:
189+
service:
190+
name: fancy-sensor
191+
port:
192+
number: 8080

0 commit comments

Comments
 (0)