-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Clock api for incremental second unit counter #1425
Clock api for incremental second unit counter #1425
Conversation
@repeatedly could you review this change? |
c0 = Fluent::Clock.now | ||
t0 = Time.now | ||
t1 = t0 - 30 | ||
assert_kind_of Time, t1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This checks ruby spec, not fluentd code.
So it seems not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, but it assures this test code uses Time argument.
Assertions are sometimes used for such usage.
end | ||
|
||
def self.freeze(dst = nil, &block) | ||
return freeze_block(dst, &block) if block_given? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if block
is enough but trivial
LGTM and add comments. |
Let me merge this right now... Windows CI is failing with known timing bug of test code (and it's already fixed in #1426) |
Currently there are many code to use
Time.now
to control flush timing and event invoke timing.It's basically wrong, because time may move to future or past by time adjustment, or affected by leap seconds (and Timecop).
We can use
Process.clock_gettime
to avoid this problem, but it's a bit troublesome to specify clock type available. It's too much and too raw for almost core code and plugins. UsingProcess.clock_gettime
is also not controlled by test code.So, this change will introduce a new internal API to provide clock value, which can be controlled to be frozen for tests.