-
Notifications
You must be signed in to change notification settings - Fork 226
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
Support for mocking Process.clock_gettime via Timecop #220
Comments
(It'd be helpful if this worked on CLOCK_REALTIME as well as CLOCK_MONOTONIC - we're moving some particularly performance-sensitive code to use |
Mocks exist for both CLOCK::MONOTONIC and CLOCK::REALTIME Handles travisjeffery#220
i've got to spend some time with @wishdev's PR, play around with it and do some tests but think this will be a nice new feature to have in our next release. |
This test mocks the internals of Statsd (time sending a message to timing) Statsd no longer uses Time.now to determine the time, instead using Process.clock_gettime in order to compute monotonic time. More details: reinh/statsd#70. We therefore must update our test to mock the new call and also stub the constant Process::CLOCK_MONOTONIC. This is the same dependency on some Statsd internal behaviour, it just _looks_ more brittle. Timecop may support this in future: travisjeffery/timecop#220 (comment)
This test mocks the internals of Statsd (time sending a message to timing) Statsd no longer uses Time.now to determine the time, instead using Process.clock_gettime in order to compute monotonic time. More details: reinh/statsd#70. We therefore must update our test to mock the new call and also stub the constant Process::CLOCK_MONOTONIC. This is the same dependency on some Statsd internal behaviour, it just _looks_ more brittle. Timecop may support this in future: travisjeffery/timecop#220 (comment)
This test mocks the internals of Statsd (time sending a message to timing) Statsd no longer uses Time.now to determine the time, instead using Process.clock_gettime in order to compute monotonic time. More details: reinh/statsd#70. We therefore must update our test to mock the new call and also stub the constant Process::CLOCK_MONOTONIC. This is the same dependency on some Statsd internal behaviour, it just _looks_ more brittle. Timecop may support this in future: travisjeffery/timecop#220 (comment)
This test mocks the internals of Statsd (time sending a message to timing) Statsd no longer uses Time.now to determine the time, instead using Process.clock_gettime in order to compute monotonic time. More details: reinh/statsd#70. I initially updated our test to mock the new call and also stub the constant Process::CLOCK_MONOTONIC. But, this is the same dependency on some Statsd internal behaviour, it just _looked_ more brittle. Timecop may support this in future: travisjeffery/timecop#220 (comment) Instead, sleeping for 1 second doesn't also test rely on testing the internals of the Statsd gem.
This test mocks the internals of Statsd (time sending a message to timing) Statsd no longer uses Time.now to determine the time, instead using Process.clock_gettime in order to compute monotonic time. More details: reinh/statsd#70. We therefore must update our test to mock the new call and also stub the constant Process::CLOCK_MONOTONIC. This is the same dependency on some Statsd internal behaviour, it just _looks_ more brittle. Timecop may support this in future: travisjeffery/timecop#220 (comment)
This functionality would be great to add, and it looks like there's a PR to deliver it as well - let me know if there's anything we can do to help here 👍 |
thanks @adfoster-r7 this slipped off my radar. The PR never had passing tests. I haven't played with it either to see how it works. |
This was closed as completed but still it's not implemented as of timecop 0.9.8 . I checked with def test_process_clock_gettime_fail
time1 = Time.now
Timecop.freeze(time1) do
time2 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
sleep 1
time3 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
assert_equal time2, time3
end
end The time obtained via @joshuacronemeyer , is this issue closed because it's decided that timecop will never support Can I suggest to mention README.md in the homepage directly that
|
@ecerulm thanks for checking in on this. I just closed this because it was old and nobody was working on it. Not because we're not open to this functionality. I don't know much about it. I see we had this PR that was here before I started working on the project: #258 I think we just need somebody to champion a properly tested, working PR. |
It would be great to be able to freeze and travel time returned by this method.
https://ruby-doc.org/core-2.4.2/Process.html#method-c-clock_gettime
More on monotonic clocks: https://www.softwariness.com/articles/monotonic-clocks-windows-and-posix/
The text was updated successfully, but these errors were encountered: