test(helm): add k3s integration test for chart deploy#160
Conversation
|
🚀 First PR — welcome aboard! A few things to expect:
If you get stuck, reply here or jump to Discussions. We want this PR to land. |
Add two new Prometheus metrics for per-program eBPF load tracking:
- kerno_bpf_program_loaded{program} gauge: 1 if loaded, 0 if failed
- kerno_bpf_program_load_errors_total{program,reason} counter
Wire metrics into buildCollectors in doctor.go so each program
reports its load result individually.
Also fix gen_stub.go build tag to use !ebpf instead of architecture
exclusions so stub types compile correctly on amd64/arm64.
Fixes optiqor#25
Signed-off-by: Hanu-man12 <shawharshit116@gmail.com>
- Import internal/metrics package in doctor.go
- Set BPFProgramLoaded{program}=0 and increment
BPFProgramLoadErrorsTotal{program,reason} on load failure
- Set BPFProgramLoaded{program}=1 on successful load
- Also emit metrics on collector registration failure
Closes optiqor#25
Signed-off-by: Hanu-man12 <shawharshit116@gmail.com>
Re-save doctor.go as UTF-8; replace 11 ??? artifacts (10 em-dashes and 1 checkmark in --quiet mode output) with the original characters. Corruption was introduced when the file was re-saved through a non-UTF-8 codepage during CRLF normalisation. Also add unit tests for BPFProgramLoaded GaugeVec and BPFProgramLoadErrorsTotal CounterVec to verify correct registration, label cardinality, and value semantics. Signed-off-by: Hanu-man12 <shawharshit116@gmail.com>
Add an end-to-end integration test that: - Boots a k3s cluster via testcontainers-go (rancher/k3s:v1.31.4-k3s1) - Installs the kerno Helm chart using the helm binary - Asserts the DaemonSet rolls out (DesiredNumberScheduled > 0 and NumberReady == DesiredNumberScheduled) - Asserts /healthz and /readyz return HTTP 200 CI overrides (busybox image + non-privileged securityContext) allow the test to run without a real eBPF-capable kernel. The test is gated behind -short skip and a helm-binary check so it does not block unit-test runs in environments without Docker or helm. Closes optiqor#149 Signed-off-by: Hanu-man12 <shawharshit116@gmail.com>
320bb63 to
0c8fe6c
Compare
|
Hi @btwshivam 👋 The Root cause: All checks pass locally:
One-line fix needed in GO_VERSION: "1.26" # was "1.25" |
btwshivam
left a comment
There was a problem hiding this comment.
the integration test is missing its build tag so it lands in the default gate (that's the red ci), plus unrelated bpf metrics and a go 1.26 bump rode in. add the tag and split the scope.
| // go test -v -tags integration -timeout 10m ./tests/integration/ | ||
| // | ||
| // Requires Docker (or a compatible OCI runtime) and the `helm` binary on PATH. | ||
| package integration |
There was a problem hiding this comment.
the package doc says run with -tags integration, but there's no //go:build integration constraint, so this compiles in the default go test ./... gate and pulls the k3s/client-go tree into the unit run. that's the red Lint and Test. add the build tag (see #164 for the pattern).
| logger.Debug("failed to load eBPF program; collector disabled", | ||
| "program", r.name, "error", err) | ||
| // Emit per-program load failure metrics. | ||
| metrics.BPFProgramLoaded.WithLabelValues(r.name).Set(0) |
There was a problem hiding this comment.
per-program bpf load metrics are a separate feature from a helm k3s test (this is the #25 work). scope creep, split it out.
| module github.com/optiqor/kerno | ||
|
|
||
| go 1.25.4 | ||
| go 1.26.0 |
There was a problem hiding this comment.
don't bump the go directive to 1.26 as a side effect of adding a test, ci runs 1.25 and nothing here needs 1.26.
|
Hi @btwshivam — I looked into this. The Two options:
Which approach do you prefer? |
What
Adds an end-to-end integration test that boots a real k3s cluster via
testcontainers, installs the kerno Helm chart, and asserts the DaemonSet
rolls out and
/healthz+/readyzendpoints return HTTP 200.Why
Fixes #149
How
testcontainers-go/modules/k3sto spin up a k3s cluster in Dockerhelmbinary with CI-safe overrides (busybox image, non-privileged securityContext)DesiredNumberScheduled > 0andNumberReady == Desired/healthzand/readyzreturn HTTP 200 viaclient-goservice lookup-tags integrationso it never runs in the normal unit-test passTesting
go build ./...passesgo test ./...passesgo vet ./...passesgolangci-lint run ./...passesgo test -v -tags integration -timeout 10m ./tests/integration/sudo ./bin/bpf-verify --read 5sconfirms 6/6 programs still load./scripts/verify.shpassesChecklist
test(helm): subject)git commit -s)scripts/verify.sh