Skip to main content

SMS Orchestrator — Testing Strategy

Status: populated Owner: Platform Engineering + QA Last updated: 2026-04-18

1. Coverage targets

LayerTargetTool
Domain aggregates95%Vitest
Value objects100%Vitest
Domain services90%Vitest
Application use cases90% (branch)Vitest
Integration (HTTP + NATS + PG + Redis)All critical pathsTestcontainers
Mutation on aggregates≥ 75%Stryker
Mutation on VOs≥ 85%Stryker

2. Unit tests

  • SmsMessage state machine: every transition path + illegal transitions rejected.
  • PhoneNumber: accepts valid E.164, rejects malformed, normalizes.
  • SegmentCalculator: GSM-7 vs UCS-2 boundary cases (160/153; 70/67).
  • RetryPolicy: backoff sequence, DLQ threshold.
  • IdempotencyResolver: hit, miss, conflict (different body).

3. Integration tests (mandatory)

  • test/integration/tenant-isolation.spec.ts — RLS rejects cross-tenant reads.
  • test/integration/outbox.spec.ts — not currently used; replaced by direct publish. (Placeholder per template; mark N/A with note.)
  • test/integration/inbox.spec.tssms.outbound.request consumer dedupes redelivery via Redis SET NX.
  • test/integration/submit-happy-path.spec.ts — POST returns 202; row persisted; NATS message published; idempotency key stored.
  • test/integration/submit-idempotency.spec.ts — repeat with same Idempotency-Key → same response, no new row.
  • test/integration/pipeline-retry.spec.ts — routing-engine errors → retry chain → DLQ after 3 attempts.
  • test/integration/validation-failure.spec.ts — invalid phone → FAILED + DLQ, no retry.
  • test/integration/redis-outage.spec.ts — Redis down → SET NX fails; service should fail closed on submit path and fail open only on pipeline idempotency (documented behavior).

4. Contract tests

  • Pact consumer of routing-engine gRPC — SelectRoute request/response schemas.
  • Schema conformance for produced events against registry (sms.outbound.request.v1, smpp.operator.*.v1, sms.events.status.v1).
  • OpenAPI diff gate in CI (no breaking changes without major version bump).

5. E2E

  • test/e2e/send-sms.e2e.spec.ts — Kong → orchestrator → NATS → stubbed downstream → status transitions observed.

6. Load / soak

  • Target: 5000 TPS sustained, P95 ≤ 200 ms submit, P95 ≤ 500 ms pipeline.
  • k6 scenarios in loadtests/orch/.

7. Security tests

  • OWASP ZAP baseline against staging.
  • Tenant isolation fuzzer (random X-Tenant-Id vs JWT).