Skip to content

Add health endpoint dependency-graph tests for degraded and down states #357

@thlpkee20-wq

Description

@thlpkee20-wq

Description

src/routes/health.ts builds a HealthDependencyGraph across database, stellar-horizon, and db-pool dependencies and returns 200/503 based on aggregate status, but the degraded vs unhealthy aggregation and latency reporting need fuller test coverage. Expand src/routes/health.test.ts to exercise each dependency status combination.

Requirements and context

  • Must be secure, tested, and documented
  • Should be efficient and easy to review
  • Relevant code: src/routes/health.ts, src/routes/health.test.ts, src/db/client.ts
  • Aggregate must be unhealthy/503 when any required dependency is down

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/health-dependency-graph
  • Implement changes
    • Inject mock db health and Stellar checkers returning up/degraded/down
    • Assert aggregate status and HTTP code for each combination
    • Assert latencyMs and dependsOn are populated
  • Validate security and correctness assumptions

Test and commit

  • Run tests
    • npm test
  • Cover edge cases
    • DB up + Horizon down, all degraded, checker throws, missing optional dependency
  • Include test output and notes

Example commit message

test: cover health dependency-graph aggregation

Guidelines

  • Minimum 95 percent test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions