-
Notifications
You must be signed in to change notification settings - Fork 25
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
Updates JMX statistics test to assert statistics update with a timeout #124
Updates JMX statistics test to assert statistics update with a timeout #124
Conversation
Hi Vassilis, cool, thanks you take a shot on this. Actually, I would have done it myself or dropped it, since I reqeusted it. There is an error in IMHO you can simplify to:
Major things:
Minor things:
|
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.
Major things:
assertEventually
needs to be corrected- I think the tests with
assertAllTheTime
are not needed.
Minor things:
- maybe drop the
throws Exception
since AssertError is an unchecked exception - maybe use an ojbect initialized with the timeout once
new Xy(long, TimeUnit)
. So the call with the runnable is a single arg and displayed nicely as lambda in modern IDEs.
4b10003
to
d0fc867
Compare
Thanks for the review Jens!
To be honest I failed to see the error in the implementation, but maybe that's just due to lack of coffee on Monday morning :) . Nevertheless, I updated my PR with the simplified version you posted, looks much better.
I think it is needed to ensure the TCK catches errors in implementations that may delay publishing of statistics. For example, consider this:
In a hypothetical implementation that updates published statistics every 10 seconds and erroneously increments
You are right, invokers of these methods should not be forced to handle checked exceptions. I have updated my PR so that any checked exceptions thrown from assertion code will now be wrapped in a
I have a slight preference towards keeping |
Gosh, I didn't think about that one. You are totally right, if an implementation delays then it wouldn't fail that test. I thought we could have a reasonable high grace time, e.g. one minute, which should do the trick for all implementations. When a change is immediate the total runtime of the unit tests would not increase. However, if we add tests, that assert a value is not changing within a certain timeframe, then the runtime increases for everyone, or most implementations need to specify that the grace time is 0 seconds. The best solution would be to make it testable e.g. by defining a flush instruction. But that would mean the Spec needs to be changed. The perfect solution needs to be postponed to 2.0... Since the current tests don't cater for this problem, I have a slight tendency for ignoring it. Adding the delay and/or a parameter just seems to me quite a hassle. Another option would be to start a test suite of timing related tests, which has longer running times and eventually also addresses expiry. |
d0fc867
to
f83906b
Compare
I think that's a good strategy to deal with time-consuming tests. Other options may also include executing tests in parallel to lower test time, however these should be explored for 2.0. That said, setting the default timeout to 0 seconds will not make a difference to current test time. Only implementations that actually defer statistics updates will need to set the timeout property to a suitable value and will have a longer test time, so I would be in favour of keeping this PR (assuming all other concerns are addressed). |
That's okay! Two little things:
5 seconds isn't true any more. Pls. make it a JavaDoc comment with |
f83906b
to
e9409a8
Compare
Thanks @cruftex , javadoc was updated as suggested. |
Cool. Thanks again for taking care of this! |
Updates
CacheMBStatisticsMBeanTest
to assert:The default timeout is 5 seconds and can be overridden via system property
org.jsr107.tck.management.statistics.timeout.seconds
.Fixes #79