Menu
ESC

Nhập từ khóa để tìm kiếm

↑↓ Di chuyển
Enter Mở
ESC Đóng

Đang tải...

Bài 45 — Microservices Testing Strategy

Test Strategy and QA Leadership Bài 45/60

Microservices Testing

Challenge

  • 50+ services interdependent.
  • Each team owns service.
  • Versioning hell.
  • Test environment expensive (run all 50 services?).

Test layers

  • Unit — within service.
  • Component — single service in isolation.
  • Contract — consumer-provider agreement.
  • Integration — couple service + DB.
  • End-to-end — full system (sparingly).

Honeycomb model

Spotify model: focus on Integrated tests (cross-service), less Implementation Detail tests.

Consumer-driven contract (CDC)

  • Consumer (frontend) writes contract.
  • Producer (backend) verifies in CI.
  • Backend break contract → consumer CI fail.
  • Pact Broker stores contracts.

Service virtualization

Mock downstream service in test.
  • Hoverfly, WireMock, Mountebank.
  • Record real interactions → replay.

End-to-end in microservice

  • Expensive: spin up 20 services.
  • Use shared staging environment.
  • Limit to 10-20 critical journeys.
  • Run nightly, not per commit.

Versioning strategy

  • Semantic versioning.
  • Backward-compatible by default.
  • Breaking change → new version, run both.
  • Sunset old version after 6 months.

Observability

  • Distributed tracing (Jaeger, Honeycomb).
  • Service mesh (Istio) for service-level metric.
  • Log aggregation (ELK, Datadog).

VN context

Tiki: 200+ microservices. Shopee VN: similar scale. MoMo: heavy microservice for payment. FPT product groups adopting microservice 2022+ — testing strategy evolving.

Common pitfall

  • E2E everything → slow, flaky pipeline.
  • No contract test → integration bug surprise.
  • Shared DB between service → not really microservice.