test(unit): add helm-unittest layer for template-rendering regression tests#96
Open
etgraylog wants to merge 18 commits into
Open
test(unit): add helm-unittest layer for template-rendering regression tests#96etgraylog wants to merge 18 commits into
etgraylog wants to merge 18 commits into
Conversation
…tup-python, bump checkout/setup-helm, drop deprecated token)
…o helm-ct-install
6b71664 to
b02f4c4
Compare
…nit-graylog, mongodb, ingress)
14aca72 to
efe3586
Compare
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.
Summary
Add a
helm-unittestlayer to the chart's CI: a newhelm-unittestjob in the existinglint-and-test.yamlworkflow that runshelm unittestagainst five starter test suites covering high-leverage conditional rendering across the chart. Complements #95'sct installcoverage with fast, cluster-free template-rendering regression tests — runs in ~200 ms vs. ~6 min forct install, exercising values combinations thatct installdoesn't.Why add helm-unittest on top of
ct install?#95's
ct installprovides strong end-to-end validation: chart installs, MongoDB Operator is in place,helm testpods pass against multiple Kubernetes versions. But it tests one specific values configuration (the minimal-resource overlay incharts/graylog/ci/ci-values.yaml). The chart has substantial conditional template logic — TLS on/off, plugins on/off, bundled vs. BYO MongoDB, ingress configurations, cert-manager annotation paths — thatct installdoesn't exercise.helm-unittest's distinct value:
helm installcycle.tls-credsvolume" — easy in helm-unittest, hard in install testing.Details
Workflow change
A new
helm-unittestjob in.github/workflows/lint-and-test.yaml:v3.16.4+v4.2.0) — exercises template-rendering logic across both supported Helm major versionsplugin.yamldoes NOT use theplatformHooksfield (added in v1.1.0+ which Helm 3.16.4 rejects during plugin.yaml parsing)helm plugin install --version(which clones the default branch, not a specific tag)The job runs in parallel with
helm-ct-lint(noneeds:between them — both are fast, independent signals).Updated dependency graph
The existing
helm-ct-installjob now gates on bothhelm-ct-lintANDhelm-unittest:helm-ct-lint ─┐
├─→ helm-ct-install
helm-unittest ─┘
Install (~6 min × matrix) only starts if BOTH lint and unittest pass. Saves CI compute on PRs that fail either of the fast gates.
Starter test suites (5 files, 38 tests)
charts/graylog/tests/service_test.yamlgraylog.inputsport iteration, the always-presentinput-fwd-confportcharts/graylog/tests/graylog_statefulset_test.yamlgraylog.replicasflows through, TLS volume + volumeMount conditional rendering, plugins emptyDir volume conditionalcharts/graylog/tests/init_graylog_test.yamlkeytool -importcertblock gated on TLS +updateKeyStore, plugin-copy logic gated ongraylog.config.plugins.enabledcharts/graylog/tests/mongodb_test.yamlmongodb.communityResource.enabled, version pin frommongodb.version, members/arbiters counts, arbiters >= replicas template failure, persistence sizingcharts/graylog/tests/ingress_test.yamlingress.enabledANDingress.web.enabled, TLS section rendering, cert-manager cluster-issuer vs. issuer annotationsThese are intentionally focused on conditional logic the chart actually has, not trivial templates. Templates like
auth/sa.yamlandpolicy/pdb/graylog.yamlare deliberately not covered — simple enough thatct installis sufficient. Future PRs can extend the pattern.Notes on template dependencies (for future test authors)
The Graylog StatefulSet template includes
graylog.configChecksumandgraylog.secretsChecksumhelpers, which themselvesincludeconfig/graylog.yamlandconfig/secret/secrets.yaml. helm-unittest'stemplates:filter must list those dependencies for the includes to resolve. The StatefulSet test suite usestemplate:field on each assertion to scope assertions to the StatefulSet specifically while still rendering the dependency templates.Commit history
2 commits:
ci(gha): add helm-unittest job to lint-and-test workflow
test(unit): add starter helm-unittest suites (service, statefulset, init-graylog, mongodb, ingress)
Linked issues
None. Builds on the testing infrastructure introduced in #95.
PR Checklist
Testing Checklist
Static Validation
helm lint ./charts/grayloghelm template graylog ./charts/graylog --validateInstallation
helm test graylog(covered by ci(gha): adopt chart-testing for chart CI (lint + install) #95)Functional (if applicable)
Upgrade (if applicable)
Specific to this PR
helm unittest charts/graylogpasses locally on Helm v4.2.0: 5 test suites, 38 tests, ~200 ms.26734982194: bothhelm-ct-lintHelm variants, bothhelm-unittestHelm variants, and all 4helm-ct-install(Helm × K8s) variants.helm-ct-installcorrectly gates on bothhelm-ct-lintANDhelm-unittest— install starts only after the fast gates pass.Notes for reviewers
plugin.yamladds aplatformHooksfield that Helm 3.x rejects. Worth tracking upstream (helm-unittest/helm-unittest) for a Helm-3-compatible release.charts/graylog/tests/are helm-unittest test definitions (YAML configs withsuite:/templates:/tests:/asserts:). They are NOT to be confused with the in-clusterhelm testpods atcharts/graylog/templates/tests/test-*.yaml, which are Pod manifests used byhelm testpost-install. Both layers coexist and serve different purposes.