NVIDIA / NVIDIA/nvcf

nvca operator Agent.Start has no integration test coverage for its HTTP routes

Open
#1,918 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
218
Forks
72
Avg merge
1d 12h
Merged PRs (30d)
427

Description

Description

reconcile.Agent.Start (src/compute-plane-services/nvca/pkg/operator/reconcile/agent.go) wires up the operator's HTTP server (/healthz, /version, /info, /metrics), but no test in agent_test.go actually calls Start(). TestAgent explicitly avoids it, with an inline comment noting it would cause duplicate Prometheus metrics registration.

That specific blocker is a small fix: metricsName is an unexported Agent field hardcoded to "nvca_operator" in NewAgent(), and since the test is in the same package it could just randomize it before calling Start(), mirroring the pattern already used for the test's own metrics.WithDefaultMetrics call.

The bigger blocker: Start() unconditionally re-runs the full NewBackendK8sCacheBuilder()...Start(ctx) pipeline regardless of any pre-built mock backendk8scache, and that pipeline does real informer cache syncs against the K8s API. TestAgent's kubeconfig points at a fake, non-listening address, so a real Start() call would likely hang or fail there. Closing this gap needs either an envtest control plane, a fake dynamic client threaded all the way through the builder, or a refactor of Start() to accept an injectable builder/cache.

Why this matters

Without this, a regression that drops route registration in Agent.Start (e.g. accidentally removing AddInfoRoute, AddVersionRoute, etc.) would not be caught by any test in this package.

Definition of Done

  • reconcile.Agent.Start is exercised by a test that asserts its HTTP routes actually respond.
  • The test does not depend on a real K8s API server being reachable.

References

Found via CodeRabbit review on #1908, which added /info and covered the equivalent gap on the pkg/nvca/agent.go (non-operator) side but intentionally left this operator side out of scope.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with reconcile/agent.go and reconcile/agent_test.go, especially Agent.Start and TestAgent. Run the existing operator tests, then determine how to exercise Start without real Kubernetes API access, using the issue's envtest, fake client, or injectable builder options. Done means the test calls Start, verifies /healthz, /version, /info, and /metrics respond, and remains independent of a reachable Kubernetes server.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
backend, infrastructure, testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.