Skip to main content
InterviewHubPRO
Section Overview
Q47

Question 47 of 50

Part 3: Advanced Internals, Scale & Production Quality (Senior / Lead)

94%
Software Testing & QA (50 Qs)•Part 3: Advanced Internals, Scale & Production Quality (Senior / Lead)

Testing Asynchronous Event-Driven Architectures: Validating Kafka / RabbitMQ consumer processing.

senior LevelCode ExampleTestingAsync & PromisesSystem Design

In Simple Words: Testing distributed systems where publishers and consumers communicate asynchronously over message brokers:

  1. Producer publishes OrderCreated event to Kafka (running via Testcontainers).
  2. Polling Assertions: Never use sleep(5000)! Use polling libraries (e.g. awaitility in Java, or Playwright's expect.poll() in TypeScript):
    typescript
    await expect.poll(async () => {
      return await db.query('SELECT status FROM orders WHERE id = $1', [orderId]);
    }, { timeout: 10000, intervals: [200] }).toBe('PROCESSED');
    
  3. Verifies that background async consumers processed the message and committed the database transaction without race conditions.