use of org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints in project controller by opendaylight.
the class RpcRegistrarTest method testHandleReceiveUpdateEndpoint.
@Test
public void testHandleReceiveUpdateEndpoint() throws Exception {
final InOrder inOrder = Mockito.inOrder(service, oldReg, newReg);
testActorRef.tell(new UpdateRemoteEndpoints(ImmutableMap.of(endpointAddress, Optional.of(firstEndpoint))), ActorRef.noSender());
// first registration
inOrder.verify(service).registerRpcImplementation(Mockito.any(RemoteRpcImplementation.class), Mockito.eq(firstEndpoint.getRpcs()));
testActorRef.tell(new UpdateRemoteEndpoints(ImmutableMap.of(endpointAddress, Optional.of(secondEndpoint))), ActorRef.noSender());
// second registration
inOrder.verify(service).registerRpcImplementation(Mockito.any(RemoteRpcImplementation.class), Mockito.eq(secondEndpoint.getRpcs()));
// verify first registration is closed
inOrder.verify(oldReg).close();
Mockito.verifyNoMoreInteractions(service, oldReg, newReg);
}
use of org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints in project controller by opendaylight.
the class RpcRegistrarTest method testHandleReceiveRemoveEndpoint.
@Test
public void testHandleReceiveRemoveEndpoint() throws Exception {
final Map<Address, Optional<RemoteRpcEndpoint>> endpoints = ImmutableMap.of(endpointAddress, Optional.empty());
testActorRef.tell(new UpdateRemoteEndpoints(endpoints), ActorRef.noSender());
Mockito.verifyNoMoreInteractions(service, oldReg, newReg);
}
use of org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints in project controller by opendaylight.
the class RpcRegistryTest method testRpcAddedOnMultiNodes.
/**
* Three node cluster. Register rpc on 2 nodes. Ensure 3rd gets updated.
*/
@Test
public void testRpcAddedOnMultiNodes() throws Exception {
final TestKit testKit = new TestKit(node3);
// Add rpc on node 1
List<DOMRpcIdentifier> addedRouteIds1 = createRouteIds();
registry1.tell(new AddOrUpdateRoutes(addedRouteIds1), ActorRef.noSender());
final UpdateRemoteEndpoints req1 = registrar3.expectMsgClass(Duration.create(3, TimeUnit.SECONDS), UpdateRemoteEndpoints.class);
// Add rpc on node 2
List<DOMRpcIdentifier> addedRouteIds2 = createRouteIds();
registry2.tell(new AddOrUpdateRoutes(addedRouteIds2), ActorRef.noSender());
final UpdateRemoteEndpoints req2 = registrar3.expectMsgClass(Duration.create(3, TimeUnit.SECONDS), UpdateRemoteEndpoints.class);
Address node2Address = node2.provider().getDefaultAddress();
Address node1Address = node1.provider().getDefaultAddress();
Map<Address, Bucket<RoutingTable>> buckets = retrieveBuckets(registry3, testKit, node1Address, node2Address);
verifyBucket(buckets.get(node1Address), addedRouteIds1);
verifyBucket(buckets.get(node2Address), addedRouteIds2);
Map<Address, Long> versions = retrieveVersions(registry3, testKit);
Assert.assertEquals("Version for bucket " + node1Address, (Long) buckets.get(node1Address).getVersion(), versions.get(node1Address));
Assert.assertEquals("Version for bucket " + node2Address, (Long) buckets.get(node2Address).getVersion(), versions.get(node2Address));
assertEndpoints(req1, node1Address, invoker1);
assertEndpoints(req2, node2Address, invoker2);
}
use of org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints in project controller by opendaylight.
the class RpcRegistrarTest method testPostStop.
@Test
public void testPostStop() throws Exception {
testActorRef.tell(new UpdateRemoteEndpoints(ImmutableMap.of(endpointAddress, Optional.of(firstEndpoint))), ActorRef.noSender());
testActorRef.tell(new UpdateRemoteEndpoints(ImmutableMap.of(endpointAddress, Optional.of(secondEndpoint))), ActorRef.noSender());
rpcRegistrar.postStop();
Mockito.verify(oldReg).close();
Mockito.verify(newReg).close();
}
use of org.opendaylight.controller.remote.rpc.registry.RpcRegistry.Messages.UpdateRemoteEndpoints in project controller by opendaylight.
the class RpcRegistrarTest method testHandleReceiveAddEndpoint.
@Test
public void testHandleReceiveAddEndpoint() throws Exception {
final Map<Address, Optional<RemoteRpcEndpoint>> endpoints = ImmutableMap.of(endpointAddress, Optional.of(firstEndpoint));
testActorRef.tell(new UpdateRemoteEndpoints(endpoints), ActorRef.noSender());
Mockito.verify(service).registerRpcImplementation(Mockito.any(RemoteRpcImplementation.class), Mockito.eq(firstEndpoint.getRpcs()));
Mockito.verifyNoMoreInteractions(service, oldReg, newReg);
}
Aggregations