fd4s / fs2-kafka

Functional Kafka Streams for Scala
https://fd4s.github.io/fs2-kafka
Apache License 2.0
296 stars 101 forks source link

Fix flaky `KafkaConsumer#assignmentStream` tests #1274

Closed aartigao closed 1 year ago

aartigao commented 1 year ago

There's no need to consume a topic's records in order to test the partition assignments.

This causes a race condition where, if consumer.records occurs first, the initial expected empty assignment is not streamed 👇🏽 (see the missing first TreeSet()):

[info] - should stream assignment updates to listeners *** FAILED *** (10 seconds, 632 milliseconds)
[info]   List(TreeSet(topic-2b357246-81b5-460d-ba2e-822ed148e635-0, topic-2b357246-81b5-460d-ba2e-822ed148e635-1, topic-2b357246-81b5-460d-ba2e-822ed148e635-2), TreeSet(), TreeSet(topic-2b357246-81b5-460d-ba2e-822ed148e635-0, topic-2b357246-81b5-460d-ba2e-822ed148e635-1)) had length 3 instead of expected length 4 (KafkaConsumerSpec.scala:803)