jpzk / mockedstreams

Scala DSL for Unit-Testing Processing Topologies in Kafka Streams
Apache License 2.0
187 stars 24 forks source link

Can't test for table build delays? #54

Open Miles-Garnsey opened 5 years ago

Miles-Garnsey commented 5 years ago

When Kafka builds a local table, it often takes some time to stream all of the records in. This means that doing a join against this table may fail due to the matching record not yet appearing.

I am trying to write a test to detect this issue, with topology and inputs as below;

val mstreams = MockedStreams()
      .topology(b => {
        ...some join logic...
        })
        .input(StreamforTable,
        someserde,
        someserde,
        irrelevantInputForTable) //A seq with 100 000 elements.
       .input(StreamForTable,
        someserde,
        someserde,
        relevantInputForTable) // A seq with one element that matches the third input() call.
      .input(StreamToJoin,
        someserde,
        someserde,
        singleRecordShouldMatch)

The intention is that the irrelevant input (in the first call to input()) should overwhelm the app, causing a delay in adding the relevant input (in the second call to input()) to the table. The join should then fail. But it appears that the input() calls are processed sequentially, which means that this isn't working.

Does anyone have any ideas on how to write this test?