Search in sources :

Example 36 with GroupId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId in project openflowplugin by opendaylight.

the class StatisticsGatheringUtilsTest method testGatherStatistics_group.

@Test
public void testGatherStatistics_group() throws Exception {
    final MultipartType type = MultipartType.OFPMPGROUP;
    final long groupIdValue = 19L;
    final GroupStatsBuilder groupStatsBld = new GroupStatsBuilder().setBucketStats(Lists.newArrayList(createBucketStat(21L, 42L))).setByteCount(BigInteger.valueOf(84L)).setPacketCount(BigInteger.valueOf(63L)).setDurationSec(11L).setDurationNsec(12L).setRefCount(13L).setGroupId(new GroupId(groupIdValue));
    final MultipartReplyGroupBuilder mpReplyGroupBld = new MultipartReplyGroupBuilder();
    mpReplyGroupBld.setGroupStats(Lists.newArrayList(groupStatsBld.build()));
    final MultipartReplyGroupCaseBuilder mpReplyGroupCaseBld = new MultipartReplyGroupCaseBuilder();
    mpReplyGroupCaseBld.setMultipartReplyGroup(mpReplyGroupBld.build());
    final MultipartReply groupStatsUpdated = assembleMPReplyMessage(type, mpReplyGroupCaseBld.build());
    final List<MultipartReply> statsData = Collections.singletonList(groupStatsUpdated);
    fireAndCheck(type, statsData);
    final InstanceIdentifier<GroupStatistics> groupPath = dummyNodePath.augmentation(FlowCapableNode.class).child(Group.class, new GroupKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId(groupIdValue))).augmentation(NodeGroupStatistics.class).child(GroupStatistics.class);
    verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(groupPath), Matchers.any(GroupStatistics.class));
}
Also used : MultipartReplyGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCaseBuilder) MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) MultipartReplyGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroupBuilder) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder) NodeGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) NodeGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics) GroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatistics) Test(org.junit.Test)

Example 37 with GroupId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId in project openflowplugin by opendaylight.

the class SingleLayerGroupServiceTest method buildRequest.

@Test
public void buildRequest() throws Exception {
    final AddGroupInput input = new AddGroupInputBuilder().setGroupId(new GroupId(GROUP_ID)).build();
    final OfHeader ofHeader = service.buildRequest(DUMMY_XID, input);
    assertEquals(GroupMessage.class, ofHeader.getImplementedInterface());
    final GroupMessage result = GroupMessage.class.cast(ofHeader);
    assertEquals(GroupModCommand.OFPGCADD, result.getCommand());
    assertEquals(GROUP_ID, result.getGroupId().getValue().longValue());
}
Also used : AddGroupInput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) GroupMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupMessage) AddGroupInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) Test(org.junit.Test)

Example 38 with GroupId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId in project openflowplugin by opendaylight.

the class GroupListenerTest method addTwoGroupsTest.

@Test
public void addTwoGroupsTest() 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());
    groupKey = new GroupKey(new GroupId((long) 256));
    groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Group.class, groupKey);
    group = new GroupBuilder().setKey(groupKey).setGroupName("Group1").build();
    writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
    assertCommit(writeTx.submit());
    salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
    addGroupCalls = salGroupService.getAddGroupCalls();
    assertEquals(2, addGroupCalls.size());
    assertEquals("DOM-1", addGroupCalls.get(1).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) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) 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) 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 39 with GroupId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId in project openflowplugin by opendaylight.

the class GroupListenerTest method staleGroupCreationTest.

@Test
public void staleGroupCreationTest() throws Exception {
    addFlowCapableNode(NODE_KEY);
    StaleGroupKey groupKey = new StaleGroupKey(new GroupId((long) 255));
    InstanceIdentifier<StaleGroup> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(StaleGroup.class, groupKey);
    StaleGroup group = new StaleGroupBuilder().setKey(groupKey).setGroupName("Stale_Group1").build();
    WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
    assertCommit(writeTx.submit());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) 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) StaleGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroup) StaleGroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.StaleGroupKey) 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 40 with GroupId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId 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)

Aggregations

ArrayList (java.util.ArrayList)41 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)36 Test (org.junit.Test)28 Bucket (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket)27 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId)22 Group (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group)21 BigInteger (java.math.BigInteger)19 ActionGroup (org.opendaylight.genius.mdsalutil.actions.ActionGroup)18 GroupBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder)12 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)11 BucketsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder)10 BucketBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder)10 ByteBuf (io.netty.buffer.ByteBuf)9 GroupKey (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey)9 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)8 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)8 AddGroupInput (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInput)8 AddGroupInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder)8 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)7 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)6