Skip to content

test: add tests of the Helm chart - #236

Merged
uniqueg merged 4 commits into
devfrom
test/chart
Nov 6, 2026
Merged

uniqueg merged 4 commits into
devfrom
test/chart

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds tests of the Helm chart, modelled on cloud-registry's chart tests:

  • tests/helm.py holds the helpers. render runs helm template of charts/tesk. find and get look up rendered objects. container and env return the API container and its environment. VALUES holds the default values.
  • tests/test_chart.py has 25 tests that render the chart and check the objects:
    • Defaults: the set of objects, images, versions and environment, and the Service.
    • Resources, images, port (container, Service and Ingress), TES base path and context path.
    • Security context, on and off.
    • Authentication, including the OAuth client secret and the authorization groups.
    • auth.service_info_public set to true, false or null, and the service-info ConfigMap and its mount.
    • Ingress: host, class, TLS, path and annotations, and the ingress turned off.
    • OpenShift route, NodePort, S3 and OpenStack storage, storage class, FTP (classic secret, netrc, host IP), transfer PVC, retries and debug.
  • CI: the composite action .github/actions/test-chart runs the tests after lint and render, in the Chart job, with the pinned Helm v3.22.1. REQUIRE_HELM=1 makes a missing Helm fail the job instead of skipping the tests. The Test job leaves them out (--ignore=tests/test_chart.py), so they run only with the pinned Helm. Coverage is unaffected: it measures docs/.
  • docs/development.md describes the chart tests and the CI split.

Closes #227

Verification

  • Locally with Helm 3.22.1: REQUIRE_HELM=1 pytest: 65 passed (25 chart, 40 hooks).
  • coverage run -m pytest --ignore=tests/test_chart.py: 40 passed, 100% coverage.
  • Without Helm, the chart tests are skipped. With REQUIRE_HELM=1 and no Helm, collection fails.
  • mypy and ruff (check and format): pass. actionlint: pass. mkdocs build --strict: pass.
  • CI: all jobs pass, including the chart tests in Chart; the Read the Docs preview builds.

Review

Full review: adversarial-reviewer and quality-reviewer, 2 rounds, no high findings.

  • Round 1 fixes:
    • Helpers moved to tests/helm.py.
    • More values covered: port, base path, context path, annotations, authorization groups, route host, FTP defaults.
    • Default images read from values.yaml.
    • A comment on the trimmed names.
    • Chart tests left out of Test.
    • Stricter REQUIRE_HELM.
  • Round 2: no findings.

Declined review findings

None.

Open questions

None.

🤖 Generated with Claude Code

Summary by Sourcery

Add automated Helm chart tests and integrate them into CI to validate rendered resources across the chart’s main configuration options.

Enhancements:

  • Add comprehensive Helm chart rendering tests covering default and configurable Kubernetes resources, authentication, ingress, OpenShift routes, storage backends, FTP, transfers, security, and runtime options.

CI:

  • Run Helm chart tests in the chart CI job with a pinned Helm version and fail when Helm is unavailable, while excluding them from the general coverage job.

Documentation:

  • Document Helm chart testing and its separation between the chart and general test jobs.

Tests:

  • Introduce reusable Helm rendering and manifest inspection helpers for chart tests.

uniqueg and others added 2 commits November 6, 2026 06:48
Render the chart with helm template for the default values and the
main options (resources, images, security context, auth, service info,
ingress, OpenShift route, NodePort, S3 and OpenStack storage, FTP,
transfer) and check the rendered objects. Run them in the chart job,
where a missing helm fails them (REQUIRE_HELM).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Move the helpers to tests/helm.py as in cloud-registry, cover the
port, base path, context path, ingress annotations, auth groups and
route host, read default images from values.yaml, accept only 1, true
or yes for REQUIRE_HELM, and leave the chart tests out of the test job
so they run only with the pinned Helm.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

The PR adds a reusable Helm-rendering test harness and 25 manifest-level tests for the chart’s defaults and major configuration paths, then runs them in the Chart CI job with pinned Helm while preserving the existing docs-hook coverage workflow and documenting the setup.

Sequence diagram for Helm chart manifest tests in CI

sequenceDiagram
    participant Chart as Chart CI job
    participant Action as test-chart action
    participant Pytest as pytest
    participant Helm as Helm 3.22.1
    participant Tests as tests/test_chart.py
    participant ChartFiles as charts/tesk

    Chart->>Action: run
    Action->>Helm: helm lint charts/tesk --strict
    Action->>Helm: helm template charts/tesk
    Action->>Pytest: REQUIRE_HELM=1 pytest
    Pytest->>Tests: collect 25 chart tests
    Tests->>Helm: render
    Helm->>ChartFiles: load chart and values
    Helm-->>Tests: rendered Kubernetes objects
    Tests->>Tests: find and get objects
    Tests-->>Pytest: assert manifests and configuration
Loading

File-Level Changes

Change Details Files
Added Helm-rendered chart test infrastructure and broad behavioral coverage for default and optional chart configurations.
  • Introduced shared helpers to invoke Helm, parse manifests, locate resources, and inspect the API container environment.
  • Added 25 tests covering defaults, images, resources, networking, paths, security, authentication, service info, ingress, OpenShift routes, storage backends, FTP, transfer volumes, retries, and debugging.
  • Tests skip when Helm is unavailable locally, while REQUIRE_HELM makes missing Helm fail in CI.
tests/__init__.py
tests/helm.py
tests/test_chart.py
Integrated chart tests into CI using a pinned Helm environment while keeping documentation-hook coverage isolated.
  • Extended the composite chart action to install the locked Python environment and run chart tests with REQUIRE_HELM=1.
  • Excluded chart tests from the general coverage job so they run only with the pinned Helm version in the Chart job.
  • Documented local chart testing and the split between Test and Chart CI jobs.
.github/actions/test-chart/action.yml
.github/workflows/ci.yml
docs/development.md

Possibly linked issues

  • test: add chart tests #227: The PR implements the issue’s requested chart tests and CI integration, covering defaults and main options with rendered-object assertions.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (73b9270) to head (3de7072).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #236   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines          199       199           
=========================================
  Hits           199       199           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 6, 2026 06:03

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/helm.py" line_range="55" />
<code_context>
+    for manifest in manifests:
+        # Some templates render names with trailing whitespace (e.g., the
+        # ingress), which YAML keeps in a plain scalar's value
+        if manifest["kind"] == kind and manifest["metadata"]["name"].strip() == name:
+            return manifest
+    return None
</code_context>
<issue_to_address>
**Invalid ingress name passes lookup**

When the rendered Ingress name has trailing whitespace, `find` strips `metadata.name` before comparing it, so `test_defaults` accepts an Ingress named `ingress-rules `; Kubernetes rejects that name, but the test still passes.

Compare the unmodified name and fix the ingress template so the rendered name is valid.
</issue_to_address>

### Comment 2
<location path="tests/test_chart.py" line_range="271-272" />
<code_context>
+    """S3 storage renders the secret with the AWS configuration."""
+    manifests = render("--set", "storage=s3")
+    assert set(get(manifests, "Secret", "aws-secret")["data"]) == {
+        "config",
+        "credentials",
+    }
+    assert find(render(), "Secret", "aws-secret") is None
</code_context>
<issue_to_address>
**AWS secret values go unchecked**

When the rendered secret has the expected keys but its values are empty, incorrect, or come from missing files, `test_storage_s3` checks only the keys in `Secret.data`, so it passes without verifying the AWS configuration values and a broken configuration goes unnoticed.

Assert that the rendered secret’s `config` and `credentials` values contain the expected AWS configuration.
</issue_to_address>

Linked issues

#227 test: add chart tests · 3 of 3 met

# Requirement Status Notes
1 Test the default chart and main options by rendering with Helm and checking the rendered objects. ✅ Met The chart tests cover defaults and the requested ingress, OpenShift route, storage, auth, and service-info options.
2 Run the chart tests in the CI chart job. ✅ Met The chart job invokes the test-chart action, which runs pytest with Helm required.
3 Do not report chart-test coverage to Codecov. ✅ Met The general test job excludes the chart tests from coverage; the chart job runs them separately.

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: tests/helm.py:55, tests/test_chart.py:272


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread tests/helm.py Resolved
Comment thread tests/test_chart.py Resolved
Render a copy of the chart with S3 files and check the decoded secret,
and compare object names as rendered, without stripping them (Sourcery
review).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

# Conflicts:
#	.github/actions/test-chart/action.yml
@uniqueg
uniqueg merged commit 080afd9 into dev Nov 6, 2026
21 checks passed
@uniqueg
uniqueg deleted the test/chart branch November 6, 2026 06:19
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.

test: add chart tests

1 participant