-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(chart): add helm unittest tests
- Loading branch information
Showing
7 changed files
with
212 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
*.tmp | ||
*.orig | ||
*~ | ||
tests/ |
110 changes: 110 additions & 0 deletions
110
helm-chart/dash0-operator/tests/operator/__snapshot__/deployment_test.yaml.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
deployment should match snapshot (default values): | ||
1: | | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app.kubernetes.io/component: manager | ||
app.kubernetes.io/instance: controller-manager | ||
app.kubernetes.io/managed-by: Helm | ||
app.kubernetes.io/name: deployment | ||
app.kubernetes.io/part-of: dash0-operator | ||
app.kubernetes.io/version: 1.0.0 | ||
control-plane: controller-manager | ||
helm.sh/chart: dash0-operator-1.0.0 | ||
name: dash0-operator-controller-manager | ||
namespace: NAMESPACE | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
control-plane: controller-manager | ||
template: | ||
metadata: | ||
annotations: | ||
kubectl.kubernetes.io/default-container: manager | ||
labels: | ||
control-plane: controller-manager | ||
spec: | ||
containers: | ||
- args: | ||
- --health-probe-bind-address=:8081 | ||
- --metrics-bind-address=127.0.0.1:8080 | ||
- --leader-elect | ||
command: | ||
- /manager | ||
env: | ||
- name: DASH0_OPERATOR_IMAGE | ||
value: dash0-operator-controller:1.0.0 | ||
- name: DASH0_INIT_CONTAINER_IMAGE | ||
value: dash0-instrumentation:1.0.0 | ||
image: dash0-operator-controller:1.0.0 | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 8081 | ||
initialDelaySeconds: 15 | ||
periodSeconds: 20 | ||
name: manager | ||
ports: | ||
- containerPort: 9443 | ||
name: webhook-server | ||
protocol: TCP | ||
readinessProbe: | ||
httpGet: | ||
path: /readyz | ||
port: 8081 | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 | ||
resources: | ||
limits: | ||
cpu: 500m | ||
ephemeral-storage: 500Mi | ||
memory: 128Mi | ||
requests: | ||
cpu: 10m | ||
ephemeral-storage: 500Mi | ||
memory: 64Mi | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
volumeMounts: | ||
- mountPath: /tmp/k8s-webhook-server/serving-certs | ||
name: cert | ||
readOnly: true | ||
- args: | ||
- --secure-listen-address=0.0.0.0:8443 | ||
- --upstream=http://127.0.0.1:8080/ | ||
- --logtostderr=true | ||
- --v=0 | ||
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.15.0 | ||
name: kube-rbac-proxy | ||
ports: | ||
- containerPort: 8443 | ||
name: https | ||
protocol: TCP | ||
resources: | ||
limits: | ||
cpu: 500m | ||
memory: 128Mi | ||
requests: | ||
cpu: 5m | ||
memory: 64Mi | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
securityContext: | ||
runAsNonRoot: true | ||
seccompProfile: | ||
type: RuntimeDefault | ||
serviceAccountName: dash0-operator-controller-manager | ||
terminationGracePeriodSeconds: 10 | ||
volumes: | ||
- name: cert | ||
secret: | ||
defaultMode: 420 | ||
secretName: webhook-server-cert |
86 changes: 86 additions & 0 deletions
86
helm-chart/dash0-operator/tests/operator/deployment_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
suite: test deployment | ||
templates: | ||
- operator/deployment.yaml | ||
tests: | ||
- it: deployment should match snapshot (default values) | ||
asserts: | ||
- matchSnapshot: {} | ||
|
||
- it: render deployment with custom settings | ||
set: | ||
operator: | ||
additionalLabels: | ||
label1: "value 1" | ||
label2: "value 2" | ||
deploymentAnnotations: | ||
annotation1: "value 1" | ||
annotation2: "value 2" | ||
replicaCount: 3 | ||
podAnnotations: | ||
annotation1: "value 1" | ||
annotation2: "value 2" | ||
podLabels: | ||
label1: "value 1" | ||
label2: "value 2" | ||
image: custom-operator-image:1.2.3 | ||
imagePullPolicy: Never | ||
initContainerImage: custom-init-container-image:4.5.6 | ||
managerPodResources: | ||
limits: | ||
cpu: 123m | ||
memory: 456Mi | ||
requests: | ||
cpu: 5m | ||
memory: 32Mi | ||
asserts: | ||
- equal: | ||
path: metadata.labels['label1'] | ||
value: "value 1" | ||
- equal: | ||
path: metadata.labels['label2'] | ||
value: "value 2" | ||
- equal: | ||
path: metadata.annotations['annotation1'] | ||
value: "value 1" | ||
- equal: | ||
path: metadata.annotations['annotation2'] | ||
value: "value 2" | ||
- equal: | ||
path: spec.replicas | ||
value: 3 | ||
- equal: | ||
path: spec.template.metadata.annotations['annotation1'] | ||
value: "value 1" | ||
- equal: | ||
path: spec.template.metadata.annotations['annotation2'] | ||
value: "value 2" | ||
- equal: | ||
path: spec.template.metadata.labels['label1'] | ||
value: "value 1" | ||
- equal: | ||
path: spec.template.metadata.labels['label2'] | ||
value: "value 2" | ||
- equal: | ||
path: spec.template.spec.containers[0].image | ||
value: custom-operator-image:1.2.3 | ||
- equal: | ||
path: spec.template.spec.containers[0].imagePullPolicy | ||
value: Never | ||
- equal: | ||
path: spec.template.spec.containers[0].env[0].value | ||
value: custom-operator-image:1.2.3 | ||
- equal: | ||
path: spec.template.spec.containers[0].env[1].value | ||
value: custom-init-container-image:4.5.6 | ||
- equal: | ||
path: spec.template.spec.containers[0].resources.limits.cpu | ||
value: 123m | ||
- equal: | ||
path: spec.template.spec.containers[0].resources.limits.memory | ||
value: 456Mi | ||
- equal: | ||
path: spec.template.spec.containers[0].resources.requests.cpu | ||
value: 5m | ||
- equal: | ||
path: spec.template.spec.containers[0].resources.requests.memory | ||
value: 32Mi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters