Akka typed test-kit: how can we simutate timeout of a probe?

I have a probe that interacts with an actor. At a given point, I want the probe to “die” and check that the actor does what is supposed to do.

If I use a probe.stop(), the probe terminate gracefully. I wanted to use something akin to stopping actors

TIA

I don’t understand the question. Does the actor send messages to the probe.ref? Does the actor watch the probe.ref?

Could you show an example of what you would like to do?

A little context: I launch a consumer (actor) and a producer (probe). The consumer gets a list of members in the cluster and finds the producer. It then uses a

   ctx.askWithStatus[Producer.Command, Consumer.Command](target, createRequest) {
     case Success(response)                      => response
     case Failure(t@StatusReply.ErrorMessage(_)) => ResponseFailure(t)
     case Failure(t)                             => ResponseFailure(t)
   }

to send a request to the producer. What I wanted to do is to simulate a failed producer (probe). The test is as follows:

    // Launch test kit (simulates cluster)
    val k = Kit(this.getClass.getSimpleName, List(Consumer.ID), 25251)

    // Probe is a Producer that processes (receives) Consumer messages
    val producer: TestProbe[Producer.Command] = createProducerProbe(fsmName, k)

    // Consumer processes Producer messages. It will join the cluster automatically.
    val consumer: ActorRef[Consumer.Command] = createConsumerActor(fsmName, k)

    // This emulates the Producer.
    val msg: Producer.Command = producer.receiveMessage()

What I wanted to do is stop the producer so that it would not respond to the askWithStatus.

At the moment I am having difficulties using the test-kit to access a ActorRef[StatusReply[Consumer.Command]]: I cannot generate these references manually and I cannot get access to an ActorContext to use the ask above. I think I am going to get rid of this ask pattern, which then makes this question mute.

However, I am still curious how one could go about testing the ask pattern. I also find that the internal actor reference causes issue with my tracking jobs assigned to actors. So please don’t waste too much time with this.

Thank you

The TestProbe will not automatically reply to messages.

That msg is the request message that you sent with askWithStatus (if target corresponds to the producer probe. To reply you would

msg.replyTo ! StatusReply.Error("boom")

If you want to simulate that the producer doesn’t reply you would not sent the reply.
If you want to simulate completely dead producer you would use producer.stop().

If that is in the Consumer Behavior, you would wrap it with Behaviors.setup. That is not specific to the TestKit.

Ok, I used the StatusReply with success.

Got my wires crossed here. Let me try again (sorry). Here I was trying to use an ask as shown here to simulate the Consumer’s use of askWithStatus. But I wanted to indicate the TestProbe[_] as the replyTo address.

Is this possible?

TIA