dotnet/orleans

Unit Testing & OrleansTestKit Path Forward

Open

#4,534 创建于 2018年4月30日

在 GitHub 查看
 (2 评论) (0 反应) (0 负责人)C# (10,777 star) (2,123 fork)batch import
design-reviewhelp wanted

描述

We have been discussing our testing strategy internally and would like to see if anyone else has opinions on how we can make testing better in Orleans. We are thinking about using a similar API to the one I created in OrleansTestKit, but run it within the actual Orleans runtime. The OrleansTestKit is able to run tests for many simple use cases, however it will not support more complex grain that are deeply integrated with Orleans for example, Lifecycle events. There are many other things that Orleans does that would not be able to be tested inside the TestKit. Rather than spending more time emulating Orleans behaviors, we are thinking about a new approach that would allow the same assertions that exist within the current TestKit, but would allow grain code to execute exactly as it does when running in a real silo.

In reality, most of this proposal is just to allow developers to assert grain state, grain calls to other grains, and provide a way for a developer configure a mock grain that will return the desired value or exception when a grain is called.

What would need to be built:

Storage provider

  • Assert the current grain state
  • Setup the grain state prior to activation

Stream provider

  • Assert that a grain is subscribed to a specific stream
  • Assert that a grain sends the proper message on a stream
  • Assert that a grain received a message from a stream without error
  • Assert that a grain unsubscribed from a specific stream

Reminder Provider

  • Assert that a reminder was registered for the correct time
  • Fire a reminder on demand from within a test

Mock Grain Call Filter

  • Assert that another grain was called with the correct values
  • Intercept grain-to-grain method calls and return a specific value or throw an exception

Other

  • Deactivate a grain on demand
  • Activate a grain on demand

Please let me know if you have other things that you would like exposed and we can talk about a roadmap to build out these features. We are going to start prototyping some of these behaviors this week to see how they work in practice.

贡献者指南