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

Add helm tests for rabbitmq and redis #2165

Merged
merged 4 commits into from
Jun 13, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix receive channel filter in alert groups API [#2140](https://github.com/grafana/oncall/pull/2140)
- Helm chart: Fix usage of `env` settings as map;
Fix usage of `mariadb.auth.database` and `mariadb.auth.username` for MYSQL env variables by @alexintech [#2146](https://github.com/grafana/oncall/pull/2146)

### Added

- Helm chart: Add unittests for rabbitmq and redis [2165](https://github.com/grafana/oncall/pull/2165)

## v1.2.41 (2023-06-08)

Expand Down
254 changes: 254 additions & 0 deletions helm/oncall/tests/rabbitmq_env_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
suite: test Rabbitmq configs for deployments
templates:
- engine/deployment.yaml
- engine/job-migrate.yaml
- celery/deployment-celery.yaml
- secrets.yaml
release:
name: oncall
tests:
- it: rabbitmq.enabled=true -> should use default values from rabbitmq subchart
templates:
- engine/deployment.yaml
- engine/job-migrate.yaml
- celery/deployment-celery.yaml
set:
broker.type: rabbitmq
rabbitmq.enabled: true
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BROKER_TYPE
value: rabbitmq
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_USERNAME
value: user
- contains:
path: spec.template.spec.containers[0].env
content:
name: BROKER_TYPE
value: rabbitmq
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
key: rabbitmq-password
name: oncall-rabbitmq
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_HOST
value: oncall-rabbitmq
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_PORT
value: "5672"
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_PROTOCOL
value: amqp
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_VHOST
value: ""

- it: rabbitmq.enabled=true -> should use custom auth values from rabbitmq subchart
templates:
- engine/deployment.yaml
- engine/job-migrate.yaml
- celery/deployment-celery.yaml
set:
broker.type: rabbitmq
rabbitmq.enabled: true
rabbitmq:
auth:
username: test_user
password: test_password
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BROKER_TYPE
value: rabbitmq
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_USERNAME
value: user
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
key: rabbitmq-password
name: oncall-rabbitmq
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_HOST
value: oncall-rabbitmq
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_PORT
value: "5672"
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_PROTOCOL
value: amqp
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_VHOST
value: ""

- it: rabbitmq.enabled=false -> should fail if not externalRabbitmq.existingSecret or not externalRabbitmq.password
templates:
- engine/deployment.yaml
- engine/job-migrate.yaml
- celery/deployment-celery.yaml
set:
broker.type: rabbitmq
rabbitmq.enabled: false
asserts:
- failedTemplate:
errorMessage: externalRabbitmq.password is required if not rabbitmq.enabled and not externalRabbitmq.existingSecret
template: secrets.yaml

- it: rabbitmq.enabled=false -> should use internal custom values
templates:
- engine/deployment.yaml
- engine/job-migrate.yaml
- celery/deployment-celery.yaml
set:
broker.type: rabbitmq
rabbitmq.enabled: false
externalRabbitmq:
host: custom-host
port: custom-port
user: custom-user
password: custom-password
protocol: custom-protocol
vhost: custom-vhost
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: BROKER_TYPE
value: rabbitmq
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_USERNAME
value: custom-user
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_HOST
value: custom-host
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_PORT
value: custom-port
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_PROTOCOL
value: custom-protocol
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_VHOST
value: custom-vhost
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: oncall-rabbitmq-external
- containsDocument:
kind: Secret
apiVersion: v1
name: oncall-rabbitmq-external
template: secrets.yaml
- equal:
path: data.rabbitmq-password
value: custom-password
decodeBase64: true
documentIndex: 1
template: secrets.yaml

- it: rabbitmq.enabled=false -> should use default internal values and auth from existing secret
templates:
- engine/deployment.yaml
- engine/job-migrate.yaml
- celery/deployment-celery.yaml
set:
broker.type: rabbitmq
rabbitmq.enabled: false
externalRabbitmq:
existingSecret: existing-secret
passwordKey: password-key
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: existing-secret
key: password-key
- contains:
path: spec.template.spec.containers[0].env
content:
name: BROKER_TYPE
value: rabbitmq
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_USERNAME
valueFrom:
secretKeyRef:
key: username
name: existing-secret
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
key: password-key
name: existing-secret
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_HOST
value: oncall-rabbitmq
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_PORT
value: "5672"
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_PROTOCOL
value: amqp
- contains:
path: spec.template.spec.containers[0].env
content:
name: RABBITMQ_VHOST
value: ""
Loading