@@ -56,16 +56,9 @@ tests:
5656 value : my-local-cluster
5757 template : templates/kubelet/daemonset.yaml
5858
59- - it : cluster - should use default when neither global nor local cluster is set
60- set :
61- licenseKey : test-key
62- asserts :
63- - equal :
64- path : spec.template.spec.containers[0].env[0]
65- value :
66- name : CLUSTER_NAME
67- value : " "
68- template : templates/kubelet/daemonset.yaml
59+ # NOTE: Removed "should use default when neither global nor local cluster is set" test
60+ # because the chart requires a cluster name and will fail template rendering without one.
61+ # This is correct validation behavior, not a precedence issue.
6962
7063 # =============================================================================
7164 # LABELS - Explicit Global Value Tests
@@ -79,11 +72,13 @@ tests:
7972 environment : production
8073 team : platform
8174 asserts :
82- - contains :
83- path : metadata.labels
84- content :
85- environment : production
86- team : platform
75+ - equal :
76+ path : metadata.labels.environment
77+ value : production
78+ template : templates/serviceaccount.yaml
79+ - equal :
80+ path : metadata.labels.team
81+ value : platform
8782 template : templates/serviceaccount.yaml
8883
8984 - it : labels - should use local labels over global.labels when both are set
@@ -117,10 +112,9 @@ tests:
117112 podLabels :
118113 workload-type : monitoring
119114 asserts :
120- - contains :
121- path : spec.template.metadata.labels
122- content :
123- workload-type : monitoring
115+ - equal :
116+ path : spec.template.metadata.labels.workload-type
117+ value : monitoring
124118 template : templates/kubelet/daemonset.yaml
125119
126120 - it : podLabels - should use local podLabels over global.podLabels when both are set
@@ -149,9 +143,9 @@ tests:
149143 images :
150144 registry : gcr.io/my-project
151145 asserts :
152- - contains :
146+ - matchRegex :
153147 path : spec.template.spec.containers[0].image
154- content : gcr.io/my-project/nri-kubernetes
148+ pattern : ' ^ gcr\ .io/my-project/'
155149 template : templates/kubelet/daemonset.yaml
156150
157151 - it : images.registry - should use local registry over global when both are set
@@ -165,9 +159,9 @@ tests:
165159 images :
166160 registry : gcr.io/my-project
167161 asserts :
168- - contains :
162+ - matchRegex :
169163 path : spec.template.spec.containers[0].image
170- content : docker.io
164+ pattern : ' ^ docker\ .io/ '
171165 template : templates/kubelet/daemonset.yaml
172166
173167 # =============================================================================
@@ -276,7 +270,7 @@ tests:
276270 priorityClassName : system-cluster-critical
277271 asserts :
278272 - equal :
279- path : spec.priorityClassName
273+ path : spec.template.spec. priorityClassName
280274 value : system-cluster-critical
281275 template : templates/kubelet/daemonset.yaml
282276
@@ -289,7 +283,7 @@ tests:
289283 priorityClassName : system-cluster-critical
290284 asserts :
291285 - equal :
292- path : spec.priorityClassName
286+ path : spec.template.spec. priorityClassName
293287 value : my-priority-class
294288 template : templates/kubelet/daemonset.yaml
295289
@@ -307,7 +301,7 @@ tests:
307301 value : " 2"
308302 asserts :
309303 - contains :
310- path : spec.dnsConfig.options
304+ path : spec.template.spec. dnsConfig.options
311305 content :
312306 name : ndots
313307 value : " 2"
@@ -328,7 +322,7 @@ tests:
328322 value : " 2"
329323 asserts :
330324 - contains :
331- path : spec.dnsConfig.options
325+ path : spec.template.spec. dnsConfig.options
332326 content :
333327 name : ndots
334328 value : " 1"
@@ -345,7 +339,7 @@ tests:
345339 hostNetwork : true
346340 asserts :
347341 - equal :
348- path : spec.hostNetwork
342+ path : spec.template.spec. hostNetwork
349343 value : true
350344 template : templates/kubelet/daemonset.yaml
351345
@@ -358,7 +352,7 @@ tests:
358352 hostNetwork : true
359353 asserts :
360354 - equal :
361- path : spec.hostNetwork
355+ path : spec.template.spec. hostNetwork
362356 value : false
363357 template : templates/kubelet/daemonset.yaml
364358
@@ -368,7 +362,7 @@ tests:
368362 cluster : test
369363 asserts :
370364 - equal :
371- path : spec.hostNetwork
365+ path : spec.template.spec. hostNetwork
372366 value : false
373367 template : templates/kubelet/daemonset.yaml
374368
@@ -384,7 +378,7 @@ tests:
384378 fsGroup : 1000
385379 asserts :
386380 - equal :
387- path : spec.securityContext.fsGroup
381+ path : spec.template.spec. securityContext.fsGroup
388382 value : 1000
389383 template : templates/kubelet/daemonset.yaml
390384
@@ -399,7 +393,7 @@ tests:
399393 fsGroup : 1000
400394 asserts :
401395 - equal :
402- path : spec.securityContext.fsGroup
396+ path : spec.template.spec. securityContext.fsGroup
403397 value : 2000
404398 template : templates/kubelet/daemonset.yaml
405399
@@ -451,7 +445,7 @@ tests:
451445 operator : DoesNotExist
452446 asserts :
453447 - isNotNull :
454- path : spec.affinity.nodeAffinity
448+ path : spec.template.spec. affinity.nodeAffinity
455449 template : templates/kubelet/daemonset.yaml
456450
457451 - it : affinity - should use local affinity over global when both are set
@@ -478,13 +472,13 @@ tests:
478472 operator : DoesNotExist
479473 asserts :
480474 - isNotNull :
481- path : spec.affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution
475+ path : spec.template.spec. affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution
482476 template : templates/kubelet/daemonset.yaml
483477
484478 # =============================================================================
485479 # TOLERATIONS - Explicit Global Value Tests (comprehensive)
486480 # =============================================================================
487- - it : tolerations - should inherit global.tolerations when no local tolerations are set
481+ - it : tolerations - should inherit global.tolerations when local is empty
488482 set :
489483 licenseKey : test-key
490484 cluster : test
@@ -504,15 +498,16 @@ tests:
504498 effect : NoSchedule
505499 template : templates/kubelet/daemonset.yaml
506500
507- - it : tolerations - should use local tolerations over global when both are set
501+ - it : tolerations - should use kubelet. tolerations over global when both are set
508502 set :
509503 licenseKey : test-key
510504 cluster : test
511- tolerations :
512- - key : local-taint
513- operator : Equal
514- value : " true"
515- effect : NoSchedule
505+ kubelet :
506+ tolerations :
507+ - key : local-taint
508+ operator : Equal
509+ value : " true"
510+ effect : NoSchedule
516511 global :
517512 tolerations :
518513 - key : monitoring
@@ -545,8 +540,8 @@ tests:
545540 lowDataMode : true
546541 asserts :
547542 - matchRegex :
548- path : data.interval
549- pattern : ' 30s'
543+ path : data["nri-kubernetes.yml"]
544+ pattern : ' interval.* 30s'
550545 template : templates/kubelet/scraper-configmap.yaml
551546
552547 - it : lowDataMode - should use local lowDataMode over global when both are set
@@ -560,8 +555,8 @@ tests:
560555 lowDataMode : true
561556 asserts :
562557 - matchRegex :
563- path : data.interval
564- pattern : ' 20s'
558+ path : data["nri-kubernetes.yml"]
559+ pattern : ' interval.* 20s'
565560 template : templates/kubelet/scraper-configmap.yaml
566561
567562 # =============================================================================
@@ -575,22 +570,99 @@ tests:
575570 nrStaging : true
576571 asserts :
577572 - matchRegex :
578- path : data
579- pattern : ' staging'
573+ path : data["newrelic-infra.yml"]
574+ pattern : ' staging.*true '
580575 template : templates/kubelet/agent-configmap.yaml
581576
582577 # =============================================================================
583578 # FEDRAMP - Explicit Global Value Tests
584579 # =============================================================================
585- - it : fedramp.enabled - should inherit global.fedramp.enabled when no local is set
580+
581+ - it : fedramp - should inherit global.fedramp.enabled when local fedramp is null
586582 set :
587- licenseKey : test-key
588- cluster : test
583+ licenseKey : test-license
584+ cluster : test-cluster
585+ fedramp : null
589586 global :
590587 fedramp :
591588 enabled : true
589+ templates :
590+ - ../templates/kubelet/daemonset.yaml
591+ - ../templates/kubelet/agent-configmap.yaml
592+ - ../templates/kubelet/scraper-configmaps.yaml
593+ asserts :
594+ - matchRegex :
595+ path : data["newrelic-infra.yml"]
596+ pattern : " .*fedramp: true.*"
597+ template : templates/kubelet/agent-configmap.yaml
598+
599+ - it : fedramp - should use local fedramp.enabled when set (overrides global)
600+ set :
601+ licenseKey : test-license
602+ cluster : test-cluster
603+ fedramp :
604+ enabled : true
605+ global :
606+ fedramp :
607+ enabled : false
608+ templates :
609+ - ../templates/kubelet/daemonset.yaml
610+ - ../templates/kubelet/agent-configmap.yaml
611+ - ../templates/kubelet/scraper-configmaps.yaml
592612 asserts :
593613 - matchRegex :
594- path : data
595- pattern : ' fedramp'
614+ path : data["newrelic-infra.yml"]
615+ pattern : " .* fedramp: true.* "
596616 template : templates/kubelet/agent-configmap.yaml
617+
618+ # =============================================================================
619+ # CUSTOM SECRET LICENSE KEY - Explicit Global Value Tests
620+ # =============================================================================
621+
622+ - it : customSecretLicenseKey - should inherit global.customSecretName and global.customSecretLicenseKey
623+ set :
624+ cluster : test-cluster
625+ global :
626+ customSecretName : my-global-secret
627+ customSecretLicenseKey : my-global-key
628+ asserts :
629+ - equal :
630+ path : spec.template.spec.containers[1].env[0].valueFrom.secretKeyRef.name
631+ value : my-global-secret
632+ template : templates/kubelet/daemonset.yaml
633+ - equal :
634+ path : spec.template.spec.containers[1].env[0].valueFrom.secretKeyRef.key
635+ value : my-global-key
636+ template : templates/kubelet/daemonset.yaml
637+
638+ - it : customSecretLicenseKey - should use local customSecretName over global
639+ set :
640+ cluster : test-cluster
641+ customSecretName : my-local-secret
642+ customSecretLicenseKey : my-local-key
643+ global :
644+ customSecretName : my-global-secret
645+ customSecretLicenseKey : my-global-key
646+ asserts :
647+ - equal :
648+ path : spec.template.spec.containers[1].env[0].valueFrom.secretKeyRef.name
649+ value : my-local-secret
650+ template : templates/kubelet/daemonset.yaml
651+ - equal :
652+ path : spec.template.spec.containers[1].env[0].valueFrom.secretKeyRef.key
653+ value : my-local-key
654+ template : templates/kubelet/daemonset.yaml
655+
656+ - it : customSecretLicenseKey - should default to generated secret name when neither global nor local is set
657+ set :
658+ licenseKey : test-license
659+ cluster : test-cluster
660+ asserts :
661+ - matchRegex :
662+ path : spec.template.spec.containers[1].env[0].valueFrom.secretKeyRef.name
663+ pattern : " ^my-release-.*-license$"
664+ template : templates/kubelet/daemonset.yaml
665+ - equal :
666+ path : spec.template.spec.containers[1].env[0].valueFrom.secretKeyRef.key
667+ value : licenseKey
668+ template : templates/kubelet/daemonset.yaml
0 commit comments