OrleansContrib / OrleansTestKit

Unit Test Toolkit for Microsoft Orleans
http://dotnet.github.io/orleans
MIT License
78 stars 43 forks source link

Concurrent Test Grain Factory #155

Closed cmeyertons closed 4 months ago

cmeyertons commented 7 months ago

The TestGrainFactory can be invoked outside the Orleans thread-safety guarantees in a parallel fashion by code that is invoking via IClusterClient and should offer functionality for concurrency guarantees.

I received an error in some new code in our codebase that we had to re-shape business logic to satisfy the unit test error

seniorquico commented 7 months ago

To be clear... the entire TestKit operates without Orleans concurrency guarantees. From the README:

The simulated grain activation context does not provide the single-threaded execution model of the Microsoft Orleans runtime. It is up to you to ensure the grain activation is used appropriately. Unfortunately, this may result in abnormal method execution or behaviors that are impossible to reproduce, especially in reentrant grains.

From the PR description and based on the new test added, it sounds like the SUT is not a grain activation, but instead some other service depending on IClusterClient. This is outside the scope of the TestKit. Instead the service should make use of its own test double/fake/mock that does not rely on a TestKit-created grain activation.

Please let me know if I'm misunderstanding something, but this looks undesirable for the TestKit.

seniorquico commented 4 months ago

This still appears to be out of scope for the TestKit. Closing for now, but happy to re-evaluate if there's more to discuss.