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

Akka.Hosting.TestKit: TestActor is no longer the implicit sender #237

Open
Aaronontheweb opened this issue Feb 21, 2023 · 3 comments
Open
Labels
bug Something isn't working testkit Akka.Hosting.TestKit fixes and issues.
Milestone

Comments

@Aaronontheweb
Copy link
Member

Version Information
Version of Akka.NET? 1.0.3
Which Akka.NET Modules? Akka.Hosting.TestKit

Describe the bug

 foreach (var i in Enumerable.Range(0, 2))
        {
            var update1 = Dsl.Update(CounterKey, GCounter.Empty, WriteLocal.Instance,
                g => g.Increment(selfAddress));
            replicator.Tell(update1);
            UpdateSuccess success1 = ExpectMsg<UpdateSuccess>();
        }

Fails and UpdateSuccess is a DeadLetter - this is because ActorRefs.NoSender is the sender.

Expected behavior

TestActor should be the implicit sender, just like in the normal testkit.

Actual behavior

There is no implicit sender.

Workaround

Can explicitly specify the TestActor as the sender.

 foreach (var i in Enumerable.Range(0, 2))
        {
            var update1 = Dsl.Update(CounterKey, GCounter.Empty, WriteLocal.Instance,
                g => g.Increment(selfAddress));
            replicator.Tell(update1, TestActor);
            UpdateSuccess success1 = ExpectMsg<UpdateSuccess>();
        }
@Aaronontheweb Aaronontheweb added bug Something isn't working testkit Akka.Hosting.TestKit fixes and issues. labels Feb 21, 2023
@Aaronontheweb Aaronontheweb added this to the 1.5.1 milestone Mar 6, 2023
@gunters63
Copy link

It would be nice if this can be fixed. We are currently migrating to Akka.Hosting in this is one of the little roadblocks as we have to touch a lot of places for this workaround.

Other than that Akka.Hosting is a great addition, it makes a lot of custom code unnecessary. We had our own system of registering root actors in .Net DI, had our own Testkit with DI support etc etc.

@Aaronontheweb
Copy link
Member Author

I believe this has been fixed via xUnit - I'm no longer able to reproduce the problem: #458 (comment)

PLEASE REOPEN THIS ISSUE IF YOU ENCOUNTER PROBLEMS ON v1.5.30.1 OR LATER

@Aaronontheweb
Copy link
Member Author

Looks like this race condition is sneakier than I thought - was able to reproduce it this morning on #458 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working testkit Akka.Hosting.TestKit fixes and issues.
Projects
None yet
Development

No branches or pull requests

2 participants