These are chat archives for etorreborre/specs2

25th
Jan 2018
Edmondo Porcu
@edmondo1984
Jan 25 2018 12:52
Why would the following snipept invoke getRecords just once?
def hasRightAnalysis  =  {
    analysisRecordConsumer.subscribe(Collections.singletonList(analysisTopic))
    def getRecords = {
      println("Invoking getrecords")
      val consumerRecord = analysisRecordConsumer.poll(10000000L)
      val records = consumerRecord.iterator().asScala.toList
      records.filter( x =>   x.key() == vatCode)
    }
    getRecords must haveSize[List[_]](1).eventually(60,new FiniteDuration(500,TimeUnit.MILLISECONDS))
  }
Eric Torreborre
@etorreborre
Jan 25 2018 13:39
Because it succeeds the first time :-)?
Edmondo Porcu
@edmondo1984
Jan 25 2018 14:07
no
it doesn't
:D
Edmondo Porcu
@edmondo1984
Jan 25 2018 16:13
@etorreborre I think I have hit an interesting problem
Edmondo Porcu
@edmondo1984
Jan 25 2018 16:34
Background: we are testing a kafka stream processor that will get a record from a topic and publish on three topics. So we create three Kafka consumers on these three topics and we polll from these topics using the eventually matchers. The problem with the eventually matchers seems to be that it blocks the main thread, the Kafka Consumers start working wrong because they operate on the same thread. If we perform the three tests separately works, however within a single specification it doesn't work
Eric Torreborre
@etorreborre
Jan 25 2018 16:54
I see, you probably cannot use eventually here
Edmondo Porcu
@edmondo1984
Jan 25 2018 17:07
I need to do some async testing
I have no idea of how to test it
Eric Torreborre
@etorreborre
Jan 25 2018 17:08
use traverse to collect values that are the result of async actions and add retries to those actions?
Edmondo Porcu
@edmondo1984
Jan 25 2018 17:14
which traverse?
Eric Torreborre
@etorreborre
Jan 25 2018 17:14
Future.traverse for example, I don't know what you are using for asynchronous calls