Bird
0
0

How can you test a Kafka Streams topology that aggregates counts per key using TopologyTestDriver?

hard📝 Application Q9 of 15
Kafka - Advanced Stream Processing
How can you test a Kafka Streams topology that aggregates counts per key using TopologyTestDriver?
APipe multiple records with same keys and verify output topic has updated counts
BPipe one record per key and check output for count 1 only
CUse a real Kafka cluster to test aggregation logic
DTest aggregation by reading input topic after processing
Step-by-Step Solution
Solution:
  1. Step 1: Understand aggregation testing

    Aggregation updates counts as multiple records with same key arrive.
  2. Step 2: Test approach

    Feeding multiple records with same keys and verifying output counts tests aggregation correctly.
  3. Step 3: Evaluate other options

    Single record tests only initial count; real cluster not needed; reading input topic does not verify aggregation.
  4. Final Answer:

    Pipe multiple records with same keys and verify output topic has updated counts -> Option A
  5. Quick Check:

    Test aggregation by multiple inputs and output counts [OK]
Quick Trick: Aggregate by piping repeated keys and checking output counts [OK]
Common Mistakes:
  • Testing with only one record per key
  • Using real cluster instead of test driver
  • Checking input topic instead of output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes