Changing manually advanced timing for high load.
Change-Id: I89e0919cb9a4353d0b79e71862055d67dbeabf42
diff --git a/utils/misc/src/test/java/org/onlab/util/AbstractAccumulatorTest.java b/utils/misc/src/test/java/org/onlab/util/AbstractAccumulatorTest.java
index db7224a..179dae6 100644
--- a/utils/misc/src/test/java/org/onlab/util/AbstractAccumulatorTest.java
+++ b/utils/misc/src/test/java/org/onlab/util/AbstractAccumulatorTest.java
@@ -33,6 +33,9 @@
private final ManuallyAdvancingTimer timer = new ManuallyAdvancingTimer();
+ private static final int LONG_REAL_TIME_DELAY = 30;
+ private static final int SHORT_REAL_TIME_DELAY = 5;
+
@Test
public void basics() throws Exception {
@@ -52,7 +55,7 @@
accumulator.add(new TestItem("d"));
assertTrue("should not have fired yet", accumulator.batch.isEmpty());
accumulator.add(new TestItem("e"));
- timer.advanceTimeMillis(20, 10);
+ timer.advanceTimeMillis(20, LONG_REAL_TIME_DELAY);
assertFalse("should have fired", accumulator.batch.isEmpty());
assertEquals("incorrect batch", "abcde", accumulator.batch);
}
@@ -61,16 +64,16 @@
public void timeTrigger() {
TestAccumulator accumulator = new TestAccumulator();
accumulator.add(new TestItem("a"));
- timer.advanceTimeMillis(30, 1);
+ timer.advanceTimeMillis(30, SHORT_REAL_TIME_DELAY);
assertTrue("should not have fired yet", accumulator.batch.isEmpty());
accumulator.add(new TestItem("b"));
- timer.advanceTimeMillis(30, 1);
+ timer.advanceTimeMillis(30, SHORT_REAL_TIME_DELAY);
assertTrue("should not have fired yet", accumulator.batch.isEmpty());
accumulator.add(new TestItem("c"));
- timer.advanceTimeMillis(30, 1);
+ timer.advanceTimeMillis(30, SHORT_REAL_TIME_DELAY);
assertTrue("should not have fired yet", accumulator.batch.isEmpty());
accumulator.add(new TestItem("d"));
- timer.advanceTimeMillis(10, 10);
+ timer.advanceTimeMillis(10, LONG_REAL_TIME_DELAY);
assertFalse("should have fired", accumulator.batch.isEmpty());
assertEquals("incorrect batch", "abcd", accumulator.batch);
}
@@ -81,7 +84,7 @@
accumulator.add(new TestItem("a"));
assertTrue("should not have fired yet", accumulator.batch.isEmpty());
accumulator.add(new TestItem("b"));
- timer.advanceTimeMillis(70, 10);
+ timer.advanceTimeMillis(70, LONG_REAL_TIME_DELAY);
assertFalse("should have fired", accumulator.batch.isEmpty());
assertEquals("incorrect batch", "ab", accumulator.batch);
}
@@ -93,10 +96,10 @@
accumulator.add(new TestItem("a"));
assertTrue("should not have fired yet", accumulator.batch.isEmpty());
accumulator.add(new TestItem("b"));
- timer.advanceTimeMillis(80, 1);
+ timer.advanceTimeMillis(80, SHORT_REAL_TIME_DELAY);
assertTrue("should not have fired yet", accumulator.batch.isEmpty());
accumulator.ready = true;
- timer.advanceTimeMillis(80, 10);
+ timer.advanceTimeMillis(80, LONG_REAL_TIME_DELAY);
assertFalse("should have fired", accumulator.batch.isEmpty());
assertEquals("incorrect batch", "ab", accumulator.batch);
}
@@ -105,12 +108,12 @@
public void readyLongTrigger() {
TestAccumulator accumulator = new TestAccumulator();
accumulator.ready = false;
- timer.advanceTimeMillis(120, 1);
+ timer.advanceTimeMillis(120, SHORT_REAL_TIME_DELAY);
assertTrue("should not have fired yet", accumulator.batch.isEmpty());
accumulator.add(new TestItem("a"));
assertTrue("should not have fired yet", accumulator.batch.isEmpty());
accumulator.ready = true;
- timer.advanceTimeMillis(120, 10);
+ timer.advanceTimeMillis(120, LONG_REAL_TIME_DELAY);
assertFalse("should have fired", accumulator.batch.isEmpty());
assertEquals("incorrect batch", "a", accumulator.batch);
}
@@ -128,7 +131,7 @@
assertTrue("should not have fired yet", accumulator.batch.isEmpty());
accumulator.ready = true;
accumulator.add(new TestItem("g"));
- timer.advanceTimeMillis(10, 10);
+ timer.advanceTimeMillis(10, LONG_REAL_TIME_DELAY);
assertFalse("should have fired", accumulator.batch.isEmpty());
assertEquals("incorrect batch", "abcdefg", accumulator.batch);
}
diff --git a/utils/misc/src/test/java/org/onlab/util/ManuallyAdvancingTimerTest.java b/utils/misc/src/test/java/org/onlab/util/ManuallyAdvancingTimerTest.java
index b8e1e85..bab199f 100644
--- a/utils/misc/src/test/java/org/onlab/util/ManuallyAdvancingTimerTest.java
+++ b/utils/misc/src/test/java/org/onlab/util/ManuallyAdvancingTimerTest.java
@@ -47,7 +47,7 @@
private AtomicInteger tasksRunCount;
// FIXME if this class fails first try increasing the real time delay to account for heavy system load.
- private static final int REAL_TIME_DELAY = 1;
+ private static final int REAL_TIME_DELAY = 10;
/**
* Sets up the testing environment.