File tree Expand file tree Collapse file tree 4 files changed +73
-2
lines changed Expand file tree Collapse file tree 4 files changed +73
-2
lines changed Original file line number Diff line number Diff line change @@ -725,6 +725,16 @@ functions:
725725 make test-race
726726 - command : gotest.parse_files
727727 params :
728+
729+ test_helm_unit :
730+ - command : shell.exec
731+ type : test
732+ params :
733+ shell : bash
734+ working_dir : src/github.com/mongodb/mongodb-kubernetes
735+ script : |
736+ source .generated/context.export.env
737+ make helm-tests
728738 files : [ "src/github.com/mongodb/mongodb-kubernetes/*.suite", "src/github.com/mongodb/mongodb-kubernetes/docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration/*.suite" ]
729739
730740 test_python_unit :
Original file line number Diff line number Diff line change @@ -275,6 +275,11 @@ tasks:
275275 commands :
276276 - func : " test_python_unit"
277277
278+ - name : unit_tests_helm
279+ tags : [ "unit_tests" ]
280+ commands :
281+ - func : " test_helm_unit"
282+
278283 - name : sbom_tests
279284 tags : [ "unit_tests" ]
280285 # The SBOM tests run only on commit builds. Running this on patches might cause false-positive failures
@@ -665,6 +670,7 @@ task_groups:
665670 - lint_repo
666671 - unit_tests_golang
667672 - unit_tests_python
673+ - unit_tests_helm
668674 - sbom_tests
669675
670676 - name : gke_code_snippets_task_group
Original file line number Diff line number Diff line change @@ -300,8 +300,17 @@ test-race: generate fmt vet manifests golang-tests-race
300300
301301test : generate fmt vet manifests golang-tests
302302
303- # all-tests will run golang and python tests without race (used locally)
304- all-tests : test python-tests
303+ # helm-tests will run helm chart unit tests
304+ helm-tests : # # Run helm chart unit tests
305+ @echo " Running helm chart unit tests..."
306+ @if ! helm plugin list | grep -q unittest; then \
307+ echo " Installing helm-unittest plugin..." ; \
308+ helm plugin install https://github.com/helm-unittest/helm-unittest; \
309+ fi
310+ helm unittest helm_chart --color
311+
312+ # all-tests will run golang, python, and helm tests without race (used locally)
313+ all-tests : test python-tests helm-tests
305314
306315# Build manager binary
307316manager : generate fmt vet
Original file line number Diff line number Diff line change 1+ suite : test webhook consistent clusterrole and binding namecomm
2+ templates :
3+ - operator-roles-webhook.yaml
4+ tests :
5+ - it : should have consistent ClusterRole and ClusterRoleBinding names
6+ set :
7+ operator.webhook.registerConfiguration : true
8+ operator.webhook.installClusterRole : true
9+ asserts :
10+ - hasDocuments :
11+ count : 2
12+ - isKind :
13+ of : ClusterRole
14+ documentIndex : 0
15+ - isKind :
16+ of : ClusterRoleBinding
17+ documentIndex : 1
18+ # The key fix: both should use the same dynamic name
19+ - equal :
20+ path : metadata.name
21+ value : mongodb-kubernetes-operator-NAMESPACE-webhook
22+ documentIndex : 0
23+ - equal :
24+ path : roleRef.name
25+ value : mongodb-kubernetes-operator-NAMESPACE-webhook
26+ documentIndex : 1
27+
28+ # Test that different installations get unique names (prevents conflicts)
29+ - it : should create unique names per installation
30+ set :
31+ operator.name : my-operator
32+ operator.namespace : custom-ns
33+ operator.webhook.registerConfiguration : true
34+ operator.webhook.installClusterRole : true
35+ release :
36+ namespace : custom-ns
37+ asserts :
38+ # Verify the naming pattern: {operator.name}-{namespace}-webhook
39+ - equal :
40+ path : metadata.name
41+ value : my-operator-custom-ns-webhook
42+ documentIndex : 0
43+ - equal :
44+ path : roleRef.name
45+ value : my-operator-custom-ns-webhook
46+ documentIndex : 1
You can’t perform that action at this time.
0 commit comments