-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chart): add helm-unittest framework (#5137)
* feat(chart): add helm-unittest framework Signed-off-by: ivan katliarchuk <[email protected]> * feat(chart): add helm-unittest framework Signed-off-by: ivan katliarchuk <[email protected]> * feat(chart): add helm-unittest framework Signed-off-by: ivan katliarchuk <[email protected]> * feat(chart): add helm-unittest framework Signed-off-by: ivan katliarchuk <[email protected]> * feat(chart): add helm-unittest framework Signed-off-by: ivan katliarchuk <[email protected]> * feat(chart): add helm-unittest framework * feat(chart): add helm-unittest framework Signed-off-by: ivan katliarchuk <[email protected]> * feat(chart): add helm-unittest framework Signed-off-by: ivan katliarchuk <[email protected]> * feat(chart): add helm-unittest framework Signed-off-by: ivan katliarchuk <[email protected]> * feat(chart): add helm-unittest framework Signed-off-by: ivan katliarchuk <[email protected]> * feat(chart): add helm-unittest framework Signed-off-by: ivan katliarchuk <[email protected]> * feat(chart): add helm-unittest framework Signed-off-by: ivan katliarchuk <[email protected]> * feat(chart): add helm-unittest framework Signed-off-by: ivan katliarchuk <[email protected]> --------- Signed-off-by: ivan katliarchuk <[email protected]>
- Loading branch information
1 parent
7c23e01
commit 5f26223
Showing
16 changed files
with
683 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ | |
ci/ | ||
schema/ | ||
.schema.yaml | ||
tests/ |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
suite: All resources contains metadata | ||
templates: | ||
- "*.yaml" | ||
release: | ||
name: external-dns | ||
chart: | ||
version: "1.15.0" | ||
appVersion: "0.15.0" | ||
tests: | ||
- it: "should contain labels metadata in each template" | ||
set: | ||
secretConfiguration: | ||
enabled: true | ||
mountPath: "/etc/kubernetes/" | ||
serviceMonitor: | ||
enabled: true | ||
asserts: | ||
- exists: | ||
path: metadata.labels | ||
- isNotEmpty: | ||
path: metadata.labels | ||
- equal: | ||
path: metadata.labels | ||
value: | ||
helm.sh/chart: external-dns-1.15.0 | ||
app.kubernetes.io/name: external-dns | ||
app.kubernetes.io/instance: external-dns | ||
app.kubernetes.io/version: "0.15.0" | ||
app.kubernetes.io/managed-by: Helm |
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,80 @@ | ||
suite: Deployment configuration | ||
templates: | ||
- deployment.yaml | ||
release: | ||
namespace: default | ||
tests: | ||
- it: should provide expected defaults | ||
asserts: | ||
- isKind: | ||
of: Deployment | ||
- hasDocuments: | ||
count: 1 | ||
- equal: | ||
path: spec.replicas | ||
value: 1 | ||
- equal: | ||
path: spec.strategy.type | ||
value: Recreate | ||
- equal: | ||
path: metadata.namespace | ||
value: default | ||
- notExists: | ||
path: spec.template.spec.automountServiceAccountToken | ||
|
||
- it: should provide expected defaults for securityContext | ||
asserts: | ||
- isSubset: | ||
path: spec.template.spec.containers[?(@.name == "external-dns")] | ||
content: | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
privileged: false | ||
readOnlyRootFilesystem: true | ||
runAsGroup: 65532 | ||
runAsNonRoot: true | ||
runAsUser: 65532 | ||
|
||
- it: should provide expected defaults for liveness and readiness | ||
asserts: | ||
- isSubset: | ||
path: spec.template.spec.containers[?(@.name == "external-dns")] | ||
content: | ||
readinessProbe: | ||
failureThreshold: 6 | ||
httpGet: | ||
path: /healthz | ||
port: http | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 5 | ||
livenessProbe: | ||
failureThreshold: 2 | ||
httpGet: | ||
path: /healthz | ||
port: http | ||
initialDelaySeconds: 10 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 5 | ||
|
||
- it: should have service account set | ||
release: | ||
name: test | ||
asserts: | ||
- equal: | ||
path: spec.template.spec.serviceAccountName | ||
value: test-external-dns | ||
|
||
- it: should have not be able to change replicas when specified via values | ||
set: | ||
deployment: | ||
replicas: 3 | ||
asserts: | ||
- equal: | ||
path: spec.replicas | ||
value: 1 |
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,119 @@ | ||
suite: Deployment flags configurations | ||
templates: | ||
- deployment.yaml | ||
release: | ||
namespace: default | ||
tests: | ||
- it: should provide expected default flags | ||
asserts: | ||
# - matchSnapshot: {} | ||
- exists : | ||
path: spec.template.spec.containers[?(@.name == "external-dns")] | ||
- equal : | ||
path: spec.template.spec.containers[?(@.name == "external-dns")].args | ||
value: | ||
- --log-level=info | ||
- --log-format=text | ||
- --interval=1m | ||
- --source=service | ||
- --source=ingress | ||
- --policy=upsert-only | ||
- --registry=txt | ||
- --provider=aws | ||
|
||
- it: should configure txtPrefix and ignore txtSuffix if not empty | ||
set: | ||
provider: | ||
name: cloudflare | ||
txtPrefix: "test-prefix" | ||
txtSuffix: "test-suffix" | ||
txtOwnerId: "testing" | ||
asserts: | ||
- exists : | ||
path: spec.template.spec.containers[?(@.name == "external-dns")] | ||
- equal : | ||
path: spec.template.spec.containers[?(@.name == "external-dns")].args | ||
value: | ||
- --log-level=info | ||
- --log-format=text | ||
- --interval=1m | ||
- --source=service | ||
- --source=ingress | ||
- --policy=upsert-only | ||
- --registry=txt | ||
- --txt-owner-id=testing | ||
- --txt-prefix=test-prefix | ||
- --provider=cloudflare | ||
- notContains: | ||
path: spec.template.spec.containers[?(@.name == "external-dns")].args | ||
content: "--txt-suffix=test-suffix" | ||
|
||
- it: should configure 'txtSuffix' when not empty with 'txtPrefix' empty | ||
set: | ||
txtPrefix: "" | ||
txtSuffix: "test-suffix" | ||
asserts: | ||
- exists : | ||
path: spec.template.spec.containers[?(@.name == "external-dns")] | ||
- equal : | ||
path: spec.template.spec.containers[?(@.name == "external-dns")].args | ||
value: | ||
- --log-level=info | ||
- --log-format=text | ||
- --interval=1m | ||
- --source=service | ||
- --source=ingress | ||
- --policy=upsert-only | ||
- --registry=txt | ||
- --txt-suffix=test-suffix | ||
- --provider=aws | ||
- notContains: | ||
path: spec.template.spec.containers[?(@.name == "external-dns")].args | ||
content: "--txt-prefix=test-prefix" | ||
|
||
- it: should be able configure multiple sources | ||
set: | ||
sources: | ||
- fake | ||
- crd | ||
asserts: | ||
- contains: | ||
path: spec.template.spec.containers[?(@.name == "external-dns")].args | ||
content: "--source=fake" | ||
- contains: | ||
path: spec.template.spec.containers[?(@.name == "external-dns")].args | ||
content: "--source=crd" | ||
|
||
- it: should be able to configure in single namespace | ||
set: | ||
namespaced: true | ||
asserts: | ||
- contains: | ||
path: spec.template.spec.containers[?(@.name == "external-dns")].args | ||
content: "--namespace=default" | ||
|
||
- it: should manage multiple zones with 'extraArgs' | ||
set: | ||
extraArgs: | ||
- --zone-id-filter=/hostedzone/Z00001 | ||
- --zone-id-filter=/hostedzone/Z00002 | ||
- --zone-id-filter=/hostedzone/Z00003 | ||
- --zone-id-filter=/hostedzone/Z00004 | ||
- --zone-id-filter=/hostedzone/Z00005 | ||
asserts: | ||
- equal: | ||
path: spec.template.spec.containers[?(@.name == "external-dns")].args | ||
value: | ||
- --log-level=info | ||
- --log-format=text | ||
- --interval=1m | ||
- --source=service | ||
- --source=ingress | ||
- --policy=upsert-only | ||
- --registry=txt | ||
- --provider=aws | ||
- --zone-id-filter=/hostedzone/Z00001 | ||
- --zone-id-filter=/hostedzone/Z00002 | ||
- --zone-id-filter=/hostedzone/Z00003 | ||
- --zone-id-filter=/hostedzone/Z00004 | ||
- --zone-id-filter=/hostedzone/Z00005 |
118 changes: 118 additions & 0 deletions
118
charts/external-dns/tests/deployment-scheduling_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,118 @@ | ||
suite: Deployment scheduling configuration | ||
templates: | ||
- deployment.yaml | ||
release: | ||
namespace: default | ||
tests: | ||
- it: should not provide defaults for affinities or tolerations | ||
asserts: | ||
- isKind: | ||
of: Deployment | ||
- notExists: | ||
path: spec.template.spec.tolerations | ||
- notExists: | ||
path: spec.template.spec.affinity | ||
|
||
- it: should provide support for custom affinities | ||
set: | ||
affinity: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: topology.kubernetes.io/zone | ||
operator: In | ||
values: | ||
- zoneA | ||
- zoneB | ||
asserts: | ||
- equal: | ||
path: spec.template.spec.affinity | ||
value: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: topology.kubernetes.io/zone | ||
operator: In | ||
values: | ||
- zoneA | ||
- zoneB | ||
|
||
- it: should provide support for configuring node and pod affinities | ||
set: | ||
affinity: | ||
podAntiAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
- topologyKey: kubernetes.io/hostname | ||
labelSelector: | ||
matchExpressions: | ||
- key: app | ||
operator: In | ||
values: | ||
- test-pod-scheduling-config | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: datadog-agent | ||
operator: In | ||
values: | ||
- standard | ||
- key: iam/scope | ||
operator: In | ||
values: | ||
- namespace | ||
asserts: | ||
- equal: | ||
path: spec.template.spec.affinity | ||
value: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: datadog-agent | ||
operator: In | ||
values: | ||
- standard | ||
- key: iam/scope | ||
operator: In | ||
values: | ||
- namespace | ||
podAntiAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
- labelSelector: | ||
matchExpressions: | ||
- key: app | ||
operator: In | ||
values: | ||
- test-pod-scheduling-config | ||
topologyKey: kubernetes.io/hostname | ||
|
||
- it: should provide support for configuring tolerations | ||
set: | ||
tolerations: | ||
- key: "key1" | ||
operator: "Equal" | ||
value: "value1" | ||
effect: "NoSchedule" | ||
- key: iam/scope | ||
operator: Equal | ||
value: namespace | ||
effect: NoExecute | ||
asserts: | ||
- notExists: | ||
path: spec.template.spec.affinity | ||
- exists: | ||
path: spec.template.spec.tolerations | ||
- equal: | ||
path: spec.template.spec.tolerations | ||
value: | ||
- effect: NoSchedule | ||
key: key1 | ||
operator: Equal | ||
value: value1 | ||
- effect: NoExecute | ||
key: iam/scope | ||
operator: Equal | ||
value: namespace |
Oops, something went wrong.