Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] add unittests to verify rendering of service account #1545

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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