Skip to content

Commit

Permalink
chore: add tests for HPA
Browse files Browse the repository at this point in the history
  • Loading branch information
hspitzley-czi committed Nov 15, 2024
1 parent 5c28061 commit 37a0da8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
23 changes: 22 additions & 1 deletion stack/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,32 @@ tests:
path: spec
content:
revisionHistoryLimit: 3
any: true
- containsDocument:
apiVersion: apps/v1
kind: Deployment

- it: sets replicas when autoscaling is disabled
set:
services:
service1:
autoscaling:
enabled: false
replicaCount: 2
asserts:
- equal:
path: spec.replicas
value: 2
- it: does not set replicas when autoscaling is enabled
set:
services:
service1:
autoscaling:
enabled: true
replicaCount: 2
asserts:
- notExists:
path: spec.replicas

- it: uses httpGet probe by default
set:
services:
Expand Down
27 changes: 27 additions & 0 deletions stack/tests/hpa_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: test HorizontalPodAutoscaler
templates:
- hpa.yaml
tests:
- it: should work
set:
services:
service1:
args: ["arg1", "arg2"]
command: ["command1", "command2"]
autoscaling:
enabled: true
minReplicas: 2
maxReplicas: 10
maxUnavailable: 1
replicaCount: 2 # this should be ignored when autoscaling is enabled
asserts:
- containsDocument:
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
- equal:
path: spec.minReplicas
value: 2
- equal:
path: spec.maxReplicas
value: 10

0 comments on commit 37a0da8

Please sign in to comment.