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());
}
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();
}
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());
}
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;
}
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());
}
Aggregations