Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add tests for HPA #171

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading