Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Oct 31, 2024
1 parent d447f06 commit f31658a
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 0 deletions.
34 changes: 34 additions & 0 deletions charts/cryostat/tests/reports_deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ tests:
reports:
replicas: 1
asserts:
- exists:
path: spec.template.spec.containers[?(@.name=='cryostat-reports-authproxy')]
- equal:
path: spec.template.spec.containers[?(@.name=='cryostat-reports-authproxy')].image
value: "quay.io/oauth2-proxy/oauth2-proxy:latest"
- equal:
path: spec.template.spec.containers[?(@.name=='cryostat-reports-authproxy')].ports
value:
- containerPort: 4180
name: http
protocol: TCP
- exists:
path: spec.template.spec.containers[?(@.name=='cryostat-reports')]
- equal:
Expand All @@ -70,6 +81,29 @@ tests:
path: spec.template.spec.containers[?(@.name=='cryostat-reports')].env[?(@.name=='QUARKUS_HTTP_PORT')].value
value: "10001"

- it: should validate authproxy settings when deployed in OpenShift
set:
reports:
replicas: 1
authentication:
openshift:
enabled: true
asserts:
- exists:
path: spec.template.spec.containers[?(@.name=='cryostat-reports-authproxy')]
- equal:
path: spec.template.spec.containers[?(@.name=='cryostat-reports-authproxy')].image
value: "quay.io/cryostat/openshift-oauth-proxy:cryostat-v3.0"
- equal:
path: spec.template.spec.containers[?(@.name=='cryostat-reports-authproxy')].ports
value:
- containerPort: 4180
name: http
protocol: TCP
- containerPort: 8443
name: https
protocol: TCP

- it: should apply Kubernetes specific settings when configured
set:
reports:
Expand Down
39 changes: 39 additions & 0 deletions charts/cryostat/tests/reports_secret_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
suite: test reports_secret.yaml
templates:
- reports_secret.yaml

tests:
- it: should create a reports secret if core.reportsSecretName is not set
set:
core.reportsSecretName: ""
asserts:
- hasDocuments:
count: 1
- equal:
path: kind
value: Secret
- equal:
path: metadata.name
value: RELEASE-NAME-reports-secret
- equal:
path: type
value: Opaque
- exists:
path: data.htpasswd
- exists:
path: data.REPORTS_PASS
- equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: cryostat
app.kubernetes.io/version: 4.0.0-dev
helm.sh/chart: cryostat-2.0.0-dev

- it: should not create a database secret if reports.reportsSecretName is set
set:
reports.reportsSecretName: "custom-reports-secret"
asserts:
- hasDocuments:
count: 0
76 changes: 76 additions & 0 deletions charts/cryostat/tests/reports_service_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
suite: test reports_service.yaml
templates:
- reports_service.yaml

tests:
- it: should do nothing if report generators are not desired
asserts:
- hasDocuments:
count: 0

- it: should create a Service targeting the Pod http port
set:
reports:
replicas: 1
asserts:
- hasDocuments:
count: 1
- equal:
path: kind
value: Service
- equal:
path: metadata.name
value: RELEASE-NAME-cryostat-reports
- equal:
path: spec.type
value: ClusterIP
- equal:
path: spec.ports[0].port
value: 10001
- equal:
path: spec.ports[0].targetPort
value: http
- equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: cryostat
app.kubernetes.io/version: "4.0.0-dev"
helm.sh/chart: cryostat-2.0.0-dev
app.kubernetes.io/component: reports

- it: should create a Service targeting the Pod https port when deployed in OpenShift
set:
reports:
replicas: 1
authentication:
openshift:
enabled: true
asserts:
- hasDocuments:
count: 1
- equal:
path: kind
value: Service
- equal:
path: metadata.name
value: RELEASE-NAME-cryostat-reports
- equal:
path: spec.type
value: ClusterIP
- equal:
path: spec.ports[0].port
value: 10001
- equal:
path: spec.ports[0].targetPort
value: https
- equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: cryostat
app.kubernetes.io/version: "4.0.0-dev"
helm.sh/chart: cryostat-2.0.0-dev
app.kubernetes.io/component: reports

0 comments on commit f31658a

Please sign in to comment.