Skip to content

Health module has no tests: liveness and readiness probes are uncovered #1131

Description

@nanaf6203-bit

Health module has no tests: liveness and readiness probes are uncovered

Labels / Complexity: testing · Medium Complexity — Medium

Problem

src/health/ (2 files, 0 *.spec.ts) implements the Kubernetes probes — GET /healthz (liveness), GET /readyz (readiness: DB + Redis), GET /startupz (startup: DB + migration state). These endpoints decide whether K8s restarts or drains the pod, yet none of them are tested: a regression that makes /readyz always report ready (or always failing) ships silently and either masks outages or causes restart loops.

Why this is architecturally hard

  1. Probe semantics need dependency stubs. Testing /readyz requires stubbing DB and Redis up/down states and asserting the correct status code and body for each combination.
  2. The endpoints are deployment-critical. The test design must cover the failure modes that matter in production: DB down, Redis down, both down.

Acceptance criteria

  • Tests cover /healthz, /readyz, and /startupz for healthy and degraded dependency states.
  • Tests run in CI via npm test.
  • The PR reports the module's coverage change (npm run test:cov).

Out of scope

Changing probe behavior or thresholds.

Getting started

  • src/health/health.controller.ts — the probe endpoints
  • src/cache/cache.service.ts — the Redis health dependency

Commands: npm test, npm run test:cov.

Good first files to read: src/health/health.controller.ts, test/e2e/analytics-date-range.spec.ts.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions