Skip to content

Commit

Permalink
Fix flaky RunloopSpec (#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
guizmaii authored Feb 27, 2023
1 parent 7215090 commit 40e6124
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import zio.kafka.consumer.diagnostics.{ DiagnosticEvent, Diagnostics }
import zio.kafka.consumer.internal.Runloop.Command
import zio.kafka.consumer.{ Consumer, ConsumerSettings }
import zio.kafka.embedded.Kafka
import zio.test.TestAspect.nonFlaky
import zio.test._
import zio.{ durationInt, Scope, ZIO }

Expand All @@ -18,8 +19,9 @@ object RunloopSpec extends ZIOKafkaSpec {
private val runSpec =
suite("::run")(
test("Immediately triggers a first Poll command, doesn't wait an initial `pollFrequency` to trigger it") {
val oneCycle = 1.second
val twoCycles = 2.seconds
val halfACycle = 500.milliseconds
val oneCycle = 1.second
val twoCycles = 2.seconds

for {
kafka <- ZIO.service[Kafka]
Expand All @@ -29,7 +31,7 @@ object RunloopSpec extends ZIOKafkaSpec {

before <- diagnosticsQueue.takeAll

_ <- TestClock.adjust(10.milliseconds)
_ <- TestClock.adjust(halfACycle)
justAfterBoot <- diagnosticsQueue.takeAll

_ <- TestClock.adjust(oneCycle)
Expand All @@ -51,7 +53,7 @@ object RunloopSpec extends ZIOKafkaSpec {
afterCycle_3.isEmpty,
afterCycle_4.size == 1 && afterCycle_4.head == DiagnosticEvent.RunloopEvent(Command.Poll)
)
}
} @@ nonFlaky(10)
)

override def spec: Spec[TestEnvironment with Kafka with Scope, Any] =
Expand Down

0 comments on commit 40e6124

Please sign in to comment.