# What this PR does ## Issue At the first run (`helm install ...`) the migration job cannot start the container because cannot find Postgres/Redis/MySQL credentials and ServiceAccount. Workaround: set `.migrate.useHook` value to `false` for the `install` stage, and after you can switch back to `true`. This PR completely resolves this issue. ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated (doesn't violate anything) - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required) - [x] It is manually tested in the internal environment --------- Co-authored-by: Joey Orlando <joey.orlando@grafana.com> Co-authored-by: Joey Orlando <joseph.t.orlando@gmail.com>
296 lines
8.6 KiB
YAML
296 lines
8.6 KiB
YAML
suite: test Rabbitmq configs for deployments
|
|
templates:
|
|
- engine/deployment.yaml
|
|
- engine/job-migrate.yaml
|
|
- celery/deployment.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.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.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.yaml
|
|
set:
|
|
broker.type: rabbitmq
|
|
rabbitmq.enabled: false
|
|
asserts:
|
|
- failedTemplate:
|
|
errorMessage: externalRabbitmq.user is required if not rabbitmq.enabled
|
|
template: engine/job-migrate.yaml
|
|
|
|
- it: rabbitmq.enabled=false -> should use internal custom values
|
|
templates:
|
|
- engine/deployment.yaml
|
|
- engine/job-migrate.yaml
|
|
- celery/deployment.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: rabbitmq-password
|
|
name: oncall-rabbitmq-external
|
|
- containsDocument:
|
|
kind: Secret
|
|
apiVersion: v1
|
|
metadata.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.yaml
|
|
set:
|
|
broker.type: rabbitmq
|
|
rabbitmq.enabled: false
|
|
externalRabbitmq:
|
|
host: some-rabbitmq-host
|
|
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: some-rabbitmq-host
|
|
- 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 host is missing
|
|
templates:
|
|
- engine/deployment.yaml
|
|
- engine/job-migrate.yaml
|
|
- celery/deployment.yaml
|
|
set:
|
|
broker.type: rabbitmq
|
|
rabbitmq.enabled: false
|
|
externalRabbitmq:
|
|
existingSecret: existing-secret
|
|
passwordKey: password-key
|
|
asserts:
|
|
- failedTemplate:
|
|
errorMessage: externalRabbitmq.host is required if not rabbitmq.enabled
|
|
template: engine/job-migrate.yaml
|
|
|
|
- it: |
|
|
rabbitmq.enabled=false and migrate.useHook=>true -> should add "helm.sh/hook" annotations
|
|
to secret with rabbitmq credentials
|
|
templates:
|
|
- secrets.yaml
|
|
set:
|
|
migrate.useHook: true
|
|
broker.type: rabbitmq
|
|
rabbitmq.enabled: false
|
|
externalRabbitmq:
|
|
host: rabbitmq-host
|
|
user: user
|
|
password: password
|
|
asserts:
|
|
- containsDocument:
|
|
kind: Secret
|
|
apiVersion: v1
|
|
name: oncall-rabbitmq-external
|
|
documentIndex: 1
|
|
- isSubset:
|
|
path: metadata.annotations
|
|
content:
|
|
"helm.sh/hook": pre-install,pre-upgrade
|
|
"helm.sh/hook-weight": "-5"
|
|
documentIndex: 1
|