Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interaction between ExplicitlyTriggeredScheduler & streams timers #31389

Open
DanielMoss opened this issue May 7, 2022 · 1 comment
Open
Labels
help wanted Issues that the core team will likely not have time to work on t:stream t:testing

Comments

@DanielMoss
Copy link
Contributor

Hi. I've been playing with ExplicitlyTriggeredScheduler and noticed it doesn't behave as you might expect if you integrate its usage with some of the streams operators. For example, in the code below you'd naively expect the probe to receive a timeout as a result of calling scheduler.timePasses, but no such timeout is received.

import scala.concurrent.duration.DurationInt

import akka.actor.ActorSystem
import akka.stream.scaladsl.Source
import akka.stream.testkit.scaladsl.TestSink
import akka.testkit.ExplicitlyTriggeredScheduler
import com.typesafe.config.ConfigFactory

object Reproduction extends App {
  implicit val system: ActorSystem = ActorSystem(
    "test",
    config = Some(ConfigFactory.parseString(
      """akka.scheduler.implementation = "akka.testkit.ExplicitlyTriggeredScheduler""""
    ))
  )

  val scheduler = system.scheduler.asInstanceOf[ExplicitlyTriggeredScheduler]
  val probe = Source.never.idleTimeout(10.seconds).runWith(TestSink.probe)
  scheduler.timePasses(20.seconds)
  
  // Exception in thread "main" java.lang.AssertionError: assertion failed: timeout (3 seconds) during expectMsgClass waiting for class akka.stream.testkit.TestSubscriber$OnError
  probe.expectSubscriptionAndError()
}

The reason for this is that a number of stream operators, including Idle, work by inspecting the system time when the background timer expires.

There's no documentation suggesting streams should play nicely with ExplicitlyTriggeredScheduler, but I thought I'd raise this for awareness anyway.

@lolczak
Copy link

lolczak commented May 26, 2022

+1

@johanandren johanandren added the help wanted Issues that the core team will likely not have time to work on label May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that the core team will likely not have time to work on t:stream t:testing
Projects
None yet
Development

No branches or pull requests

3 participants