Skip to content

Commit

Permalink
[chore] add unittests to verify rendering of service account (#1545)
Browse files Browse the repository at this point in the history
* [chore] add unittests to verify rendering of service account

* fix test suite name
  • Loading branch information
jinja2 authored Nov 21, 2024
1 parent c4c103f commit f4fd2f8
Showing 1 changed file with 112 additions and 0 deletions.
112 changes: 112 additions & 0 deletions test/unittests/service_account_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
suite: splunk-otel-collector.serviceAccount
values:
- ./values/basic.yaml
templates:
- serviceAccount.yaml
- deployment-cluster-receiver.yaml
- configmap-cluster-receiver.yaml
- daemonset.yaml
- configmap-fluentd.yaml
- configmap-agent.yaml
release:
name: test-release
tests:
- it: should render serviceaccount correctly
set:
image:
imagePullSecrets:
- secret1
- secret2
serviceAccount:
create: true
annotations:
key1: value1
featureGates:
explicitMountServiceAccountToken: true # automount should be false
template: serviceAccount.yaml
asserts:
- isKind:
of: ServiceAccount
template: serviceAccount.yaml
- equal:
path: metadata.name
value: "test-release-splunk-otel-collector"
- equal:
path: metadata.annotations
value:
key1: value1
- equal:
path: automountServiceAccountToken
value: false
- equal:
path: imagePullSecrets
value:
- name: secret1
- name: secret2
- it: should add default serviceAccountName to deployment and daemonset
set:
serviceAccount:
create: true
templates:
- deployment-cluster-receiver.yaml
- daemonset.yaml
asserts:
- equal:
path: spec.template.spec.serviceAccountName
value: "test-release-splunk-otel-collector"
template: deployment-cluster-receiver.yaml
- equal:
path: spec.template.spec.serviceAccountName
value: "test-release-splunk-otel-collector"
template: daemonset.yaml
- it: should not render serviceaccount
set:
serviceAccount:
create: false
template: serviceAccount.yaml
asserts:
- hasDocuments:
count: 0
- it: should set custom service account name correctly in serviceaccount, deployment and daemonset
set:
serviceAccount:
create: true
name: custom-service-account
templates:
- deployment-cluster-receiver.yaml
- daemonset.yaml
- serviceAccount.yaml
asserts:
- equal:
path: spec.template.spec.serviceAccountName
value: custom-service-account
template: deployment-cluster-receiver.yaml
- equal:
path: spec.template.spec.serviceAccountName
value: custom-service-account
template: daemonset.yaml
- equal:
path: metadata.name
value: custom-service-account
template: serviceAccount.yaml
- it: should set custom service account name correctly in deployment and daemonset with no serviceaccount
set:
serviceAccount:
create: false
name: custom-service-account
templates:
- deployment-cluster-receiver.yaml
- daemonset.yaml
- serviceAccount.yaml
asserts:
- equal:
path: spec.template.spec.serviceAccountName
value: custom-service-account
template: deployment-cluster-receiver.yaml
- equal:
path: spec.template.spec.serviceAccountName
value: custom-service-account
template: daemonset.yaml
- hasDocuments:
count: 0
template: serviceAccount.yaml

0 comments on commit f4fd2f8

Please sign in to comment.