From f31658ae29c20b4711977a974a918763e00ec25a Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Thu, 31 Oct 2024 12:18:56 -0400 Subject: [PATCH] tests --- .../tests/reports_deployment_test.yaml | 34 +++++++++ .../cryostat/tests/reports_secret_test.yaml | 39 ++++++++++ .../cryostat/tests/reports_service_test.yaml | 76 +++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 charts/cryostat/tests/reports_secret_test.yaml create mode 100644 charts/cryostat/tests/reports_service_test.yaml diff --git a/charts/cryostat/tests/reports_deployment_test.yaml b/charts/cryostat/tests/reports_deployment_test.yaml index d504264..6009512 100644 --- a/charts/cryostat/tests/reports_deployment_test.yaml +++ b/charts/cryostat/tests/reports_deployment_test.yaml @@ -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: @@ -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: diff --git a/charts/cryostat/tests/reports_secret_test.yaml b/charts/cryostat/tests/reports_secret_test.yaml new file mode 100644 index 0000000..df41781 --- /dev/null +++ b/charts/cryostat/tests/reports_secret_test.yaml @@ -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 diff --git a/charts/cryostat/tests/reports_service_test.yaml b/charts/cryostat/tests/reports_service_test.yaml new file mode 100644 index 0000000..4ba1dc4 --- /dev/null +++ b/charts/cryostat/tests/reports_service_test.yaml @@ -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