use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter in project openflowplugin by opendaylight.
the class MeterForwarderTest method testUpdate.
@Test
public void testUpdate() throws Exception {
Mockito.when(salMeterService.updateMeter(updateMeterInputCpt.capture())).thenReturn(RpcResultBuilder.success(new UpdateMeterOutputBuilder().setTransactionId(txId).build()).buildFuture());
Meter meterOriginal = new MeterBuilder(meter).build();
Meter meterUpdate = new MeterBuilder(meter).setMeterName("another-test").build();
final Future<RpcResult<UpdateMeterOutput>> updateResult = meterForwarder.update(meterPath, meterOriginal, meterUpdate, flowCapableNodePath);
Mockito.verify(salMeterService).updateMeter(Matchers.<UpdateMeterInput>any());
Assert.assertTrue(updateResult.isDone());
final RpcResult<UpdateMeterOutput> meterResult = updateResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(meterResult.isSuccessful());
Assert.assertEquals(1, meterResult.getResult().getTransactionId().getValue().intValue());
final UpdateMeterInput updateMeterInput = updateMeterInputCpt.getValue();
Assert.assertEquals(meterPath, updateMeterInput.getMeterRef().getValue());
Assert.assertEquals(nodePath, updateMeterInput.getNode().getValue());
Assert.assertEquals("test-meter", updateMeterInput.getOriginalMeter().getMeterName());
Assert.assertEquals("another-test", updateMeterInput.getUpdatedMeter().getMeterName());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter in project openflowplugin by opendaylight.
the class MeterForwarderTest method testRemove.
@Test
public void testRemove() throws Exception {
Mockito.when(salMeterService.removeMeter(removeMeterInputCpt.capture())).thenReturn(RpcResultBuilder.success(new RemoveMeterOutputBuilder().setTransactionId(txId).build()).buildFuture());
Meter removeMeter = new MeterBuilder(meter).build();
final Future<RpcResult<RemoveMeterOutput>> removeResult = meterForwarder.remove(meterPath, removeMeter, flowCapableNodePath);
Mockito.verify(salMeterService).removeMeter(Matchers.<RemoveMeterInput>any());
Assert.assertTrue(removeResult.isDone());
final RpcResult<RemoveMeterOutput> meterResult = removeResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(meterResult.isSuccessful());
Assert.assertEquals(1, meterResult.getResult().getTransactionId().getValue().intValue());
final RemoveMeterInput removeMeterInput = removeMeterInputCpt.getValue();
Assert.assertEquals(meterPath, removeMeterInput.getMeterRef().getValue());
Assert.assertEquals(nodePath, removeMeterInput.getNode().getValue());
Assert.assertEquals("test-meter", removeMeterInput.getMeterName());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter in project openflowplugin by opendaylight.
the class MeterForwarderTest method testAdd.
@Test
public void testAdd() throws Exception {
Mockito.when(salMeterService.addMeter(addMeterInputCpt.capture())).thenReturn(RpcResultBuilder.success(new AddMeterOutputBuilder().setTransactionId(txId).build()).buildFuture());
final Future<RpcResult<AddMeterOutput>> addResult = meterForwarder.add(meterPath, meter, flowCapableNodePath);
Mockito.verify(salMeterService).addMeter(Matchers.<AddMeterInput>any());
Assert.assertTrue(addResult.isDone());
final RpcResult<AddMeterOutput> meterResult = addResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(meterResult.isSuccessful());
Assert.assertEquals(1, meterResult.getResult().getTransactionId().getValue().intValue());
final AddMeterInput addMeterInput = addMeterInputCpt.getValue();
Assert.assertEquals(meterPath, addMeterInput.getMeterRef().getValue());
Assert.assertEquals(nodePath, addMeterInput.getNode().getValue());
Assert.assertEquals("test-meter", addMeterInput.getMeterName());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter 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.flow.inventory.rev130819.meters.Meter in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImplTest method setUp.
@Before
public void setUp() throws Exception {
Mockito.when(flowCapableTxService.sendBarrier(Matchers.<SendBarrierInput>any())).thenReturn(RpcResultBuilder.success((Void) null).buildFuture());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(groupCommitter).add(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(groupCommitter).update(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(groupCommitter).remove(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(flowCommitter).add(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(flowCommitter).update(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(flowCommitter).remove(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(meterCommitter).add(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(meterCommitter).update(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(meterCommitter).remove(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
Mockito.doAnswer(createSalServiceFutureAnswer()).when(tableCommitter).update(Matchers.<InstanceIdentifier<TableFeatures>>any(), Matchers.<TableFeatures>any(), Matchers.<TableFeatures>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
syncPlanPushStrategy = new SyncPlanPushStrategyIncrementalImpl().setMeterForwarder(meterCommitter).setTableForwarder(tableCommitter).setGroupForwarder(groupCommitter).setFlowForwarder(flowCommitter).setTransactionService(flowCapableTxService);
counters = new SyncCrudCounters();
}
Aggregations