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
Sharding EntityRef for testing, #29267 #29336
Conversation
* adding a TestEntityRef that forwards tell and ask messages to a given probe ActorRef
Thanks, @patriknw. Looks good, works for me. If feels a little odd to have this in the |
I agree, but I can't motivate another testkit module just for this |
@@ -405,43 +401,3 @@ object EntityTypeKey { | |||
EntityTypeKeyImpl(name, messageClass.getName) | |||
|
|||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to separate EntityRef.scala file
"be useful will ClusterShardingStub" in { | ||
val probes = Map("entity-1" -> createTestProbe[String](), "entity-2" -> createTestProbe[String]()) | ||
|
||
class ClusterShardingStub extends javadsl.ClusterSharding with ClusterSharding { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should make it easier to create a stub of ClusterSharding
also?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't yet had the need for that, but this might become useful in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, let's add that later if/when needed
* Copyright (C) 2019-2020 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package akka.cluster.sharding.typed.scaladsl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we still put it in a testkit named package though?
akka.cluster.sharding.typed.testkit.{javadsl,scaladsl}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
Test PASSed. |
Test PASSed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* It forwards all messages to the `probe`. | ||
*/ | ||
object TestEntityRef { | ||
def of[M](@unused typeKey: EntityTypeKey[M], entityId: String, probe: ActorRef[M]): EntityRef[M] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks find but we sometimes get bitten for not having at least compile only tests for javadsl
probe ActorRef
References #29267
@hseeberger Would this be sufficient for what you requested? See TestEntityRefSpec for how it can be used.