OrleansTestKit icon indicating copy to clipboard operation
OrleansTestKit copied to clipboard

Question for this.AsReference<IMyGrain> in timers

Open amccool opened this issue 2 years ago • 0 comments

getting the following when testing a timer

System.ArgumentException : Passing a half baked grain as an argument. It is possible that you instantiated a grain class explicitly, as a regular object and not via Orleans runtime or via proper test mocking (Parameter 'grain')

  Stack Trace: 
GrainExtensions.AsWeaklyTypedReference(IAddressable grain)
GrainExtensions.AsReference[TGrainInterface](IAddressable grain)
MyGrain.SnapshotTimerFired() line 1029
TestTimerRegistry.FireAllAsync() line 37

using await Silo.FireAllTimersAsync(); on var myGrain = await Silo.CreateGrainAsync<MyGrain>(myguid, myspecialstring);

timer is registered in OnActivateAsync

timer callback looks like this:

        private async Task SnapshotTimerFired()
        {
            var me = this.AsReference<IMyGrain>();

            await me.CheckForExpiredCallsAndSendSnapshotHACK();
        }

the AsReference is used so the timer execution counts as a grain call.

does the testkit handle this, or it this some other grain having an issue?

amccool avatar Jun 13 '22 19:06 amccool