Merge "Stabilizing tests for TopologyManager."
authorAnil Vishnoi <vishnoianil@gmail.com>
Wed, 7 Jan 2015 21:01:02 +0000 (21:01 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 7 Jan 2015 21:01:03 +0000 (21:01 +0000)
opendaylight/adsal/topologymanager/implementation/src/test/java/org/opendaylight/controller/topologymanager/internal/TopologyManagerImplTest.java

index 600f1d8cbfafb05162be7cba530e6b4c05505d3a..a361285db5c60d42b65d0866a731d7a247d4c250 100644 (file)
@@ -756,7 +756,8 @@ public class TopologyManagerImplTest {
     }
 
     @Test
-    public void bug1348FixTest() throws ConstructionException {
+    public void bug1348FixTest() throws ConstructionException,
+           InterruptedException {
         TestSwitchManager swMgr = new TestSwitchManager();
         topoManagerImpl.setSwitchManager(swMgr);
         topoManagerImpl.nonClusterObjectCreate();
@@ -782,12 +783,15 @@ public class TopologyManagerImplTest {
         }
 
         Assert.assertTrue(topoManagerImpl.flushUpdateQueue(5000));
+        // Give TopologyManger time to update its edges DB.
+        Thread.sleep(1000);
         Assert.assertEquals(1, topoManagerImpl.getEdges().size());
         Assert.assertNotNull(topoManagerImpl.getEdges().get(edge));
     }
 
     @Test
-    public void testNotifyNodeConnector() throws ConstructionException {
+    public void testNotifyNodeConnector() throws ConstructionException,
+           InterruptedException {
         TestSwitchManager swMgr = new TestSwitchManager();
         topoManagerImpl.setSwitchManager(swMgr);
         topoManagerImpl.nonClusterObjectCreate();
@@ -826,6 +830,8 @@ public class TopologyManagerImplTest {
         swMgr.addNodeConnectors(nc2);
         topoManagerImpl.notifyNodeConnector(nc2, UpdateType.CHANGED, propMap);
         Assert.assertTrue(topoManagerImpl.flushUpdateQueue(5000));
+        // Give TopologyManger time to update its edges DB.
+        Thread.sleep(1000);
         Assert.assertEquals(2, topoManagerImpl.getEdges().size());
 
         teu1 = new TopoEdgeUpdate(edge1, props, UpdateType.REMOVED);
@@ -835,6 +841,8 @@ public class TopologyManagerImplTest {
         topoedgeupdateList.add(teu2);
         topoManagerImpl.edgeUpdate(topoedgeupdateList);
         Assert.assertTrue(topoManagerImpl.flushUpdateQueue(5000));
+        // Give TopologyManger time to update its edges DB.
+        Thread.sleep(1000);
         Assert.assertEquals(0, topoManagerImpl.getEdges().size());
         topoManagerImpl.notifyNodeConnector(nc1, UpdateType.REMOVED, propMap);
         topoManagerImpl.notifyNodeConnector(nc2, UpdateType.REMOVED, propMap);
@@ -862,10 +870,14 @@ public class TopologyManagerImplTest {
         swMgr.addNodeConnectors(nc2);
         topoManagerImpl.notifyNodeConnector(nc2, UpdateType.CHANGED, propMap);
         Assert.assertTrue(topoManagerImpl.flushUpdateQueue(5000));
+        // Give TopologyManger time to update its edges DB.
+        Thread.sleep(1000);
         Assert.assertEquals(0, topoManagerImpl.getEdges().size());
         topoManagerImpl.notifyNodeConnector(nc1, UpdateType.REMOVED, propMap);
         topoManagerImpl.notifyNodeConnector(nc2, UpdateType.REMOVED, propMap);
         Assert.assertTrue(topoManagerImpl.flushUpdateQueue(5000));
+        // Give TopologyManger time to update its edges DB.
+        Thread.sleep(1000);
         Assert.assertEquals(0, topoManagerImpl.getEdges().size());
     }
 }