Search in sources :

Example 16 with SendBarrierInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput in project openflowplugin by opendaylight.

the class FlowCapableTransactionServiceImpl method buildRequest.

@Override
protected OfHeader buildRequest(final Xid xid, final SendBarrierInput input) throws ServiceException {
    final BarrierInputBuilder barrierInputOFJavaBuilder = new BarrierInputBuilder();
    barrierInputOFJavaBuilder.setVersion(getVersion());
    barrierInputOFJavaBuilder.setXid(xid.getValue());
    return barrierInputOFJavaBuilder.build();
}
Also used : BarrierInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder)

Example 17 with SendBarrierInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput in project openflowplugin by opendaylight.

the class BarrierUtilTest method testCreateSendBarrierInput.

@Test
public void testCreateSendBarrierInput() throws Exception {
    final SendBarrierInput barrierInput = BarrierUtil.createSendBarrierInput(NODE_REF);
    Assert.assertEquals(NODE_REF, barrierInput.getNode());
    Assert.assertEquals(SendBarrierInput.class, barrierInput.getImplementedInterface());
}
Also used : SendBarrierInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput) Test(org.junit.Test)

Example 18 with SendBarrierInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyIncrementalImplTest method testRemoveRedundantGroups.

@Test
public void testRemoveRedundantGroups() throws Exception {
    Mockito.when(groupCommitter.remove(Matchers.<InstanceIdentifier<Group>>any(), groupCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new RemoveGroupOutputBuilder().build()).buildFuture());
    ItemSyncBox<Group> groupBox1 = new ItemSyncBox<>();
    groupBox1.getItemsToPush().add(DSInputFactory.createGroup(2L));
    groupBox1.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(DSInputFactory.createGroup(1L), DSInputFactory.createGroupWithAction(1L)));
    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.removeRedundantGroups(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(5L, 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(2L, groupCaptorAllValues.get(3).getGroupId().getValue().longValue());
    final InOrder inOrderGroup = Mockito.inOrder(flowCapableTxService, groupCommitter);
    // remove 5
    inOrderGroup.verify(groupCommitter).remove(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.eq(NODE_IDENT));
    inOrderGroup.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
    // remove 3, 4
    inOrderGroup.verify(groupCommitter, Mockito.times(2)).remove(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.eq(NODE_IDENT));
    inOrderGroup.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
    // remove 2
    inOrderGroup.verify(groupCommitter).remove(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.eq(NODE_IDENT));
    inOrderGroup.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
    inOrderGroup.verifyNoMoreInteractions();
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) RemoveGroupOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupOutputBuilder) InOrder(org.mockito.InOrder) ItemSyncBox(org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Test(org.junit.Test)

Example 19 with SendBarrierInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyIncrementalImplTest method testAddMissingGroups_withUpdate.

@Test
public void testAddMissingGroups_withUpdate() throws Exception {
    Mockito.when(groupCommitter.add(Matchers.<InstanceIdentifier<Group>>any(), groupCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new AddGroupOutputBuilder().build()).buildFuture());
    Mockito.when(groupCommitter.update(Matchers.<InstanceIdentifier<Group>>any(), groupUpdateCaptor.capture(), groupUpdateCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new UpdateGroupOutputBuilder().build()).buildFuture());
    ItemSyncBox<Group> groupBox1 = new ItemSyncBox<>();
    groupBox1.getItemsToPush().add(DSInputFactory.createGroup(2L));
    groupBox1.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(DSInputFactory.createGroup(1L), DSInputFactory.createGroupWithAction(1L)));
    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 List<Group> groupUpdateCaptorAllValues = groupUpdateCaptor.getAllValues();
    Assert.assertEquals(2, groupUpdateCaptorAllValues.size());
    Assert.assertEquals(1L, groupUpdateCaptorAllValues.get(0).getGroupId().getValue().longValue());
    Assert.assertEquals(1L, groupUpdateCaptorAllValues.get(1).getGroupId().getValue().longValue());
    final InOrder inOrderGroups = Mockito.inOrder(flowCapableTxService, groupCommitter);
    // add 2, update 1
    inOrderGroups.verify(groupCommitter).add(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.eq(NODE_IDENT));
    inOrderGroups.verify(groupCommitter).update(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<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();
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) InOrder(org.mockito.InOrder) ItemSyncBox(org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdateGroupOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutputBuilder) AddGroupOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutputBuilder) Test(org.junit.Test)

Example 20 with SendBarrierInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyIncrementalImplTest method testAddMissingMeters.

@Test
public void testAddMissingMeters() throws Exception {
    Mockito.when(meterCommitter.add(Matchers.<InstanceIdentifier<Meter>>any(), meterCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new AddMeterOutputBuilder().build()).buildFuture());
    final ItemSyncBox<Meter> meterSyncBox = new ItemSyncBox<>();
    meterSyncBox.getItemsToPush().add(DSInputFactory.createMeter(2L));
    meterSyncBox.getItemsToPush().add(DSInputFactory.createMeter(4L));
    final ListenableFuture<RpcResult<Void>> result = syncPlanPushStrategy.addMissingMeters(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)).add(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();
}
Also used : InOrder(org.mockito.InOrder) ItemSyncBox(org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) AddMeterOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutputBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)31 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)29 InOrder (org.mockito.InOrder)27 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)9 Meter (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter)4 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)4 SendBarrierInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput)4 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)4 LinkedHashMap (java.util.LinkedHashMap)3 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)3 AddFlowOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder)3 AddGroupOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupOutputBuilder)3 AddMeterOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutputBuilder)3 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)2 AddFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput)2 RemoveFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput)2 RemoveFlowOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder)2 UpdateFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput)2 UpdateFlowOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder)2 AddFlowsBatchInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.AddFlowsBatchInput)2