You've already forked prometheus-postgres-exporter
Initial Commit
This commit is contained in:
104
unittests/secrets/database.yaml
Normal file
104
unittests/secrets/database.yaml
Normal file
@ -0,0 +1,104 @@
|
||||
chart:
|
||||
appVersion: 0.1.0
|
||||
version: 0.1.0
|
||||
suite: Secret database template (basic)
|
||||
release:
|
||||
name: prometheus-postgres-exporter-unittest
|
||||
namespace: testing
|
||||
templates:
|
||||
- templates/prometheus-postgres-exporter/secretDatabase.yaml
|
||||
tests:
|
||||
- it: Skip rendering by using existing secret.
|
||||
set:
|
||||
config.database.existingSecret.enabled: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
||||
|
||||
- it: Expect error when no variable is defined.
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: No `databaseConnectionUrl` defined!
|
||||
|
||||
- it: Expect error when variable `databaseUsername` is not defined.
|
||||
set:
|
||||
# config.database.secret.databaseUsername: ""
|
||||
config.database.secret.databasePassword: "postgres"
|
||||
config.database.secret.databaseConnectionUrl: "localhost:5432/postgres?sslmode=disable"
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: No `databaseUsername` defined!
|
||||
|
||||
- it: Expect error when variable `databasePassword` is not defined.
|
||||
set:
|
||||
config.database.secret.databaseUsername: "postgres"
|
||||
# config.database.secret.databasePassword: "postgres"
|
||||
config.database.secret.databaseConnectionUrl: "localhost:5432/postgres?sslmode=disable"
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: No `databasePassword` defined!
|
||||
|
||||
- it: Expect error when variable `databaseConnectionUrl` is not defined.
|
||||
set:
|
||||
config.database.secret.databaseUsername: "postgres"
|
||||
config.database.secret.databasePassword: "postgres"
|
||||
# config.database.secret.databaseConnectionUrl: "localhost:5432/postgres?sslmode=disable"
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: No `databaseConnectionUrl` defined!
|
||||
|
||||
- it: Rendering database secret.
|
||||
set:
|
||||
config.database.secret.databaseUsername: "postgres"
|
||||
config.database.secret.databasePassword: "postgres"
|
||||
config.database.secret.databaseConnectionUrl: "localhost:5432/postgres?sslmode=disable"
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- containsDocument:
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
name: prometheus-postgres-exporter-unittest-database-env
|
||||
namespace: testing
|
||||
- notExists:
|
||||
path: metadata.annotations
|
||||
- equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: prometheus-postgres-exporter-unittest
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: prometheus-postgres-exporter
|
||||
app.kubernetes.io/version: 0.1.0
|
||||
helm.sh/chart: prometheus-postgres-exporter-0.1.0
|
||||
- equal:
|
||||
path: stringData.DATA_SOURCE_URI
|
||||
value: "localhost:5432/postgres?sslmode=disable"
|
||||
- equal:
|
||||
path: stringData.DATA_SOURCE_USER
|
||||
value: "postgres"
|
||||
- equal:
|
||||
path: stringData.DATA_SOURCE_PASS
|
||||
value: "postgres"
|
||||
|
||||
- it: Rendering custom annotations and labels.
|
||||
set:
|
||||
config.database.secret.annotations:
|
||||
foo: bar
|
||||
bar: foo
|
||||
config.database.secret.databaseUsername: "postgres"
|
||||
config.database.secret.databasePassword: "postgres"
|
||||
config.database.secret.databaseConnectionUrl: "localhost:5432/postgres?sslmode=disable"
|
||||
config.database.secret.labels:
|
||||
foo: bar
|
||||
bar: foo
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
foo: bar
|
||||
bar: foo
|
||||
- isSubset:
|
||||
path: metadata.labels
|
||||
content:
|
||||
foo: bar
|
||||
bar: foo
|
86
unittests/secrets/exporterConfig.yaml
Normal file
86
unittests/secrets/exporterConfig.yaml
Normal file
@ -0,0 +1,86 @@
|
||||
chart:
|
||||
appVersion: 0.1.0
|
||||
version: 0.1.0
|
||||
suite: Secret database template (basic)
|
||||
release:
|
||||
name: prometheus-postgres-exporter-unittest
|
||||
namespace: testing
|
||||
templates:
|
||||
- templates/prometheus-postgres-exporter/secretExporterConfig.yaml
|
||||
tests:
|
||||
- it: Skip rendering by using existing secret.
|
||||
set:
|
||||
config.exporterConfig.existingSecret.enabled: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
||||
|
||||
- it: Render secret, but with no value.
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- equal:
|
||||
path: stringData["exporterConfig.yaml"]
|
||||
value: |
|
||||
{}
|
||||
|
||||
- it: Rendering exporter config secret.
|
||||
set:
|
||||
config.exporterConfig.secret.exporterConfig:
|
||||
auth_modules:
|
||||
first:
|
||||
type: userpass
|
||||
userpass:
|
||||
username: first_username
|
||||
password: first_password
|
||||
options:
|
||||
sslmode: disable
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- containsDocument:
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
name: prometheus-postgres-exporter-unittest-exporter-config
|
||||
namespace: testing
|
||||
- notExists:
|
||||
path: metadata.annotations
|
||||
- equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: prometheus-postgres-exporter-unittest
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: prometheus-postgres-exporter
|
||||
app.kubernetes.io/version: 0.1.0
|
||||
helm.sh/chart: prometheus-postgres-exporter-0.1.0
|
||||
- equal:
|
||||
path: stringData["exporterConfig.yaml"]
|
||||
value: |
|
||||
auth_modules:
|
||||
first:
|
||||
options:
|
||||
sslmode: disable
|
||||
type: userpass
|
||||
userpass:
|
||||
password: first_password
|
||||
username: first_username
|
||||
|
||||
- it: Rendering custom annotations and labels.
|
||||
set:
|
||||
config.exporterConfig.secret.annotations:
|
||||
foo: bar
|
||||
bar: foo
|
||||
config.exporterConfig.secret.labels:
|
||||
foo: bar
|
||||
bar: foo
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
foo: bar
|
||||
bar: foo
|
||||
- isSubset:
|
||||
path: metadata.labels
|
||||
content:
|
||||
foo: bar
|
||||
bar: foo
|
81
unittests/secrets/webconfig.yaml
Normal file
81
unittests/secrets/webconfig.yaml
Normal file
@ -0,0 +1,81 @@
|
||||
chart:
|
||||
appVersion: 0.1.0
|
||||
version: 0.1.0
|
||||
suite: Secret database template (basic)
|
||||
release:
|
||||
name: prometheus-postgres-exporter-unittest
|
||||
namespace: testing
|
||||
templates:
|
||||
- templates/prometheus-postgres-exporter/secretWebConfig.yaml
|
||||
tests:
|
||||
- it: Skip rendering by using existing secret.
|
||||
set:
|
||||
config.webConfig.existingSecret.enabled: true
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
||||
|
||||
- it: Skip rendering when no webConfig.yaml is defined.
|
||||
set:
|
||||
config.webConfig.existingSecret.enabled: false
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
||||
|
||||
- it: Rendering database secret.
|
||||
set:
|
||||
config.webConfig.secret.webConfig:
|
||||
tls_server_config:
|
||||
cert_file: /path/to/cert.pem
|
||||
client_ca_file: /path/to/ca.pem
|
||||
key_file: /path/to/key.pem
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- containsDocument:
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
name: prometheus-postgres-exporter-unittest-webconfig
|
||||
namespace: testing
|
||||
- notExists:
|
||||
path: metadata.annotations
|
||||
- equal:
|
||||
path: metadata.labels
|
||||
value:
|
||||
app.kubernetes.io/instance: prometheus-postgres-exporter-unittest
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: prometheus-postgres-exporter
|
||||
app.kubernetes.io/version: 0.1.0
|
||||
helm.sh/chart: prometheus-postgres-exporter-0.1.0
|
||||
- equal:
|
||||
path: stringData["webConfig.yaml"]
|
||||
value: |
|
||||
tls_server_config:
|
||||
cert_file: /path/to/cert.pem
|
||||
client_ca_file: /path/to/ca.pem
|
||||
key_file: /path/to/key.pem
|
||||
|
||||
- it: Rendering custom annotations and labels.
|
||||
set:
|
||||
config.webConfig.secret.annotations:
|
||||
foo: bar
|
||||
bar: foo
|
||||
config.webConfig.secret.labels:
|
||||
foo: bar
|
||||
bar: foo
|
||||
config.webConfig.secret.webConfig:
|
||||
tls_server_config:
|
||||
cert_file: /path/to/cert.pem
|
||||
key_file: /path/to/key.pem
|
||||
client_ca_file: /path/to/ca.pem
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.annotations
|
||||
value:
|
||||
foo: bar
|
||||
bar: foo
|
||||
- isSubset:
|
||||
path: metadata.labels
|
||||
content:
|
||||
foo: bar
|
||||
bar: foo
|
Reference in New Issue
Block a user