Skip to content

test(tcp-balancer): add default render helm unit tests - #4093

Open
Akanksha Trehun (magic-peach) wants to merge 1 commit into
cozystack:mainfrom
magic-peach:test/tcp-balancer-helm-unittest
Open

Akanksha Trehun (magic-peach) wants to merge 1 commit into
cozystack:mainfrom
magic-peach:test/tcp-balancer-helm-unittest

Conversation

@magic-peach

@magic-peach Akanksha Trehun (magic-peach) commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

tcp-balancer was one of the eight user-facing apps in packages/apps/ called out in #3631 as shipping with zero helm-unittest coverage. This adds a tests/ suite pinning the default Deployment render (replica count, haproxy image) and wires the standard test: helm unittest . target the sibling charts already use, following the same pattern as #4081 and #4074.

Ran helm unittest . locally against the chart, it passes, and also ran the repo's full hack/helm-unit-tests.sh sweep across every package to confirm nothing else broke.

Screenshots

Not applicable, test-only change.

Downstream repositories

  • No downstream repository is affected by this change

Walked the trigger map in docs/agents/contributing.md against the diff: this only adds a test file and a Makefile target inside an existing package, it does not add, rename or remove a package, and it does not touch values.yaml, values.schema.json, Chart.yaml or README.md, so none of the listed triggers apply.

Release note

test(tcp-balancer): add Helm unit test coverage for the default render

Summary by CodeRabbit

  • Tests
    • Added Helm chart tests for the TCP balancer’s default configuration.
    • Verified that the default deployment uses two replicas and the expected container image.
    • Added a command to run the chart test suite.

tcp-balancer was one of the remaining user-facing apps with no helm-unittest coverage.

Signed-off-by: Akanksha Trehun <[email protected]>
@github-actions github-actions Bot added area/networking Issues or PRs related to networking (ingress, gateway, vpn, metallb, kube-ovn) size/S This PR changes 10-29 lines, ignoring generated files labels Sep 6, 2026
@coderabbitai

coderabbitai Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: c6d2de0b-2c7c-40a3-ab67-e1c06a96d33e

📥 Commits

Reviewing files that changed from the base of the PR and between 41f92ec and d5998c4.

📒 Files selected for processing (2)
  • packages/apps/tcp-balancer/Makefile
  • packages/apps/tcp-balancer/tests/tcp-balancer_test.yaml

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The TCP balancer chart gains a Makefile test target and a Helm unit test suite. The suite checks the default Deployment replica count and container image.

Changes

TCP balancer chart validation

Layer / File(s) Summary
Chart test entry point and default assertions
packages/apps/tcp-balancer/Makefile, packages/apps/tcp-balancer/tests/tcp-balancer_test.yaml
The Makefile adds a phony test target that runs helm unittest .. The test suite verifies two replicas and the haproxy:latest image in the default Deployment.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to d5998

This change adds TCP balancer Helm test coverage for the default replica count and HAProxy image without changing chart runtime behavior. The test entry point and assertions are ready to merge.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the addition of default-render Helm unit tests for the tcp-balancer chart.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

Akanksha Trehun (@magic-peach) NOT LGTM, because of the image assertion only. Another open PR fixes this chart, and the two collide in two places. #4366 adds the same test: target to the Makefile, which is a textual conflict. It also changes the image from haproxy:latest to haproxy:3.4.4, which turns your image assertion red.

That assertion pins the bug the other PR fixes. haproxy:latest resolves to 3.4.4 today. From 3.3 on HAProxy refuses a backend named like a frontend, so every tcp-balancer pod started now fails at config parse (#1966). The test is correct against main, but it makes that broken state part of the chart's contract.

What each side needs depends on the merge order:

  • If #4366 lands first, this PR needs a rebase that drops the Makefile hunk, since the target will already exist, and a change to the image assertion.
  • If this lands first, #4366 has to resolve the Makefile and rewrite or delete this assertion, which its image change turns red.

A prefix match keeps the check in both cases and leaves only the Makefile conflict:

  - it: renders a Deployment with the default replica count and haproxy image
    template: templates/deployment.yaml
    documentSelector:
      path: kind
      value: Deployment
    asserts:
      - equal:
          path: spec.replicas
          value: 2
      - matchRegex:
          path: spec.template.spec.containers[0].image
          pattern: '^haproxy:'

I ran it against main and against #4366, on helm-unittest 1.1.1 and 1.1.2, and it passes each time. The line that scopes the test to the Deployment template matters too. Without it the test fails on helm-unittest 1.1.1 with document not found, because the documentSelector also runs against configmap.yaml and finds no Deployment there. 1.1.2 fixed that ("Fix documentSelector not working when multiple templates are used"), and CI installs the latest plugin, so it would pass there today.

The rest holds up. Changing the image, the default replica count or the kind each turns the test red, so the selector and the two equal checks are not vacuous. The new target is picked up too. The CI unit test job runs hack/helm-unit-tests.sh, which runs a package's tests when make -n test succeeds there, and it does here. CI has not run on this PR yet, since the fork workflows are still waiting for approval.

IvanHunters added a commit that referenced this pull request Sep 22, 2026
## What this PR does

vpn was one of the eight user-facing apps in `packages/apps/` called out
in #3631 as shipping with zero helm-unittest coverage. This adds a
`tests/` suite pinning the default render and wires the standard `test:
helm unittest .` target the sibling charts already use, following the
same pattern as #4081, #4074 and #4093.

Ran `helm unittest .` locally against the chart, it passes. `make show`
needs a live cluster connection through `cozyhr`, which was not
available in this environment, so I relied on `helm unittest` for local
verification, same as the referenced sibling PRs.

### Screenshots

Not applicable, test-only change.

### Downstream repositories

Walked the trigger map in docs/agents/contributing.md against the diff:
this only adds a test file and a Makefile target inside an existing
package, it does not add, rename or remove a package, and it does not
touch `values.yaml`, `values.schema.json`, `Chart.yaml` or `README.md`,
so none of the listed triggers apply.

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
test(vpn): add Helm unit test coverage for the default render
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Tests**
- Added automated validation for the VPN deployment’s default
configuration, including replica count, container image, service port,
and generated resource naming.

- **Chores**
- Added a convenient command for running the VPN chart’s automated
tests.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/networking Issues or PRs related to networking (ingress, gateway, vpn, metallb, kube-ovn) size/S This PR changes 10-29 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants