use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class GroupForwarderTest method testUpdate.
@Test
public void testUpdate() throws Exception {
Mockito.when(salGroupService.updateGroup(updateGroupInputCpt.capture())).thenReturn(RpcResultBuilder.success(new UpdateGroupOutputBuilder().setTransactionId(txId).build()).buildFuture());
Group groupOriginal = new GroupBuilder(group).build();
Group groupUpdate = new GroupBuilder(group).setGroupName("another-test").build();
final Future<RpcResult<UpdateGroupOutput>> addResult = groupForwarder.update(groupPath, groupOriginal, groupUpdate, flowCapableNodePath);
Mockito.verify(salGroupService).updateGroup(Matchers.<UpdateGroupInput>any());
Assert.assertTrue(addResult.isDone());
final RpcResult<UpdateGroupOutput> result = addResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(result.isSuccessful());
Assert.assertEquals(1, result.getResult().getTransactionId().getValue().intValue());
final UpdateGroupInput updateGroupInput = updateGroupInputCpt.getValue();
Assert.assertEquals(groupPath, updateGroupInput.getGroupRef().getValue());
Assert.assertEquals(nodePath, updateGroupInput.getNode().getValue());
Assert.assertNotNull(updateGroupInput.getOriginalGroup().getBuckets());
Assert.assertNotNull(updateGroupInput.getUpdatedGroup().getBuckets());
Assert.assertEquals("test-group", updateGroupInput.getOriginalGroup().getGroupName());
Assert.assertEquals("another-test", updateGroupInput.getUpdatedGroup().getGroupName());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImplTest method testRemoveRedundantMeters.
@Test
public void testRemoveRedundantMeters() throws Exception {
Mockito.when(meterCommitter.remove(Matchers.<InstanceIdentifier<Meter>>any(), meterCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new RemoveMeterOutputBuilder().build()).buildFuture());
final ItemSyncBox<Meter> meterSyncBox = new ItemSyncBox<>();
meterSyncBox.getItemsToPush().add(DSInputFactory.createMeter(2L));
meterSyncBox.getItemsToPush().add(DSInputFactory.createMeter(4L));
meterSyncBox.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(DSInputFactory.createMeter(1L), DSInputFactory.createMeterWithBody(1L)));
final ListenableFuture<RpcResult<Void>> result = syncPlanPushStrategy.removeRedundantMeters(NODE_ID, NODE_IDENT, meterSyncBox, counters);
Assert.assertTrue(result.isDone());
Assert.assertTrue(result.get().isSuccessful());
final List<Meter> metercaptorAllValues = meterCaptor.getAllValues();
Assert.assertEquals(2, metercaptorAllValues.size());
Assert.assertEquals(2L, metercaptorAllValues.get(0).getMeterId().getValue().longValue());
Assert.assertEquals(4L, metercaptorAllValues.get(1).getMeterId().getValue().longValue());
final InOrder inOrderMeter = Mockito.inOrder(flowCapableTxService, meterCommitter);
inOrderMeter.verify(meterCommitter, Mockito.times(2)).remove(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.eq(NODE_IDENT));
// TODO: uncomment when enabled in impl
// inOrderMeter.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
inOrderMeter.verifyNoMoreInteractions();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImplTest method testAddMissingFlows_withUpdate.
@Test
public void testAddMissingFlows_withUpdate() throws Exception {
Mockito.when(flowCommitter.add(Matchers.<InstanceIdentifier<Flow>>any(), flowCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new AddFlowOutputBuilder().build()).buildFuture());
Mockito.when(flowCommitter.update(Matchers.<InstanceIdentifier<Flow>>any(), flowUpdateCaptor.capture(), flowUpdateCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new UpdateFlowOutputBuilder().build()).buildFuture());
final ItemSyncBox<Flow> flowBox = new ItemSyncBox<>();
flowBox.getItemsToPush().add(DSInputFactory.createFlow("f3", 3));
flowBox.getItemsToPush().add(DSInputFactory.createFlow("f4", 4));
flowBox.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(DSInputFactory.createFlow("f1", 1), DSInputFactory.createFlowWithInstruction("f1", 1)));
final Map<TableKey, ItemSyncBox<Flow>> flowBoxMap = new LinkedHashMap<>();
flowBoxMap.put(new TableKey((short) 0), flowBox);
// TODO: replace null
final ListenableFuture<RpcResult<Void>> result = syncPlanPushStrategy.addMissingFlows(NODE_ID, NODE_IDENT, flowBoxMap, counters);
Assert.assertTrue(result.isDone());
Assert.assertTrue(result.get().isSuccessful());
final List<Flow> flowCaptorAllValues = flowCaptor.getAllValues();
Assert.assertEquals(2, flowCaptorAllValues.size());
Assert.assertEquals("f3", flowCaptorAllValues.get(0).getId().getValue());
Assert.assertEquals("f4", flowCaptorAllValues.get(1).getId().getValue());
final List<Flow> flowUpdateCaptorAllValues = flowUpdateCaptor.getAllValues();
Assert.assertEquals(2, flowUpdateCaptorAllValues.size());
Assert.assertEquals("f1", flowUpdateCaptorAllValues.get(0).getId().getValue());
Assert.assertEquals("f1", flowUpdateCaptorAllValues.get(1).getId().getValue());
final InOrder inOrderFlow = Mockito.inOrder(flowCapableTxService, flowCommitter);
// add f3, f4
inOrderFlow.verify(flowCommitter, Mockito.times(2)).add(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.eq(NODE_IDENT));
// update f1
inOrderFlow.verify(flowCommitter).update(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<Flow>any(), Matchers.eq(NODE_IDENT));
// TODO: uncomment when enabled in impl
// inOrderFlow.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
inOrderFlow.verifyNoMoreInteractions();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImplTest method testAddMissingGroups.
@Test
public void testAddMissingGroups() throws Exception {
Mockito.when(groupCommitter.add(Matchers.<InstanceIdentifier<Group>>any(), groupCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new AddGroupOutputBuilder().build()).buildFuture());
ItemSyncBox<Group> groupBox1 = new ItemSyncBox<>();
groupBox1.getItemsToPush().add(DSInputFactory.createGroup(2L));
ItemSyncBox<Group> groupBox2 = new ItemSyncBox<>();
groupBox2.getItemsToPush().add(DSInputFactory.createGroupWithPreconditions(3L, 2L));
groupBox2.getItemsToPush().add(DSInputFactory.createGroupWithPreconditions(4L, 2L));
ItemSyncBox<Group> groupBox3 = new ItemSyncBox<>();
groupBox3.getItemsToPush().add(DSInputFactory.createGroupWithPreconditions(5L, 3L, 4L));
final List<ItemSyncBox<Group>> groupBoxLot = Lists.newArrayList(groupBox1, groupBox2, groupBox3);
final ListenableFuture<RpcResult<Void>> result = syncPlanPushStrategy.addMissingGroups(NODE_ID, NODE_IDENT, groupBoxLot, counters);
Assert.assertTrue(result.isDone());
Assert.assertTrue(result.get().isSuccessful());
final List<Group> groupCaptorAllValues = groupCaptor.getAllValues();
Assert.assertEquals(4, groupCaptorAllValues.size());
Assert.assertEquals(2L, groupCaptorAllValues.get(0).getGroupId().getValue().longValue());
Assert.assertEquals(3L, groupCaptorAllValues.get(1).getGroupId().getValue().longValue());
Assert.assertEquals(4L, groupCaptorAllValues.get(2).getGroupId().getValue().longValue());
Assert.assertEquals(5L, groupCaptorAllValues.get(3).getGroupId().getValue().longValue());
final InOrder inOrderGroups = Mockito.inOrder(flowCapableTxService, groupCommitter);
// add 2
inOrderGroups.verify(groupCommitter).add(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.eq(NODE_IDENT));
inOrderGroups.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
// add 3, 4
inOrderGroups.verify(groupCommitter, Mockito.times(2)).add(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.eq(NODE_IDENT));
inOrderGroups.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
// add 5
inOrderGroups.verify(groupCommitter).add(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.eq(NODE_IDENT));
inOrderGroups.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
inOrderGroups.verifyNoMoreInteractions();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImplTest method testUpdateTableFeatures.
@Test
public void testUpdateTableFeatures() throws Exception {
Mockito.when(tableCommitter.update(Matchers.<InstanceIdentifier<TableFeatures>>any(), Matchers.isNull(TableFeatures.class), tableFeaturesCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new UpdateTableOutputBuilder().build()).buildFuture());
final FlowCapableNode operational = new FlowCapableNodeBuilder().setTable(Collections.singletonList(new TableBuilder().setId((short) 1).build())).setTableFeatures(Collections.singletonList(new TableFeaturesBuilder().setName("test table features").setTableId((short) 1).build())).build();
final ListenableFuture<RpcResult<Void>> result = syncPlanPushStrategy.updateTableFeatures(NODE_IDENT, operational);
Assert.assertTrue(result.isDone());
Assert.assertTrue(result.get().isSuccessful());
final List<TableFeatures> groupCaptorAllValues = tableFeaturesCaptor.getAllValues();
// TODO: uncomment when enabled in impl
// Assert.assertEquals(1, groupCaptorAllValues.size());
// Assert.assertEquals("test table features", groupCaptorAllValues.get(0).getName());
// Assert.assertEquals(1, groupCaptorAllValues.get(0).getTableId().intValue());
Mockito.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
}
Aggregations