Aaron Kruglikov

Changing manually advanced timing for high load.

Change-Id: I89e0919cb9a4353d0b79e71862055d67dbeabf42
...@@ -33,6 +33,9 @@ public class AbstractAccumulatorTest { ...@@ -33,6 +33,9 @@ public class AbstractAccumulatorTest {
33 33
34 private final ManuallyAdvancingTimer timer = new ManuallyAdvancingTimer(); 34 private final ManuallyAdvancingTimer timer = new ManuallyAdvancingTimer();
35 35
36 + private static final int LONG_REAL_TIME_DELAY = 30;
37 + private static final int SHORT_REAL_TIME_DELAY = 5;
38 +
36 39
37 @Test 40 @Test
38 public void basics() throws Exception { 41 public void basics() throws Exception {
...@@ -52,7 +55,7 @@ public class AbstractAccumulatorTest { ...@@ -52,7 +55,7 @@ public class AbstractAccumulatorTest {
52 accumulator.add(new TestItem("d")); 55 accumulator.add(new TestItem("d"));
53 assertTrue("should not have fired yet", accumulator.batch.isEmpty()); 56 assertTrue("should not have fired yet", accumulator.batch.isEmpty());
54 accumulator.add(new TestItem("e")); 57 accumulator.add(new TestItem("e"));
55 - timer.advanceTimeMillis(20, 10); 58 + timer.advanceTimeMillis(20, LONG_REAL_TIME_DELAY);
56 assertFalse("should have fired", accumulator.batch.isEmpty()); 59 assertFalse("should have fired", accumulator.batch.isEmpty());
57 assertEquals("incorrect batch", "abcde", accumulator.batch); 60 assertEquals("incorrect batch", "abcde", accumulator.batch);
58 } 61 }
...@@ -61,16 +64,16 @@ public class AbstractAccumulatorTest { ...@@ -61,16 +64,16 @@ public class AbstractAccumulatorTest {
61 public void timeTrigger() { 64 public void timeTrigger() {
62 TestAccumulator accumulator = new TestAccumulator(); 65 TestAccumulator accumulator = new TestAccumulator();
63 accumulator.add(new TestItem("a")); 66 accumulator.add(new TestItem("a"));
64 - timer.advanceTimeMillis(30, 1); 67 + timer.advanceTimeMillis(30, SHORT_REAL_TIME_DELAY);
65 assertTrue("should not have fired yet", accumulator.batch.isEmpty()); 68 assertTrue("should not have fired yet", accumulator.batch.isEmpty());
66 accumulator.add(new TestItem("b")); 69 accumulator.add(new TestItem("b"));
67 - timer.advanceTimeMillis(30, 1); 70 + timer.advanceTimeMillis(30, SHORT_REAL_TIME_DELAY);
68 assertTrue("should not have fired yet", accumulator.batch.isEmpty()); 71 assertTrue("should not have fired yet", accumulator.batch.isEmpty());
69 accumulator.add(new TestItem("c")); 72 accumulator.add(new TestItem("c"));
70 - timer.advanceTimeMillis(30, 1); 73 + timer.advanceTimeMillis(30, SHORT_REAL_TIME_DELAY);
71 assertTrue("should not have fired yet", accumulator.batch.isEmpty()); 74 assertTrue("should not have fired yet", accumulator.batch.isEmpty());
72 accumulator.add(new TestItem("d")); 75 accumulator.add(new TestItem("d"));
73 - timer.advanceTimeMillis(10, 10); 76 + timer.advanceTimeMillis(10, LONG_REAL_TIME_DELAY);
74 assertFalse("should have fired", accumulator.batch.isEmpty()); 77 assertFalse("should have fired", accumulator.batch.isEmpty());
75 assertEquals("incorrect batch", "abcd", accumulator.batch); 78 assertEquals("incorrect batch", "abcd", accumulator.batch);
76 } 79 }
...@@ -81,7 +84,7 @@ public class AbstractAccumulatorTest { ...@@ -81,7 +84,7 @@ public class AbstractAccumulatorTest {
81 accumulator.add(new TestItem("a")); 84 accumulator.add(new TestItem("a"));
82 assertTrue("should not have fired yet", accumulator.batch.isEmpty()); 85 assertTrue("should not have fired yet", accumulator.batch.isEmpty());
83 accumulator.add(new TestItem("b")); 86 accumulator.add(new TestItem("b"));
84 - timer.advanceTimeMillis(70, 10); 87 + timer.advanceTimeMillis(70, LONG_REAL_TIME_DELAY);
85 assertFalse("should have fired", accumulator.batch.isEmpty()); 88 assertFalse("should have fired", accumulator.batch.isEmpty());
86 assertEquals("incorrect batch", "ab", accumulator.batch); 89 assertEquals("incorrect batch", "ab", accumulator.batch);
87 } 90 }
...@@ -93,10 +96,10 @@ public class AbstractAccumulatorTest { ...@@ -93,10 +96,10 @@ public class AbstractAccumulatorTest {
93 accumulator.add(new TestItem("a")); 96 accumulator.add(new TestItem("a"));
94 assertTrue("should not have fired yet", accumulator.batch.isEmpty()); 97 assertTrue("should not have fired yet", accumulator.batch.isEmpty());
95 accumulator.add(new TestItem("b")); 98 accumulator.add(new TestItem("b"));
96 - timer.advanceTimeMillis(80, 1); 99 + timer.advanceTimeMillis(80, SHORT_REAL_TIME_DELAY);
97 assertTrue("should not have fired yet", accumulator.batch.isEmpty()); 100 assertTrue("should not have fired yet", accumulator.batch.isEmpty());
98 accumulator.ready = true; 101 accumulator.ready = true;
99 - timer.advanceTimeMillis(80, 10); 102 + timer.advanceTimeMillis(80, LONG_REAL_TIME_DELAY);
100 assertFalse("should have fired", accumulator.batch.isEmpty()); 103 assertFalse("should have fired", accumulator.batch.isEmpty());
101 assertEquals("incorrect batch", "ab", accumulator.batch); 104 assertEquals("incorrect batch", "ab", accumulator.batch);
102 } 105 }
...@@ -105,12 +108,12 @@ public class AbstractAccumulatorTest { ...@@ -105,12 +108,12 @@ public class AbstractAccumulatorTest {
105 public void readyLongTrigger() { 108 public void readyLongTrigger() {
106 TestAccumulator accumulator = new TestAccumulator(); 109 TestAccumulator accumulator = new TestAccumulator();
107 accumulator.ready = false; 110 accumulator.ready = false;
108 - timer.advanceTimeMillis(120, 1); 111 + timer.advanceTimeMillis(120, SHORT_REAL_TIME_DELAY);
109 assertTrue("should not have fired yet", accumulator.batch.isEmpty()); 112 assertTrue("should not have fired yet", accumulator.batch.isEmpty());
110 accumulator.add(new TestItem("a")); 113 accumulator.add(new TestItem("a"));
111 assertTrue("should not have fired yet", accumulator.batch.isEmpty()); 114 assertTrue("should not have fired yet", accumulator.batch.isEmpty());
112 accumulator.ready = true; 115 accumulator.ready = true;
113 - timer.advanceTimeMillis(120, 10); 116 + timer.advanceTimeMillis(120, LONG_REAL_TIME_DELAY);
114 assertFalse("should have fired", accumulator.batch.isEmpty()); 117 assertFalse("should have fired", accumulator.batch.isEmpty());
115 assertEquals("incorrect batch", "a", accumulator.batch); 118 assertEquals("incorrect batch", "a", accumulator.batch);
116 } 119 }
...@@ -128,7 +131,7 @@ public class AbstractAccumulatorTest { ...@@ -128,7 +131,7 @@ public class AbstractAccumulatorTest {
128 assertTrue("should not have fired yet", accumulator.batch.isEmpty()); 131 assertTrue("should not have fired yet", accumulator.batch.isEmpty());
129 accumulator.ready = true; 132 accumulator.ready = true;
130 accumulator.add(new TestItem("g")); 133 accumulator.add(new TestItem("g"));
131 - timer.advanceTimeMillis(10, 10); 134 + timer.advanceTimeMillis(10, LONG_REAL_TIME_DELAY);
132 assertFalse("should have fired", accumulator.batch.isEmpty()); 135 assertFalse("should have fired", accumulator.batch.isEmpty());
133 assertEquals("incorrect batch", "abcdefg", accumulator.batch); 136 assertEquals("incorrect batch", "abcdefg", accumulator.batch);
134 } 137 }
......
...@@ -47,7 +47,7 @@ public class ManuallyAdvancingTimerTest { ...@@ -47,7 +47,7 @@ public class ManuallyAdvancingTimerTest {
47 private AtomicInteger tasksRunCount; 47 private AtomicInteger tasksRunCount;
48 48
49 // FIXME if this class fails first try increasing the real time delay to account for heavy system load. 49 // FIXME if this class fails first try increasing the real time delay to account for heavy system load.
50 - private static final int REAL_TIME_DELAY = 1; 50 + private static final int REAL_TIME_DELAY = 10;
51 51
52 /** 52 /**
53 * Sets up the testing environment. 53 * Sets up the testing environment.
......