import org.junit.Test;
import org.mockito.Mockito;
import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
-import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException;
-import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipChange;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
-import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipState;
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;
+import org.opendaylight.infrautils.ready.SystemReadyListener;
+import org.opendaylight.infrautils.ready.SystemReadyMonitor;
+import org.opendaylight.infrautils.ready.SystemState;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.mdsal.eos.binding.api.Entity;
+import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipCandidateRegistration;
+import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipChange;
+import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListener;
+import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListenerRegistration;
+import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
+import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState;
+import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState;
import org.opendaylight.ovsdb.lib.OvsdbConnection;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
public void testInit() throws CandidateAlreadyRegisteredException {
// Indicate that this is the owner
when(entityOwnershipService.getOwnershipState(any(Entity.class))).thenReturn(
- Optional.of(new EntityOwnershipState(true, true)));
+ Optional.of(EntityOwnershipState.from(true, true)));
try (SouthboundProvider southboundProvider = new SouthboundProvider(
getDataBroker(),
entityOwnershipService,
Mockito.mock(OvsdbConnection.class),
Mockito.mock(DOMSchemaService.class),
- Mockito.mock(BindingNormalizedNodeSerializer.class))) {
+ Mockito.mock(BindingNormalizedNodeSerializer.class),
+ new ImmediateSystemReadyMonitor(),
+ Mockito.mock(DiagStatusService.class))) {
// Initiate the session
southboundProvider.init();
public void testInitWithClose() throws CandidateAlreadyRegisteredException {
// Indicate that this is the owner
when(entityOwnershipService.getOwnershipState(any(Entity.class))).thenReturn(
- Optional.of(new EntityOwnershipState(true, true)));
+ Optional.of(EntityOwnershipState.from(true, true)));
try (SouthboundProvider southboundProvider = new SouthboundProvider(
getDataBroker(),
entityOwnershipService,
Mockito.mock(OvsdbConnection.class),
Mockito.mock(DOMSchemaService.class),
- Mockito.mock(BindingNormalizedNodeSerializer.class))) {
+ Mockito.mock(BindingNormalizedNodeSerializer.class),
+ new ImmediateSystemReadyMonitor(),
+ Mockito.mock(DiagStatusService.class))) {
// Initiate the session
southboundProvider.init();
@Test
public void testGetDb() {
when(entityOwnershipService.getOwnershipState(any(Entity.class))).thenReturn(
- Optional.of(new EntityOwnershipState(true, true)));
+ Optional.of(EntityOwnershipState.from(true, true)));
try (SouthboundProvider southboundProvider = new SouthboundProvider(
getDataBroker(),
entityOwnershipService,
Mockito.mock(OvsdbConnection.class),
Mockito.mock(DOMSchemaService.class),
- Mockito.mock(BindingNormalizedNodeSerializer.class))) {
+ Mockito.mock(BindingNormalizedNodeSerializer.class),
+ new ImmediateSystemReadyMonitor(),
+ Mockito.mock(DiagStatusService.class))) {
southboundProvider.init();
@Test
public void testHandleOwnershipChange() throws ReadFailedException {
when(entityOwnershipService.getOwnershipState(any(Entity.class))).thenReturn(
- Optional.of(new EntityOwnershipState(false, true)));
+ Optional.of(EntityOwnershipState.from(false, true)));
Entity entity = new Entity("ovsdb-southbound-provider", "ovsdb-southbound-provider");
KeyedInstanceIdentifier<Topology, TopologyKey> topologyIid = InstanceIdentifier
.create(NetworkTopology.class)
entityOwnershipService,
Mockito.mock(OvsdbConnection.class),
Mockito.mock(DOMSchemaService.class),
- Mockito.mock(BindingNormalizedNodeSerializer.class))) {
+ Mockito.mock(BindingNormalizedNodeSerializer.class),
+ new ImmediateSystemReadyMonitor(),
+ Mockito.mock(DiagStatusService.class))) {
southboundProvider.init();
topologyIid).checkedGet().isPresent());
// Become owner
- southboundProvider.handleOwnershipChange(new EntityOwnershipChange(entity, false, true, true));
+ southboundProvider.handleOwnershipChange(new EntityOwnershipChange(entity,
+ EntityOwnershipChangeState.from(false, true, true)));
// Now the OVSDB topology must be present in both trees
assertTrue(getDataBroker().newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION,
topologyIid).checkedGet().isPresent());
// Verify idempotency
- southboundProvider.handleOwnershipChange(new EntityOwnershipChange(entity, false, true, true));
+ southboundProvider.handleOwnershipChange(new EntityOwnershipChange(entity,
+ EntityOwnershipChangeState.from(false, true, true)));
// The OVSDB topology must be present in both trees
assertTrue(getDataBroker().newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION,
topologyIid).checkedGet().isPresent());
}
}
+
+ private static class ImmediateSystemReadyMonitor implements SystemReadyMonitor {
+
+ @Override
+ public SystemState getSystemState() {
+ return SystemState.ACTIVE;
+ }
+
+ @Override
+ public void registerListener(SystemReadyListener listener) {
+ listener.onSystemBootReady();
+ }
+
+ }
}