Search in sources :

Example 1 with UpdateGroupInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput 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());
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) UpdateGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput) GroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdateGroupOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutputBuilder) UpdateGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput) Test(org.junit.Test)

Example 2 with UpdateGroupInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput in project openflowplugin by opendaylight.

the class SalGroupServiceImplTest method updateGroup.

private void updateGroup() {
    final UpdatedGroup updatedGroup = new UpdatedGroupBuilder().setGroupId(new GroupId(DUMMY_GROUP_ID)).build();
    final OriginalGroup originalGroup = new OriginalGroupBuilder().setGroupId(new GroupId(DUMMY_GROUP_ID)).build();
    final UpdateGroupInput updateGroupInput = new UpdateGroupInputBuilder().setUpdatedGroup(updatedGroup).setOriginalGroup(originalGroup).build();
    this.<UpdateGroupOutput>mockSuccessfulFuture();
    salGroupService.updateGroup(updateGroupInput);
    verify(mockedRequestContextStack).createRequestContext();
}
Also used : OriginalGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroup) UpdateGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput) OriginalGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroupBuilder) UpdateGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder) UpdatedGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroup) UpdatedGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder) UpdateGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)

Example 3 with UpdateGroupInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput in project openflowplugin by opendaylight.

the class GroupListenerTest method updateGroupTest.

@Test
public void updateGroupTest() throws Exception {
    addFlowCapableNode(NODE_KEY);
    GroupKey groupKey = new GroupKey(new GroupId((long) 255));
    InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Group.class, groupKey);
    Group group = new GroupBuilder().setKey(groupKey).setGroupName("Group1").build();
    WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
    assertCommit(writeTx.submit());
    SalGroupServiceMock salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
    List<AddGroupInput> addGroupCalls = salGroupService.getAddGroupCalls();
    assertEquals(1, addGroupCalls.size());
    assertEquals("DOM-0", addGroupCalls.get(0).getTransactionUri().getValue());
    group = new GroupBuilder().setKey(groupKey).setGroupName("Group2").build();
    writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
    assertCommit(writeTx.submit());
    salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
    List<UpdateGroupInput> updateGroupCalls = salGroupService.getUpdateGroupCalls();
    assertEquals(1, updateGroupCalls.size());
    assertEquals("DOM-1", updateGroupCalls.get(0).getTransactionUri().getValue());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) StaleGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup) Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) AddGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) StaleGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupBuilder) GroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) StaleGroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupKey) SalGroupServiceMock(test.mock.util.SalGroupServiceMock) UpdateGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) FRMTest(test.mock.util.FRMTest) Test(org.junit.Test)

Example 4 with UpdateGroupInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput in project openflowplugin by opendaylight.

the class SalGroupsBatchServiceImpl method updateGroupsBatch.

@Override
public Future<RpcResult<UpdateGroupsBatchOutput>> updateGroupsBatch(final UpdateGroupsBatchInput input) {
    final List<BatchUpdateGroups> batchUpdateGroups = input.getBatchUpdateGroups();
    LOG.trace("Updating groups @ {} : {}", PathUtil.extractNodeId(input.getNode()), batchUpdateGroups.size());
    final ArrayList<ListenableFuture<RpcResult<UpdateGroupOutput>>> resultsLot = new ArrayList<>();
    for (BatchUpdateGroups batchGroup : batchUpdateGroups) {
        final UpdateGroupInput updateGroupInput = new UpdateGroupInputBuilder(input).setOriginalGroup(new OriginalGroupBuilder(batchGroup.getOriginalBatchedGroup()).build()).setUpdatedGroup(new UpdatedGroupBuilder(batchGroup.getUpdatedBatchedGroup()).build()).setGroupRef(createGroupRef(input.getNode(), batchGroup)).setNode(input.getNode()).build();
        resultsLot.add(JdkFutureAdapters.listenInPoolThread(salGroupService.updateGroup(updateGroupInput)));
    }
    final Iterable<Group> groups = batchUpdateGroups.stream().map(BatchGroupInputUpdateGrouping::getUpdatedBatchedGroup).collect(Collectors.toList());
    final ListenableFuture<RpcResult<List<BatchFailedGroupsOutput>>> commonResult = Futures.transform(Futures.allAsList(resultsLot), GroupUtil.<UpdateGroupOutput>createCumulatingFunction(groups, batchUpdateGroups.size()));
    ListenableFuture<RpcResult<UpdateGroupsBatchOutput>> updateGroupsBulkFuture = Futures.transform(commonResult, GroupUtil.GROUP_UPDATE_TRANSFORM);
    if (input.isBarrierAfter()) {
        updateGroupsBulkFuture = BarrierUtil.chainBarrier(updateGroupsBulkFuture, input.getNode(), transactionService, GroupUtil.GROUP_UPDATE_COMPOSING_TRANSFORM);
    }
    return updateGroupsBulkFuture;
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group) UpdateGroupOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput) BatchFailedGroupsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.batch.group.output.list.grouping.BatchFailedGroupsOutput) ArrayList(java.util.ArrayList) OriginalGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroupBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdateGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder) UpdatedGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder) UpdateGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput) BatchUpdateGroups(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.update.groups.batch.input.BatchUpdateGroups) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Example 5 with UpdateGroupInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput in project openflowplugin by opendaylight.

the class SalGroupsBatchServiceImplTest method testUpdateGroupsBatch_success.

@Test
public void testUpdateGroupsBatch_success() throws Exception {
    Mockito.when(salGroupService.updateGroup(Mockito.<UpdateGroupInput>any())).thenReturn(RpcResultBuilder.success(new UpdateGroupOutputBuilder().build()).buildFuture());
    final UpdateGroupsBatchInput input = new UpdateGroupsBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchUpdateGroups(Lists.newArrayList(createEmptyBatchUpdateGroup(42L), createEmptyBatchUpdateGroup(44L))).build();
    final Future<RpcResult<UpdateGroupsBatchOutput>> resultFuture = salGroupsBatchService.updateGroupsBatch(input);
    Assert.assertTrue(resultFuture.isDone());
    Assert.assertTrue(resultFuture.get().isSuccessful());
    final InOrder inOrder = Mockito.inOrder(salGroupService, transactionService);
    inOrder.verify(salGroupService, Mockito.times(2)).updateGroup(updateGroupInputCpt.capture());
    final List<UpdateGroupInput> allValues = updateGroupInputCpt.getAllValues();
    Assert.assertEquals(2, allValues.size());
    Assert.assertEquals(42, allValues.get(0).getOriginalGroup().getGroupId().getValue().longValue());
    Assert.assertEquals(43, allValues.get(0).getUpdatedGroup().getGroupId().getValue().longValue());
    Assert.assertEquals(44, allValues.get(1).getOriginalGroup().getGroupId().getValue().longValue());
    Assert.assertEquals(45, allValues.get(1).getUpdatedGroup().getGroupId().getValue().longValue());
    inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
}
Also used : UpdateGroupsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.UpdateGroupsBatchInputBuilder) InOrder(org.mockito.InOrder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) UpdateGroupOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutputBuilder) UpdateGroupsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.UpdateGroupsBatchInput) UpdateGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput) Test(org.junit.Test)

Aggregations

UpdateGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInput)6 Test (org.junit.Test)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 UpdateGroupOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput)3 InOrder (org.mockito.InOrder)2 UpdateGroupInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder)2 UpdateGroupOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutputBuilder)2 OriginalGroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroupBuilder)2 UpdatedGroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder)2 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)2 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)2 GroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder)2 UpdateGroupsBatchInput (org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.UpdateGroupsBatchInput)2 UpdateGroupsBatchInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.UpdateGroupsBatchInputBuilder)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ArrayList (java.util.ArrayList)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)1 AddGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput)1 OriginalGroup (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.OriginalGroup)1