oncall-engine/helm/oncall/tests/postgres_env_test.yaml
Sergei Kuzmin 370d7b9867
Secrets consistency for the chart (#1016)
- Enabling existing secrets for external MySQL and Redis
- Tolerate existing secrets for bundled charts.
- README.md: secrets handling explained.
- Fixed multiple bugs where missing required field was replaced with
default instead of failing.
- PHONE_NOTIFICATIONS_LIMIT was on the wrong level: it was not set if
existingSecret was true.

Next are the cosmetic changes. They improve chart consistency, e.g.
prevent generation of multiple new lines in certain cases:
- Common approach to spaces trimming. This typically allows curly blocks
and actual strings indentation and nice `nindent` usage:
- Two curly blocks should not trim the same space. I.e. "{{ ... -}} {{-
... }}" shouldn't happen.
- Template generates either single line or multiline string. In both
cases, no new line appears on both sides of the output string. So we
delete unnecessary new lines inside and at the end of string with
"trim-to-left" (`{{-` ) and the leading new line using "trim-to-right"
(`-}}`).
Note that trimming both leading and trailing new line is not always
easily possible: https://github.com/Masterminds/sprig/issues/357

    Example.

    ```
    {{- define "mytemplate" -}}
    {{ if someBoolean -}}
      {{ .Value.some }}
    {{- else -}}
      some string
    {{- end }}
    {{- end }}
    ```

- `template` replaced with `include`. It is often recommended to use
`include` by default, as it allows pipelining.

## Checklist

- [ ] Tests updated - No tests for Helm chart
- [X] Documentation added
- [x] `CHANGELOG.md` updated

Co-authored-by: Ildar Iskhakov <Ildar.iskhakov@grafana.com>
2023-06-23 05:43:05 +00:00

141 lines
4 KiB
YAML

suite: test PostgreSQL envs for deployments
templates:
- engine/deployment.yaml
- engine/job-migrate.yaml
- celery/deployment-celery.yaml
release:
name: oncall
tests:
- it: postgresql.enabled=false -> external PostgreSQL default settings
set:
database.type: postgresql
postgresql.enabled: false
externalPostgresql.host: custom-postgres-host
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_TYPE
value: postgresql
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_NAME
value: oncall
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_PORT
value: "5432"
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_USER
value: postgres
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_HOST
value: custom-postgres-host
- it: externalPostgresql -> should use external PostgreSQL custom settings
set:
database.type: postgresql
postgresql.enabled: false
externalPostgresql:
host: test-host
port: 5555
db_name: grafana_oncall
user: test_user
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_TYPE
value: postgresql
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_NAME
value: grafana_oncall
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_PORT
value: "5555"
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_USER
value: test_user
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_HOST
value: test-host
- it: postgresql.enabled=true -> internal PostgreSQL default settings
set:
database.type: postgresql
postgresql.enabled: true
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_TYPE
value: postgresql
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_NAME
value: oncall
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_PORT
value: "5432"
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_USER
value: postgres
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_HOST
value: oncall-postgresql
- it: postgresql.auth -> should use internal PostgreSQL custom settings
set:
database.type: postgresql
postgresql:
enabled: true
auth:
database: grafana_oncall
username: grafana_oncall
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_TYPE
value: postgresql
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_NAME
value: grafana_oncall
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_PORT
value: "5432"
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_USER
value: grafana_oncall
- contains:
path: spec.template.spec.containers[0].env
content:
name: DATABASE_HOST
value: oncall-postgresql