cw-infra-apps/grafana/charts/feature-integrations/tests/mysql_metrics_test.yaml

121 lines
3.3 KiB
YAML

# yamllint disable rule:document-start rule:line-length rule:trailing-spaces
suite: Test MySQL Integration - Metrics
templates:
- configmap.yaml
- mysql-secret.yaml
tests:
- it: should create the MySQL config
set:
deployAsConfigMap: true
mysql:
instances:
- name: my-database
exporter:
dataSource:
host: my-db.mysql.svc
auth:
username: db-admin
password: db-password
logs: {enabled: false}
asserts:
- template: configmap.yaml
isKind:
of: ConfigMap
- template: configmap.yaml
matchSnapshot:
path: data["metrics.alloy"]
- template: mysql-secret.yaml
documentIndex: 0
containsDocument:
apiVersion: v1
kind: Secret
name: my-database-release-name-feature-integrations
namespace: NAMESPACE
- template: mysql-secret.yaml
equal:
path: stringData.username
value: db-admin
- template: mysql-secret.yaml
equal:
path: stringData.password
value: db-password
- it: works with multiple MySQL Instances
set:
deployAsConfigMap: true
mysql:
instances:
- name: test-db
exporter:
dataSource:
host: database.test.svc
logs: {enabled: false}
- name: staging-db
exporter:
dataSourceName: "root:password@database.staging.svc:3306/"
logs: {enabled: false}
- name: prod-db
exporter:
dataSource:
host: database.prod.svc
auth:
username: db-admin
password: db-password
logs: {enabled: false}
asserts:
- template: configmap.yaml
isKind:
of: ConfigMap
- template: configmap.yaml
matchSnapshot:
path: data["metrics.alloy"]
- template: mysql-secret.yaml
hasDocuments:
count: 1 # Only one secret should be created
- template: mysql-secret.yaml
documentIndex: 0
containsDocument:
apiVersion: v1
kind: Secret
name: prod-db-release-name-feature-integrations
namespace: NAMESPACE
- template: mysql-secret.yaml
equal:
path: stringData.username
value: db-admin
- template: mysql-secret.yaml
equal:
path: stringData.password
value: db-password
- it: works when referencing the MySQL Secret
set:
deployAsConfigMap: true
mysql:
instances:
- name: test-database
exporter:
dataSource:
host: test-database-mysql.mysql.svc
auth:
usernameFrom: sys.env(MYSQL_ROOT_USER)
passwordKey: mysql-root-password
secret:
create: false
name: test-database-mysql
namespace: mysql
logs: {enabled: false}
asserts:
- template: configmap.yaml
isKind:
of: ConfigMap
- template: configmap.yaml
matchSnapshot:
path: data["metrics.alloy"]
- template: mysql-secret.yaml
hasDocuments:
count: 0 # No secret should be created