Get rid of useless (Hwvtep)SouthboundProvider thread
[ovsdb.git] / southbound / southbound-impl / src / test / java / org / opendaylight / ovsdb / southbound / SouthboundProviderTest.java
index 09ae00851b142a7e8e4434d3d2ba139a7b680632..d0bdcfbf0e4f6518bf9396ca0e29af64d2b5097b 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.ovsdb.southbound;
 
 import static org.junit.Assert.assertEquals;
@@ -19,10 +18,13 @@ import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 import static org.opendaylight.infrautils.ready.testutils.TestSystemReadyMonitor.Behaviour.IMMEDIATE;
 
+import com.google.common.base.Stopwatch;
+import com.google.common.util.concurrent.Uninterruptibles;
+import java.util.concurrent.TimeUnit;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
+import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.infrautils.diagstatus.DiagStatusService;
@@ -45,10 +47,14 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 
-public class SouthboundProviderTest extends AbstractDataBrokerTest {
+public class SouthboundProviderTest extends AbstractConcurrentDataBrokerTest {
 
     private EntityOwnershipService entityOwnershipService;
 
+    public SouthboundProviderTest() {
+        super(true);
+    }
+
     @Before
     public void setUp() throws CandidateAlreadyRegisteredException {
         entityOwnershipService = mock(EntityOwnershipService.class);
@@ -165,6 +171,13 @@ public class SouthboundProviderTest extends AbstractDataBrokerTest {
             southboundProvider.handleOwnershipChange(new EntityOwnershipChange(entity,
                     EntityOwnershipChangeState.from(false, true, true)));
 
+            // Up to 3 seconds for DTCL to settle
+            final Stopwatch sw = Stopwatch.createStarted();
+            while (!southboundProvider.isRegistered() && sw.elapsed(TimeUnit.SECONDS) < 3) {
+                Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
+            }
+            assertTrue(southboundProvider.isRegistered());
+
             // Now the OVSDB topology must be present in both trees
             assertTrue(getDataBroker().newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION,
                     topologyIid).checkedGet().isPresent());