Github user HeartSaVioR commented on a diff in the pull request:
https://github.com/apache/storm/pull/776#discussion_r40963272
--- Diff: storm-core/test/jvm/backtype/storm/utils/RateTrackerTest.java ---
@@ -27,36 +27,63 @@
public class RateTrackerTest extends TestCase {
@Test
+ public void testExactRate() {
+ final long interval = 1000l;
+ long time = 0l;
+ RateTracker rt = new RateTracker(10000, 10, time);
+ double [] expected = new double[] {10.0, 10.0, 10.0, 10.0, 10.0,
10.0, 10.0, 10.0, 10.0, 10.0};
+ for (int i = 0; i < expected.length; i++) {
+ double exp = expected[i];
+ rt.notify(10);
+ time += interval;
+ double actual = rt.reportRate(time);
+ rt.forceRotate(1, interval);
+ assertEquals("Expected rate on iteration "+i+" is wrong.",
exp, actual, 0.00001);
+ }
+ expected = new double[] {11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0,
18.0, 19.0, 20.0};
--- End diff --
It would be better to comment that it is continuous test after previous
loop, so for each loop earliest bucket (which stores 10) is eclipsed and
replaced to 20.
I was misunderstood L43-51 to a new test, so I spent some times to find out
why it is not 20.0.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---