Skip to content

TestKit support for JournaledGrains #104

@marcosikkens

Description

@marcosikkens

I was looking at the different examples but I couldn't find an example of a journaled grain that is being tested. Is this supported? I just want to call a method an verify that the "Raise event" is being called.

My grain is a journaled grain with a [LogConsistencyProvider(ProviderName = "EventStorage")] and when activating this grain it would just crash with the following exception:

   at Orleans.EventSourcing.JournaledGrain`2.OnActivateAsync()
   at Orleans.Grain.<Participate>b__31_0(CancellationToken ct)
   at Orleans.LifecycleExtensions.Observer.OnStart(CancellationToken ct)
   at Orleans.TestKit.TestGrainLifecycle.<>c.<TriggerStartAsync>b__2_1(ValueTuple`2 x)
   at System.Linq.Enumerable.SelectIPartitionIterator`2.PreallocatingToArray(Int32 count)
   at System.Linq.Enumerable.SelectIPartitionIterator`2.ToArray()
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Orleans.TestKit.TestGrainLifecycle.TriggerStartAsync()
   at Orleans.TestKit.TestKitSilo.<CreateGrainAsync>d__31`1.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Translink.Vbn.Aggregates.Tests.CompanyAggregateRootContext.<Execute>d__6.MoveNext() 

So something doesnt work in the OnActivate. This exception occurs when calling the CreateGrainAsync method

        Grain = await Silo.CreateGrainAsync<CompanyAggregateRoot>(CompanyId);

When I directly use the grain factory i do not get any DI which this grain needs (and the version property is not set). Are there better ways to test journaled grains? Or do I just not test them (which feels kinda strange).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions