How do you test APIs that use eventual consistency?
- eventual consistency
- distributed systems
- polling
Answer it first, then compare. Nothing here is saved or scored.
Model answer
Eventually consistent systems require patience and polling in tests. Approach: (1) After a write, poll the read endpoint with exponential backoff until the data appears (with a max timeout). (2) Test the consistency window, verify reads return stale data within the window. (3) Test conflict resolution, concurrent writes should resolve predictably. (4) Test cross-region consistency if applicable. (5) Never assume immediate consistency in tests, always use retry/polling assertions. Tools: custom polling helpers, expect.poll() in Playwright.
What interviewers listen for
- Schema-first thinkingYou validate response shape before you assert on values, every time.
- Status-code literacyYou can defend why 401 vs 403 vs 422 matters for the consumer.
- Contract awarenessYou know when consumer-driven contract tests beat end-to-end checks.
- Auth fluencyYou can describe rotating tokens across parallel workers without secrets in logs.