Skip to content

Commit 18fd081

Browse files
committed
Added helm tests.
1 parent 1bee190 commit 18fd081

File tree

1 file changed

+216
-0
lines changed

1 file changed

+216
-0
lines changed
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
suite: pgstac configuration tests
2+
templates:
3+
- templates/pgstacbootstrap/configmap.yaml
4+
- templates/pgstacbootstrap/queue-processor.yaml
5+
- templates/pgstacbootstrap/extent-updater.yaml
6+
tests:
7+
# PgSTAC Settings Tests
8+
- it: should apply custom pgstac settings
9+
set:
10+
pgstacBootstrap:
11+
enabled: true
12+
settings:
13+
pgstacSettings:
14+
queue_timeout: "30 minutes"
15+
use_queue: "false"
16+
update_collection_extent: "true"
17+
context: "on"
18+
context_estimated_count: "50000"
19+
template: templates/pgstacbootstrap/configmap.yaml
20+
documentIndex: 0
21+
asserts:
22+
- matchRegex:
23+
path: data["pgstac-settings.sql"]
24+
pattern: "VALUES \\('queue_timeout', '30 minutes'\\)"
25+
- matchRegex:
26+
path: data["pgstac-settings.sql"]
27+
pattern: "VALUES \\('use_queue', 'false'\\)"
28+
- matchRegex:
29+
path: data["pgstac-settings.sql"]
30+
pattern: "VALUES \\('update_collection_extent', 'true'\\)"
31+
- matchRegex:
32+
path: data["pgstac-settings.sql"]
33+
pattern: "VALUES \\('context_estimated_count', '50000'\\)"
34+
35+
- it: should use default pgstac settings
36+
set:
37+
pgstacBootstrap:
38+
enabled: true
39+
template: templates/pgstacbootstrap/configmap.yaml
40+
documentIndex: 0
41+
asserts:
42+
- matchRegex:
43+
path: data["pgstac-settings.sql"]
44+
pattern: "VALUES \\('queue_timeout', '10 minutes'\\)"
45+
- matchRegex:
46+
path: data["pgstac-settings.sql"]
47+
pattern: "VALUES \\('use_queue', 'true'\\)"
48+
- matchRegex:
49+
path: data["pgstac-settings.sql"]
50+
pattern: "VALUES \\('update_collection_extent', 'false'\\)"
51+
52+
# Queue Processor Tests
53+
- it: should create queue processor when use_queue is true
54+
set:
55+
pgstacBootstrap:
56+
enabled: true
57+
settings:
58+
pgstacSettings:
59+
use_queue: "true"
60+
template: templates/pgstacbootstrap/queue-processor.yaml
61+
asserts:
62+
- hasDocuments:
63+
count: 1
64+
- isKind:
65+
of: CronJob
66+
- equal:
67+
path: metadata.name
68+
value: RELEASE-NAME-pgstac-queue-processor
69+
- equal:
70+
path: spec.schedule
71+
value: "0 * * * *"
72+
73+
- it: should NOT create queue processor when use_queue is false
74+
set:
75+
pgstacBootstrap:
76+
enabled: true
77+
settings:
78+
pgstacSettings:
79+
use_queue: "false"
80+
template: templates/pgstacbootstrap/queue-processor.yaml
81+
asserts:
82+
- hasDocuments:
83+
count: 0
84+
85+
- it: should use custom queue processor schedule
86+
set:
87+
pgstacBootstrap:
88+
enabled: true
89+
settings:
90+
pgstacSettings:
91+
use_queue: "true"
92+
queueProcessor:
93+
schedule: "*/15 * * * *"
94+
command: "SELECT custom_queue_function();"
95+
template: templates/pgstacbootstrap/queue-processor.yaml
96+
asserts:
97+
- equal:
98+
path: spec.schedule
99+
value: "*/15 * * * *"
100+
- matchRegex:
101+
path: spec.jobTemplate.spec.template.spec.containers[0].command[2]
102+
pattern: "SELECT custom_queue_function\\(\\);"
103+
104+
# Extent Updater Tests
105+
- it: should create extent updater when update_collection_extent is false
106+
set:
107+
pgstacBootstrap:
108+
enabled: true
109+
settings:
110+
pgstacSettings:
111+
update_collection_extent: "false"
112+
template: templates/pgstacbootstrap/extent-updater.yaml
113+
asserts:
114+
- hasDocuments:
115+
count: 1
116+
- isKind:
117+
of: CronJob
118+
- equal:
119+
path: metadata.name
120+
value: RELEASE-NAME-pgstac-extent-updater
121+
- equal:
122+
path: spec.schedule
123+
value: "0 2 * * *"
124+
125+
- it: should NOT create extent updater when update_collection_extent is true
126+
set:
127+
pgstacBootstrap:
128+
enabled: true
129+
settings:
130+
pgstacSettings:
131+
update_collection_extent: "true"
132+
template: templates/pgstacbootstrap/extent-updater.yaml
133+
asserts:
134+
- hasDocuments:
135+
count: 0
136+
137+
- it: should use custom extent updater schedule
138+
set:
139+
pgstacBootstrap:
140+
enabled: true
141+
settings:
142+
pgstacSettings:
143+
update_collection_extent: "false"
144+
extentUpdater:
145+
schedule: "0 */6 * * *"
146+
command: "SELECT custom_extent_function();"
147+
template: templates/pgstacbootstrap/extent-updater.yaml
148+
asserts:
149+
- equal:
150+
path: spec.schedule
151+
value: "0 */6 * * *"
152+
- matchRegex:
153+
path: spec.jobTemplate.spec.template.spec.containers[0].command[2]
154+
pattern: "SELECT custom_extent_function\\(\\);"
155+
156+
# Combined scenario tests
157+
- it: should create both cronjobs with proper settings
158+
set:
159+
pgstacBootstrap:
160+
enabled: true
161+
settings:
162+
pgstacSettings:
163+
use_queue: "true"
164+
update_collection_extent: "false"
165+
templates:
166+
- templates/pgstacbootstrap/queue-processor.yaml
167+
- templates/pgstacbootstrap/extent-updater.yaml
168+
asserts:
169+
- hasDocuments:
170+
count: 1
171+
- isKind:
172+
of: CronJob
173+
174+
- it: should not create any cronjobs when disabled
175+
set:
176+
pgstacBootstrap:
177+
enabled: false
178+
templates:
179+
- templates/pgstacbootstrap/queue-processor.yaml
180+
- templates/pgstacbootstrap/extent-updater.yaml
181+
asserts:
182+
- hasDocuments:
183+
count: 0
184+
185+
# Resource limits tests
186+
- it: should set correct resource limits for queue processor
187+
set:
188+
pgstacBootstrap:
189+
enabled: true
190+
settings:
191+
pgstacSettings:
192+
use_queue: "true"
193+
template: templates/pgstacbootstrap/queue-processor.yaml
194+
asserts:
195+
- equal:
196+
path: spec.jobTemplate.spec.template.spec.containers[0].resources.limits.cpu
197+
value: "256m"
198+
- equal:
199+
path: spec.jobTemplate.spec.template.spec.containers[0].resources.limits.memory
200+
value: "512Mi"
201+
202+
- it: should set correct resource limits for extent updater
203+
set:
204+
pgstacBootstrap:
205+
enabled: true
206+
settings:
207+
pgstacSettings:
208+
update_collection_extent: "false"
209+
template: templates/pgstacbootstrap/extent-updater.yaml
210+
asserts:
211+
- equal:
212+
path: spec.jobTemplate.spec.template.spec.containers[0].resources.limits.cpu
213+
value: "512m"
214+
- equal:
215+
path: spec.jobTemplate.spec.template.spec.containers[0].resources.limits.memory
216+
value: "1024Mi"

0 commit comments

Comments
 (0)