Unit test fix - timeout is not correctly set in parallel execution environment
Change-Id: Id3089c45ad217113f9c01c93e2047114b7fbccb4
diff --git a/core/net/src/main/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManager.java b/core/net/src/main/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManager.java
index a050e07..48a4d35 100644
--- a/core/net/src/main/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManager.java
+++ b/core/net/src/main/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManager.java
@@ -64,7 +64,8 @@
private final Logger log = LoggerFactory.getLogger(getClass());
// TODO Make queue timeout configurable
- static int objTimeoutMs = 15000;
+ static final int DEFAULT_OBJ_TIMEOUT = 15000;
+ int objTimeoutMs = DEFAULT_OBJ_TIMEOUT;
private Cache<FilteringObjQueueKey, Objective> filtObjQueueHead;
private Cache<ForwardingObjQueueKey, Objective> fwdObjQueueHead;
diff --git a/core/net/src/test/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManagerTest.java b/core/net/src/test/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManagerTest.java
index 94096b5..77af15a 100644
--- a/core/net/src/test/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManagerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/flowobjective/impl/InOrderFlowObjectiveManagerTest.java
@@ -184,7 +184,12 @@
@Before
public void setUp() {
+ internalSetup(InOrderFlowObjectiveManager.DEFAULT_OBJ_TIMEOUT);
+ }
+
+ private void internalSetup(int objTimeoutMs) {
mgr = new InOrderFlowObjectiveManager();
+ mgr.objTimeoutMs = objTimeoutMs;
mgr.pipeliners.put(DEV1, pipeliner);
mgr.executorService = newFixedThreadPool(4, groupedThreads("foo", "bar"));
mgr.cfgService = createMock(ComponentConfigService.class);
@@ -249,15 +254,14 @@
Lists.newArrayList(fwdTimeout, FWD1, FWD2));
// Reduce timeout so the unit test doesn't have to wait many seconds
- InOrderFlowObjectiveManager.objTimeoutMs = TIMEOUT_THRESH;
- setUp();
+ internalSetup(TIMEOUT_THRESH);
expect(mgr.flowObjectiveStore.getNextGroup(NID1)).andReturn(NGRP1).times(1);
expect(mgr.flowObjectiveStore.getNextGroup(NID2)).andReturn(NGRP2).times(2);
replay(mgr.flowObjectiveStore);
// Force this objective to time out
- offset = InOrderFlowObjectiveManager.objTimeoutMs * 2;
+ offset = mgr.objTimeoutMs * 2;
expectFwdObjsTimeout.forEach(fwdObj -> mgr.forward(DEV1, fwdObj));