0

I have an application code that produce events to a Kafka Topic. So now I needed to write Integration tests for it. After searching on internet, I got confused with definition of Integration test that whether should I use embedded Kafka server provided by spring-kafka-test library or shall I test my code with actual Kafka cluster that I am going to use?

What would be the integration test here? Somebody please help clear my confusion.

My Test would be: First produce a record to a topic and then consume it whether it actually produced.

Vip
  • 1,448
  • 2
  • 17
  • 20

1 Answers1

0

Each project might have different needs, and that why each dev might thinks something is or isn't enough.

The more complete (but expensive) suite of tests would:

  1. Test in isolation the producer
  2. Test a the producer with embedded kafka
  3. Test the producer with a kafka instance with test config (one node, local)
  4. Test the producer with kafka with production config in Staging environment (multi-node, in the actual server but "test environment", as a CI/CD pipeline)
  5. Test the producer in actual production to stress test the production server, and have assurance that the product is behaving well (think Simian Army)

How much of this is worth is up to you:

  • I'll do 1 because TDD
  • 3 also is cheap, makes 2 redundant and gives you reassurance that the actual "integration" is working I always do 3.
  • 4 is necessary and common for any product in production, its automated on top of 3.
  • 5 is only achieved by few companies, it actually costs significant money to "attack yourself" in your actual production environment, just to assure that everything is working great.

Each is test layer is as important as you give it importance and could be seems as "coverage" because certain bugs only occur in the next layer.

Coding Edgar
  • 1,285
  • 1
  • 8
  • 22