Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pmacius committed Oct 14, 2024
1 parent 9e4b427 commit b3e284e
Show file tree
Hide file tree
Showing 5 changed files with 352 additions and 0 deletions.
198 changes: 198 additions & 0 deletions charts/alfresco-audit-storage/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
suite: test configmaps
templates:
- deployment.yaml
tests:
- it: should have default image pull secret
asserts:
- equal:
path: spec.template.spec.imagePullSecrets[0].name
value: quay-registry-secret
- it: should have default securityContext
asserts:
- equal:
path: spec.template.spec.securityContext
value:
runAsUser: 33000
runAsGroup: 1000
fsGroup: 1000
- it: should have default container name
asserts:
- equal:
path: spec.template.spec.containers[0].name
value: alfresco-audit-storage
- it: should have custom container image
set:
image:
repository: "custom-repo"
tag: "custom-tag"
asserts:
- equal:
path: spec.template.spec.containers[0].image
value: "custom-repo:custom-tag"
- it: should have custom imagePullPolicy
set:
image:
pullPolicy: "Always"
asserts:
- equal:
path: spec.template.spec.containers[0].imagePullPolicy
value: "Always"
- it: should have default securityContext
asserts:
- equal:
path: spec.template.spec.containers[0].securityContext
value:
runAsNonRoot: true
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
- it: should have default ports section
asserts:
- equal:
path: spec.template.spec.containers[0].ports[0]
value:
containerPort: 8081
name: http
protocol: TCP
- it: should have envs section with external cm and secrets
set:
messageBrokerConnection:
existingConfigMap:
name: mq-external-config
keys:
url: BROKER_URL_EXTERNAL
existingSecret:
name: mq-external-secret
keys:
username: BROKER_USERNAME_EXTERNAL
password: BROKER_PASSWORD_EXTERNAL
elasticSearchConnection:
existingConfigMap:
name: es-external-config
keys:
url: SEARCH_URL_EXTERNAL
existingSecret:
name: es-external-secret
keys:
username: SEARCH_USERNAME_EXTERNAL
password: SEARCH_PASSWORD_EXTERNAL
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: SPRING_ACTIVEMQ_USER
valueFrom:
secretKeyRef:
key: BROKER_USERNAME_EXTERNAL
name: mq-external-secret
- contains:
path: spec.template.spec.containers[0].env
content:
name: SPRING_ACTIVEMQ_PASSWORD
valueFrom:
secretKeyRef:
key: BROKER_PASSWORD_EXTERNAL
name: mq-external-secret
- contains:
path: spec.template.spec.containers[0].env
content:
name: SPRING_ACTIVEMQ_BROKERURL
valueFrom:
configMapKeyRef:
key: BROKER_URL_EXTERNAL
name: mq-external-config
- contains:
path: spec.template.spec.containers[0].env
content:
name: AUDIT_ENTRYSTORAGE_OPENSEARCH_CONNECTOR_USERNAME
valueFrom:
secretKeyRef:
key: SEARCH_USERNAME_EXTERNAL
name: es-external-secret
- contains:
path: spec.template.spec.containers[0].env
content:
name: AUDIT_ENTRYSTORAGE_OPENSEARCH_CONNECTOR_PASSWORD
valueFrom:
secretKeyRef:
key: SEARCH_PASSWORD_EXTERNAL
name: es-external-secret
- contains:
path: spec.template.spec.containers[0].env
content:
name: AUDIT_ENTRYSTORAGE_OPENSEARCH_CONNECTOR_URI
valueFrom:
configMapKeyRef:
key: SEARCH_URL_EXTERNAL
name: es-external-config
- it: should contain default envs
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: SPRING_ACTIVEMQ_USER
valueFrom:
secretKeyRef:
key: BROKER_USERNAME
name: RELEASE-NAME-alfresco-audit-storage-mq
- contains:
path: spec.template.spec.containers[0].env
content:
name: SPRING_ACTIVEMQ_PASSWORD
valueFrom:
secretKeyRef:
key: BROKER_PASSWORD
name: RELEASE-NAME-alfresco-audit-storage-mq
- contains:
path: spec.template.spec.containers[0].env
content:
name: SPRING_ACTIVEMQ_BROKERURL
valueFrom:
configMapKeyRef:
key: BROKER_URL
name: RELEASE-NAME-alfresco-audit-storage-mq
- contains:
path: spec.template.spec.containers[0].env
content:
name: AUDIT_ENTRYSTORAGE_OPENSEARCH_CONNECTOR_USERNAME
valueFrom:
secretKeyRef:
key: SEARCH_USERNAME
name: RELEASE-NAME-alfresco-audit-storage-es
- contains:
path: spec.template.spec.containers[0].env
content:
name: AUDIT_ENTRYSTORAGE_OPENSEARCH_CONNECTOR_PASSWORD
valueFrom:
secretKeyRef:
key: SEARCH_PASSWORD
name: RELEASE-NAME-alfresco-audit-storage-es
- contains:
path: spec.template.spec.containers[0].env
content:
name: AUDIT_ENTRYSTORAGE_OPENSEARCH_CONNECTOR_URI
valueFrom:
configMapKeyRef:
key: SEARCH_URL
name: RELEASE-NAME-alfresco-audit-storage-es
- contains:
path: spec.template.spec.containers[0].env
content:
name: AUDIT_EVENTINGESTION_DLQ_CONSUMEPERIOD
value: "60000"
- contains:
path: spec.template.spec.containers[0].env
content:
name: AUDIT_EVENTINGESTION_DLQ_CONSUMPTIONCOUNT
value: "1000"
- contains:
path: spec.template.spec.containers[0].env
content:
name: AUDIT_EVENTINGESTION_URI
value: activemq:topic:alfresco.repo.event2
- contains:
path: spec.template.spec.containers[0].env
content:
name: SPRING_PROFILES_ACTIVE
value: durable-subscriptions
35 changes: 35 additions & 0 deletions charts/alfresco-audit-storage/tests/secret-es_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
suite: test es credentials secret manifest
templates:
- secret-es.yaml
tests:
- it: should have empty credentials as default
asserts:
- equal:
path: data.SEARCH_USERNAME
value: ""
- equal:
path: data.SEARCH_PASSWORD
value: ""

- it: should have credentials populated when credentials are set
set:
elasticSearchConnection:
username: admin
password: letmein
asserts:
- equal:
path: data.SEARCH_USERNAME
value: YWRtaW4=
- equal:
path: data.SEARCH_PASSWORD
value: bGV0bWVpbg==

- it: should not have a secret when existingSecret is set
set:
elasticSearchConnection:
existingSecret:
name: whatever
asserts:
- hasDocuments:
count: 0
34 changes: 34 additions & 0 deletions charts/alfresco-audit-storage/tests/secret-mq_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
suite: test messagebroker credentials secret
templates:
- secret-mq.yaml
tests:
- it: should have empty credentials populated by default
asserts:
- equal:
path: data.BROKER_USERNAME
value: ""
- equal:
path: data.BROKER_PASSWORD
value: ""

- it: should have credentials populated when messagebroker values are set
set:
messageBrokerConnection:
url: ssl://mq.domain.tld:61617
username: ext-admin
password: ext-pass
asserts:
- equal:
path: data.BROKER_USERNAME
value: ZXh0LWFkbWlu
- equal:
path: data.BROKER_PASSWORD
value: ZXh0LXBhc3M=

- it: should not have a secret when existingSecretName is set
set:
messageBrokerConnection.existingSecret.name: existing-secret
asserts:
- hasDocuments:
count: 0
50 changes: 50 additions & 0 deletions charts/alfresco-audit-storage/tests/service_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
suite: test service
templates:
- service.yaml
tests:
- it: render default service
asserts:
- equal:
path: spec.type
value: ClusterIP
- contains:
path: spec.ports
content:
port: 8081
targetPort: http
protocol: TCP
name: http-traffic

- it: render modified service
set:
service.type: NodePort
service.port: 2222
asserts:
- equal:
path: spec.type
value: NodePort
- contains:
path: spec.ports
content:
port: 2222
targetPort: http
protocol: TCP
name: http-traffic

- it: should render labels for service
set:
nameOverride: testName
chart:
version: 1.0.0
appVersion: 2.0.0
asserts:
- isSubset:
path: metadata.labels
content:
app.kubernetes.io/component: alfresco-audit-storage
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: testName
app.kubernetes.io/version: 2.0.0
helm.sh/chart: alfresco-audit-storage-1.0.0
35 changes: 35 additions & 0 deletions charts/alfresco-audit-storage/tests/serviceaccount_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
suite: test service
templates:
- serviceaccount.yaml
tests:
- it: should not have been rendered when disabled
set:
serviceAccount:
create: false
asserts:
- hasDocuments:
count: 0

- it: render default serviceaccount
asserts:
- equal:
path: automountServiceAccountToken
value: true

- it: should render labels for serviceaccount
set:
nameOverride: testName
chart:
version: 1.0.0
appVersion: 2.0.0
asserts:
- isSubset:
path: metadata.labels
content:
app.kubernetes.io/component: alfresco-audit-storage
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: testName
app.kubernetes.io/version: 2.0.0
helm.sh/chart: alfresco-audit-storage-1.0.0

0 comments on commit b3e284e

Please sign in to comment.