newrelic-pixie: Add Comprehensive Global Value Inheritance Test Coverage#2024
Open
dpacheconr wants to merge 16 commits into
Open
newrelic-pixie: Add Comprehensive Global Value Inheritance Test Coverage#2024dpacheconr wants to merge 16 commits into
dpacheconr wants to merge 16 commits into
Conversation
…ages Make the newrelic-pixie integration images respect the global.images.registry setting, enabling consistent private registry configuration across nri-bundle. Changes: - Updated values.yaml to keep default image repositories with clarifying comments - Added helpers to _helpers.tpl to check global.images.registry fallback - Updated job.yaml to use new image helpers - Both clusterRegistrationWaitImage and main image now support global registry Implementation details: - If global.images.registry is set AND repository matches default, uses global registry - If repository is explicitly set to custom value, that takes precedence - If global registry is not set, defaults to original paths Tested scenarios: ✓ Global registry is used when set and repository is default ✓ Defaults to standard image paths when global registry not configured ✓ Explicit repository configuration overrides global registry
Update imagePullSecrets handling to cascade from global.images.pullSecrets: - Added newrelic-pixie.imagePullSecrets helper in _helpers.tpl - Added newrelic-pixie.clusterWaitImagePullSecrets helper (for future use) - Updated job.yaml to use imagePullSecrets helper combining global and chart-level Configuration hierarchy: 1. global.images.pullSecrets (applied first) 2. image.pullSecrets (applied second - chart level) Both sources are concatenated to support flexible secret management. The helper uses toYaml for consistent formatting with existing patterns.
Add support for cascading pullPolicy from global.images.pullPolicy setting:
- Added pullPolicy helpers to _helpers.tpl for both init and main containers
- Updated job.yaml to use pullPolicy helpers
Configuration hierarchy for pullPolicy:
1. global.images.pullPolicy (highest priority)
2. Chart-level image.pullPolicy
3. Default: IfNotPresent
Users can now configure pull policy globally:
global:
images:
pullPolicy: Always
…ge path - Fix pullPolicy precedence: chart-specific > global.images.pullPolicy > default (IfNotPresent) - Restore clusterRegistrationWaitImage default to full GCR path (gcr.io/pixie-oss/pixie-dev-public/curl) - Update registry helper to compare and strip against full default path - Remove unused clusterWaitImagePullSecrets helper
- Preserve original tests untouched - Add tests for registry, pullPolicy, pullSecrets on both main image and init container - Cover all precedence cases: chart-specific > global > default - Use YAML anchor (&global_images_base) and alias (<<: *) to avoid set block repetition in new tests
- Add helper functions for all applicable global values: - images.registry, images.pullSecrets, images.pullPolicy - proxy, nodeSelector, tolerations, affinity, priorityClassName - podSecurityContext, containerSecurityContext, dnsConfig, hostNetwork - labels, podLabels (merged), verboseLog - Update job.yaml template to use global value helpers - Implement proper precedence: local > global > defaults - Support air-gapped registries via global.images.registry - Support global proxy configuration for HTTP/HTTPS connectivity - Support global scheduling constraints (nodeSelector, tolerations, affinity) - All template changes maintain backward compatibility This change ensures newrelic-pixie respects global configuration values while maintaining backward compatibility and allowing subchart-specific overrides to take precedence.
Change precedence from global > local to local > global: - cluster: local takes precedence over global - licenseKey: local takes precedence over global - apiKey: local takes precedence over global - customSecretName: local takes precedence over global - customSecretLicenseKey: local takes precedence over global Also added comprehensive test suite with 30+ tests covering: - Proxy global inheritance - Image registry/pullPolicy/pullSecrets - NodeSelector, tolerations, affinity - Pod/container security context - DNS config and hostNetwork - Labels and podLabels - All scenarios with local overrides taking precedence
…assing - Simplified array/object assertions to use isNotNull for complex structures - Fixed test expectations for simplified assertions - All 27 tests now passing (100% pass rate) - Covers proxy, images, scheduling, security, networking, labels - Tests precedence: local > global > defaults - Validates comprehensive scenarios with multiple globals
- Updated README.md with comprehensive global values documentation - Clarified precedence model: local > global > defaults - Added table of 18 supported global values with descriptions - Added important note about apiKey requiring separate auth (not global.licenseKey) - Included example showing global values with required apiKey - Added comments to values.yaml explaining precedence for key values - Explained proxy, nodeSelector, tolerations, and affinity inheritance
…stablished pattern - Replace verbose multi-line precedence explanations with concise single-line format - Add helm-docs compatible '# --' prefix to all value descriptions - Align comment style with other New Relic charts (nri-kubernetes, nri-kube-events) - Change 'Precedence: local > global > default' to 'Can be configured also with global.<value>' - Add @default annotations for image and resource sections - Improve clarity while maintaining all necessary information This change ensures consistency across all New Relic Helm charts and enables proper documentation generation via helm-docs tool.
- Replace 7 weak assertions (isNotNull, isKind) with explicit value checks - Add 8 missing local override tests for labels, priorityClassName, containerSecurityContext - Add explicit tests for implemented but untested globals: customSecretName, customSecretLicenseKey, nrStaging - Add licenseKey environment variable validation test - Standardize test format with clear test descriptions matching assertion patterns Test Results: 36/36 passing (100%) - All 18 applicable global values now have explicit test coverage - Tests validate both global propagation and local override precedence - All tests use explicit value assertions, no weak presence-only checks Documentation Updated: - Known Limitation: global.images.pullPolicy not propagated (defaults block inheritance) - Known Limitation: global.verboseLog not integrated in template (only local .Values.verbose works) - Known Limitation: nrStaging helper has backwards precedence logic (prefers global over local) These issues should be addressed in template fixes but tests now accurately reflect current behavior.
Fixed three known limitations using patterns from other nri-bundle charts: 1. global.images.pullPolicy now propagates correctly - Removed defaults from values.yaml for pullPolicy (set to empty strings) - Updated helper to check local first, then global, then default - Now follows Local > Global > Default precedence pattern - Added test: 'Image pull policy NOW propagates from global value' 2. global.verboseLog now integrated in template - Added verbose and nrStaging fields to values.yaml (were missing) - Updated job.yaml template to use verboseLog helper - Precedence: local .Values.verbose > global.verboseLog - Added test: 'VerboseLog NOW propagates from global value' 3. nrStaging precedence fixed (was backwards) - Fixed helper to check local first, then global - Changed from: global > local (wrong) to local > global (correct) - Added test: 'NrStaging NOW respects local override (precedence fix)' Test Results: 39/39 passing (100%) - 36 existing tests continue to pass - 3 new tests verify the fixes work correctly - All 18 applicable global values fully functional with proper precedence These fixes bring newrelic-pixie in line with other charts like newrelic-infra-operator that use the standard Local > Global > Default precedence pattern.
…nd imagePullSecrets - Change imagePullSecrets helper to use toYaml|trim instead of toJson to avoid fromJson array deserialization failure at render time - Remove fromJson from job.yaml tolerations and imagePullSecrets template pipelines since helpers now emit YAML directly - Simplify nodeSelector key in comprehensive test to avoid dot-in-path assertion issues
1e4cc0a to
68b94fc
Compare
Contributor
Author
|
Rebased onto master. |
…y into comprehensive global inheritance PR
helm-unittest v1.0.3 does not support backslash-escaped dots in path expressions (data.custom1\.yaml). Assert on the entire data map instead to avoid the path parsing issue.
98e4d05
ec172f8 to
c2a1c73
Compare
vrajpurohitNR
approved these changes
Mar 26, 2026
vrajpurohitNR
left a comment
There was a problem hiding this comment.
Everything looks good. Approved!
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds comprehensive test coverage with explicit validation of global value inheritance for the newrelic-pixie chart, and fixes four template bugs that were blocking proper global value propagation. The chart already implements global value support through helper templates. This PR includes 43 explicit tests validating all 18 applicable global values with full Local > Global > Default precedence. Four template fixes resolve critical issues that were preventing global values from working correctly:
toJsonproducing JSON arrays, butjob.yamlpiped throughfromJsonwhich only handles JSON objects — causing a render-time panic (now fixed)Changes
Fixed Template Bugs
templates/job.yamlAdded Test Suite
charts/newrelic-pixie/tests/global_inheritance_test.yamlcharts/newrelic-pixie/tests/jobs.yaml(file was never executed due to wrong naming convention; assertions broken by new env vars added in this PR)Test Results
Test coverage includes:
Global Values Coverage
All 27 global values from the nri-bundle global contract assessed:
Legend:
Yes- Chart includes explicit helm-unittest test coverageNo- Value not applicable to this chart typeFixed Template Limitations
All previously identified template limitations have been resolved:
1. global.images.pullPolicy Now Propagates
pullPolicy: IfNotPresent) blocked global fallback2. global.verboseLog Now Integrated
3. nrStaging Precedence Fixed
4. tolerations and imagePullSecrets Array Serialization Fixed
toJsonwhich produces a JSON array ([...]). Thejob.yamltemplate piped this throughfromJson | toYaml | nindent— but Helm'sfromJsononly unmarshals JSON objects ({...}), not arrays, causing a render-time panic:Error: 'json: cannot unmarshal array into Go value of type map[string]interface {}'toYaml | triminstead oftoJson; removedfromJsonfrom the template pipelines in job.yamlAll fixes follow the standard pattern used across other nri-bundle charts with consistent Local > Global > Default precedence throughout.
Files Modified
charts/newrelic-pixie/templates/job.yaml- Integrated verboseLog helper, ensured proper precedence, removedfromJsonfrom tolerations and imagePullSecrets pipelinescharts/newrelic-pixie/templates/_helpers.tpl- Fixed nrStaging precedence (Local > Global), improved pullPolicy fallback, fixed tolerations/imagePullSecrets to usetoYaml | trimcharts/newrelic-pixie/values.yaml- Removed blocking defaults, added verbose/nrStaging fieldscharts/newrelic-pixie/tests/global_inheritance_test.yaml- Added 38 comprehensive test casescharts/newrelic-pixie/tests/jobs.yaml- Fixed 5 pre-existing tests broken by PR changescharts/newrelic-pixie/Chart.yaml- Bumped version 2.1.5 → 2.1.6CHANGELOG.md- Added test suite and bug fix entries under UnreleasedNo Breaking Changes
Build Status
Changelog Entry