lex82
lex82

Reputation: 11317

How to disable Akka Dead Letters warnings in Tests

I recently upgraded to Akka 2.6.10. Now I'm seeing a lot of warnings like this when I run tests for my actors with ActorTestKit:

[WARN] [12/16/2020 09:03:14.995] [AsyncTestWithControlledTime-akka.actor.internal-dispatcher-3] [akka://AsyncTestWithControlledTime/user/$a] received dead letter: GotCriticalFailure(my custom error message,akka.stream.AbruptStageTerminationException: GraphStage [akka.stream.impl.ActorRefSinkStage$$anon$1@15cc9eaa] terminated abruptly, caused by for example materializer or actor system termination.)

AyncTestWithControlledTime is a class I wrote and is a super class of all my tests. It creates the test kit and provides the config for the actor sytem. However, trying to suppress the warnings via the config, for instance with akka.log-dead-letters = off, does not help.

I usually receive the warnings when my actor has subscribed to a stream and the test finishes so the stream is not properly cancelled.

How can I disable the warnings. It would be best if I could suppress them only when the test is finished and the test kit actor system is shut down.

Upvotes: 0

Views: 593

Answers (1)

johanandren
johanandren

Reputation: 11479

That log entry is from the akka.testkit.TestEventListener (or some subclass of it) part of the Akka testkit, it is only present if you have explicitly enabled it through config with akka.loggers = ["akka.testkit.TestEventListener"].

The akka.log-dead-letters setting only has effect on the default dead letter handler, not the testkit one.

If you don't use the logging testkit you can simply remove that config from your config in the test, if you use it you can perhaps use TestEvent.Mute with a filter for that specific warning. Mute is published on the event bus and picked up by the TestEventListener.

Upvotes: 1

Related Questions