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

Timeout.InfiniteTimeSpan should execute only once with RegisterTimer #82

Open
Gabrielm1 opened this issue Nov 25, 2019 · 1 comment
Open

Comments

@Gabrielm1
Copy link

Hi,

I noticed that the Timeout.InfiniteTimeSpan when it's used with the RegisterTimer doesn't work as expected. It's should only executed once, but it appears not to be.

Here is a dummy RegisterTimer

public Task DummyTimer() { RegisterTimer( o => SimpleMethod(), "dummy", TimeSpan.FromSeconds(5), Timeout.InfiniteTimeSpan) };

Here is the dummy test :

await DummyTimer() await Silo.FireAllTimersAsync(); service.Verify(s => s.SimpleMethod(), Times.Once ); await Silo.FireAllTimersAsync(); service.Verify(s => s.SimpleMethod(), Times.Once );

Here is the problem, the method SimpleMethod() is called two time, but should be only called once.

Here is the sample of the implementation of the class GrainTimer.cs. As we can see the INFINITE_TIMESPAN should dispose the timer.

}finally { previousTickTime = DateTime.UtcNow; currentlyExecutingTickTask = null; // if this is not a repeating timer, then we can // dispose of the timer. if (timerFrequency == Constants.INFINITE_TIMESPAN) DisposeTimer(); }

@seniorquico
Copy link
Collaborator

seniorquico commented Nov 25, 2019

Thanks for the detailed description, @Gabrielm1. Currently, the TestKit does not "schedule" or manage lifetimes of reminders or timers. Additionally, it keeps no record of reminders that have ticked or timers that have fired. The API simply enables calling the grain methods from a test. For now, this issue is by design/a known limitation.

There is a discussion about an improved API on PR #60. I have a work-in-progress branch where I've been exploring a new test fixture component to manage time and fire/tick "due" reminders/timers with minimal changes to the TestKit... just a layering on top of the existing API. Progress has been slow due to work constraints, but I have an upcoming Orleans project that may re-kickstart this work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants