Skip to content

Conversation

@dpacheconr
Copy link
Contributor

@dpacheconr dpacheconr commented Nov 27, 2025

Overview

This PR adds comprehensive explicit test coverage for all 15 applicable global values in the nri-metadata-injection chart. While the chart already supported global values through common-library integration, it lacked explicit helm-unittest tests demonstrating inheritance and precedence behavior. This PR ensures every applicable global value has dedicated test coverage proving it works correctly.

Changes

Added Comprehensive Global Value Tests

New Test File: tests/global-inheritance_test.yaml (20 tests)

  • global.cluster - inheritance and local precedence (2 tests)
  • global.labels - inheritance and merge behavior (2 tests)
  • global.podLabels - inheritance and merge behavior (2 tests)
  • global.images.registry - inheritance and local precedence (2 tests)
  • global.images.pullSecrets - inheritance and merge behavior (2 tests)
  • global.priorityClassName - inheritance and local precedence (2 tests)
  • global.hostNetwork - inheritance and local precedence (2 tests)
  • global.dnsConfig - inheritance and local precedence (2 tests)
  • global.nodeSelector - inheritance and local precedence (2 tests)
  • global.affinity - inheritance and local precedence (2 tests)

New Test File: tests/serviceaccount-global_test.yaml (4 tests)

  • global.serviceAccount.create - inheritance and local precedence (3 tests)
  • Default ServiceAccount name validation (1 test)

Previously Tested Global Values (Already Had Explicit Tests)

  • global.tolerations - tests/job_serviceaccount_test.yaml (2 tests)
  • global.serviceAccount.annotations - tests/serviceaccount_annotations_test.yaml (2 tests)
  • global.podSecurityContext - tests/security_context_test.yaml + tests/job_security_context_test.yaml (multiple tests)
  • global.containerSecurityContext - tests/security_context_test.yaml + tests/job_security_context_test.yaml (multiple tests)

Test Results

Charts:      1 passed (1 total)
Test Suites: 12 passed (12 total)
Tests:       86 passed (86 total) 
Pass Rate:   100%

Tests Added: 24 new tests
Previous Tests: 62 tests
Total Coverage: 86 tests covering all 15 applicable global values

Global Values Coverage

All 27 global values from the nri-bundle global contract assessed:

Testing Philosophy: Every applicable global value MUST have explicit helm-unittest test coverage demonstrating:

  1. Inheritance: Global value applies when local value is omitted
  2. Precedence: Local value overrides global when both are set

Coverage Summary: 15/27 global values applicable to webhook charts, all 15 now have explicit tests (100%)

Global Value Applicable Tested Test File(s)
cluster Yes Yes global-inheritance_test.yaml (2 tests)
licenseKey No N/A Webhook pods do not authenticate to New Relic
customSecretName No N/A Not applicable to webhook
customSecretLicenseKey No N/A Not applicable to webhook
insightsKey No N/A Deprecated
provider No N/A Not applicable to webhook
labels Yes Yes global-inheritance_test.yaml (2 tests)
podLabels Yes Yes global-inheritance_test.yaml (2 tests)
images.registry Yes Yes global-inheritance_test.yaml (2 tests)
images.pullSecrets Yes Yes global-inheritance_test.yaml (2 tests)
serviceAccount.create Yes Yes serviceaccount-global_test.yaml (3 tests)
serviceAccount.name Yes Yes serviceaccount-global_test.yaml (1 test)
serviceAccount.annotations Yes Yes serviceaccount_annotations_test.yaml (2 tests)
hostNetwork Yes Yes global-inheritance_test.yaml (2 tests)
dnsConfig Yes Yes global-inheritance_test.yaml (2 tests)
proxy No N/A Webhook does not make outbound connections
priorityClassName Yes Yes global-inheritance_test.yaml (2 tests)
nodeSelector Yes Yes global-inheritance_test.yaml (2 tests)
tolerations Yes Yes job_serviceaccount_test.yaml (2 tests)
affinity Yes Yes global-inheritance_test.yaml (2 tests)
podSecurityContext Yes Yes security_context_test.yaml + job_security_context_test.yaml
containerSecurityContext Yes Yes security_context_test.yaml + job_security_context_test.yaml
privileged No N/A Not applicable to webhook
customAttributes No N/A Not applicable to webhook
lowDataMode No N/A Not applicable to webhook
fargate No N/A Webhook does not have Fargate-specific requirements
nrStaging No N/A Webhook does not send data to New Relic
verboseLog No N/A Webhook does not use logging configuration
fedramp.enabled No N/A Webhook does not send data to New Relic
TOTAL 15/27 15/15 100% Explicit Test Coverage

Files Added

  • charts/nri-metadata-injection/tests/global-inheritance_test.yaml - 20 new tests for cluster, labels, podLabels, images.*, priorityClassName, hostNetwork, dnsConfig, nodeSelector, affinity
  • charts/nri-metadata-injection/tests/serviceaccount-global_test.yaml - 4 new tests for serviceAccount.create precedence

Test Coverage Validation

Each test validates two critical behaviors:

  1. Inheritance Test: Verifies global value is used when local value is omitted
  2. Precedence Test: Verifies local value overrides global when both are set

This ensures consistent precedence behavior (Local > Global > Default) across all 15 applicable global values.

No Breaking Changes

  • No template modifications affecting existing functionality
  • No API changes
  • Backward compatible with existing configurations
  • Tests only validate existing common-library behavior

Build Status

Tests:  86/86 passing (100%)
Lint:   Passing
Build:  Successful

Changelog Entry

## Comprehensive Global Value Inheritance Tests

### Added
- Add comprehensive explicit test coverage for all 15 applicable global values
- New test file: global-inheritance_test.yaml with 20 tests covering cluster, labels, podLabels, images.*, priorityClassName, hostNetwork, dnsConfig, nodeSelector, affinity
- New test file: serviceaccount-global_test.yaml with 4 tests for serviceAccount.create
- All global values now have explicit helm-unittest tests proving inheritance and precedence behavior

### Changed
- Test suite expanded from 62 to 86 tests (24 new tests added)
- Achieved 100% explicit test coverage for applicable global values (15/15)

dpacheconr and others added 5 commits October 4, 2023 10:08
…Account

Enables the webhook job ServiceAccount to inherit global.serviceAccount.annotations,
which is critical for IAM role integration in cloud environments:
- IRSA (AWS EKS)
- Workload Identity (GCP GKE)
- Pod Identity (Azure AKS)

The ServiceAccount template now includes the common-library helper for annotations,
properly merging global annotations with the existing helm hook annotations.

Changes:
- Add serviceAccount.annotations inheritance to job-patch/serviceaccount.yaml
- Add test suite for serviceAccount annotations inheritance
- Fix pre-existing test error (notExists -> isNull in webhook_test.yaml)

Test Coverage:
- Global annotations inheritance validated
- Annotation merge behavior with helm hooks validated
- All 62 tests passing (10 test suites)
@dpacheconr dpacheconr requested a review from a team as a code owner November 27, 2025 14:05
@dpacheconr dpacheconr force-pushed the fix/global-serviceaccount-annotations branch from 04d7822 to a218554 Compare December 4, 2025 13:45
- Add global-inheritance_test.yaml with 20 tests covering cluster, labels,
  podLabels, images.registry, images.pullSecrets, priorityClassName,
  hostNetwork, dnsConfig, nodeSelector, and affinity
- Add serviceaccount-global_test.yaml with 4 tests for serviceAccount.create
- All 15 applicable global values now have explicit helm-unittest coverage
- Tests verify both inheritance (global applies when local omitted) and
  precedence (local overrides global when both set)
- Test results: 86/86 passing (24 new tests added)
- Achieves 100% global values test coverage for this chart
@dpacheconr dpacheconr force-pushed the fix/global-serviceaccount-annotations branch from a218554 to 55ac85d Compare December 4, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant