Search in sources :

Example 16 with GroupOperation

use of org.onosproject.net.group.GroupOperation in project onos by opennetworkinglab.

the class OpenFlowGroupProviderTest method groupModFailure.

@Test
public void groupModFailure() {
    TestOpenFlowGroupProviderService testProviderService = (TestOpenFlowGroupProviderService) providerService;
    GroupId groupId = new GroupId(1);
    List<GroupBucket> bucketList = Lists.newArrayList();
    TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
    builder.setOutput(PortNumber.portNumber(1));
    GroupBucket bucket = DefaultGroupBucket.createSelectGroupBucket(builder.build());
    bucketList.add(bucket);
    GroupBuckets buckets = new GroupBuckets(bucketList);
    List<GroupOperation> operationList = Lists.newArrayList();
    GroupOperation operation = GroupOperation.createAddGroupOperation(groupId, GroupDescription.Type.SELECT, buckets);
    operationList.add(operation);
    GroupOperations operations = new GroupOperations(operationList);
    provider.performGroupOperation(deviceId, operations);
    OFGroupModFailedErrorMsg.Builder errorBuilder = OFFactories.getFactory(OFVersion.OF_13).errorMsgs().buildGroupModFailedErrorMsg();
    OFGroupMod.Builder groupBuilder = OFFactories.getFactory(OFVersion.OF_13).buildGroupModify();
    groupBuilder.setGroupType(OFGroupType.ALL);
    groupBuilder.setGroup(OFGroup.of(1));
    errorBuilder.setCode(OFGroupModFailedCode.GROUP_EXISTS);
    errorBuilder.setXid(provider.getXidAndAdd(0) - 1);
    controller.processPacket(dpid1, errorBuilder.build());
    assertNotNull("Operation failed should not be null", testProviderService.failedOperation);
}
Also used : OFGroupModFailedErrorMsg(org.projectfloodlight.openflow.protocol.errormsg.OFGroupModFailedErrorMsg) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) GroupId(org.onosproject.core.GroupId) OFGroupMod(org.projectfloodlight.openflow.protocol.OFGroupMod) GroupOperations(org.onosproject.net.group.GroupOperations) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) GroupOperation(org.onosproject.net.group.GroupOperation) Test(org.junit.Test)

Example 17 with GroupOperation

use of org.onosproject.net.group.GroupOperation in project onos by opennetworkinglab.

the class VirtualNetworkGroupManagerTest method testAuditWithExtraneousMissingGroups.

// Test AUDIT process with extraneous groups and missing groups
private void testAuditWithExtraneousMissingGroups(NetworkId networkId, DeviceId deviceId) {
    VirtualNetworkGroupManager groupManager;
    VirtualGroupProviderService providerService;
    if (networkId.id() == 1) {
        groupManager = groupManager1;
        providerService = providerService1;
    } else {
        groupManager = groupManager2;
        providerService = providerService2;
    }
    PortNumber[] ports1 = { PortNumber.portNumber(31), PortNumber.portNumber(32) };
    PortNumber[] ports2 = { PortNumber.portNumber(41), PortNumber.portNumber(42) };
    GroupId gId1 = new GroupId(1);
    Group group1 = createSouthboundGroupEntry(gId1, Arrays.asList(ports1), 0, deviceId);
    GroupId gId2 = new GroupId(2);
    Group group2 = createSouthboundGroupEntry(gId2, Arrays.asList(ports2), 0, deviceId);
    List<Group> groupEntries = Arrays.asList(group1, group2);
    providerService.pushGroupMetrics(deviceId, groupEntries);
    GroupKey key = new DefaultGroupKey("group1BeforeAudit".getBytes());
    Group createdGroup = groupManager.getGroup(deviceId, key);
    List<GroupOperation> expectedGroupOps = Arrays.asList(GroupOperation.createDeleteGroupOperation(gId1, Group.Type.SELECT), GroupOperation.createDeleteGroupOperation(gId2, Group.Type.SELECT), GroupOperation.createAddGroupOperation(createdGroup.id(), Group.Type.SELECT, createdGroup.buckets()));
    if (deviceId.equals(VDID1)) {
        provider.validate(networkId, deviceId, expectedGroupOps);
    }
}
Also used : VirtualGroupProviderService(org.onosproject.incubator.net.virtual.provider.VirtualGroupProviderService) DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) PortNumber(org.onosproject.net.PortNumber) GroupOperation(org.onosproject.net.group.GroupOperation) GroupId(org.onosproject.core.GroupId)

Example 18 with GroupOperation

use of org.onosproject.net.group.GroupOperation in project onos by opennetworkinglab.

the class SimpleGroupStoreTest method testGroupOperationFailure.

@Test
public void testGroupOperationFailure() {
    simpleGroupStore.deviceInitialAuditCompleted(D1, true);
    ApplicationId appId = new DefaultApplicationId(2, "org.groupstore.test");
    GroupKey key = new DefaultGroupKey("group1".getBytes());
    PortNumber[] ports = { PortNumber.portNumber(31), PortNumber.portNumber(32) };
    List<PortNumber> outPorts = new ArrayList<>();
    outPorts.add(ports[0]);
    outPorts.add(ports[1]);
    List<GroupBucket> buckets = new ArrayList<>();
    for (PortNumber portNumber : outPorts) {
        TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
        tBuilder.setOutput(portNumber).setEthDst(MacAddress.valueOf("00:00:00:00:00:02")).setEthSrc(MacAddress.valueOf("00:00:00:00:00:01")).pushMpls().setMpls(MplsLabel.mplsLabel(106));
        buckets.add(DefaultGroupBucket.createSelectGroupBucket(tBuilder.build()));
    }
    GroupBuckets groupBuckets = new GroupBuckets(buckets);
    GroupDescription groupDesc = new DefaultGroupDescription(D1, Group.Type.SELECT, groupBuckets, key, null, appId);
    InternalGroupStoreDelegate checkStoreGroupDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_ADD_REQUESTED);
    simpleGroupStore.setDelegate(checkStoreGroupDelegate);
    // Testing storeGroup operation
    simpleGroupStore.storeGroupDescription(groupDesc);
    simpleGroupStore.unsetDelegate(checkStoreGroupDelegate);
    // Testing Group add operation failure
    Group createdGroup = simpleGroupStore.getGroup(D1, key);
    checkStoreGroupDelegate.verifyGroupId(createdGroup.id());
    GroupOperation groupAddOp = GroupOperation.createAddGroupOperation(createdGroup.id(), createdGroup.type(), createdGroup.buckets());
    InternalGroupStoreDelegate checkGroupAddFailureDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_ADD_FAILED);
    simpleGroupStore.setDelegate(checkGroupAddFailureDelegate);
    simpleGroupStore.groupOperationFailed(D1, groupAddOp);
    // Testing Group modify operation failure
    simpleGroupStore.unsetDelegate(checkGroupAddFailureDelegate);
    GroupOperation groupModOp = GroupOperation.createModifyGroupOperation(createdGroup.id(), createdGroup.type(), createdGroup.buckets());
    InternalGroupStoreDelegate checkGroupModFailureDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_UPDATE_FAILED);
    simpleGroupStore.setDelegate(checkGroupModFailureDelegate);
    simpleGroupStore.groupOperationFailed(D1, groupModOp);
    // Testing Group modify operation failure
    simpleGroupStore.unsetDelegate(checkGroupModFailureDelegate);
    GroupOperation groupDelOp = GroupOperation.createDeleteGroupOperation(createdGroup.id(), createdGroup.type());
    InternalGroupStoreDelegate checkGroupDelFailureDelegate = new InternalGroupStoreDelegate(key, groupBuckets, GroupEvent.Type.GROUP_REMOVE_FAILED);
    simpleGroupStore.setDelegate(checkGroupDelFailureDelegate);
    simpleGroupStore.groupOperationFailed(D1, groupDelOp);
}
Also used : DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) GroupKey(org.onosproject.net.group.GroupKey) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) ArrayList(java.util.ArrayList) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) GroupBuckets(org.onosproject.net.group.GroupBuckets) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroupKey(org.onosproject.net.group.DefaultGroupKey) GroupBucket(org.onosproject.net.group.GroupBucket) DefaultGroupBucket(org.onosproject.net.group.DefaultGroupBucket) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) PortNumber(org.onosproject.net.PortNumber) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupOperation(org.onosproject.net.group.GroupOperation) Test(org.junit.Test)

Aggregations

GroupOperation (org.onosproject.net.group.GroupOperation)18 DefaultGroup (org.onosproject.net.group.DefaultGroup)13 Group (org.onosproject.net.group.Group)13 DefaultGroupKey (org.onosproject.net.group.DefaultGroupKey)12 GroupKey (org.onosproject.net.group.GroupKey)12 PortNumber (org.onosproject.net.PortNumber)10 GroupId (org.onosproject.core.GroupId)8 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)8 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)8 DefaultGroupBucket (org.onosproject.net.group.DefaultGroupBucket)8 GroupBucket (org.onosproject.net.group.GroupBucket)8 GroupBuckets (org.onosproject.net.group.GroupBuckets)8 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)5 VirtualGroupProviderService (org.onosproject.incubator.net.virtual.provider.VirtualGroupProviderService)5 GroupOperations (org.onosproject.net.group.GroupOperations)3 DefaultGroupDescription (org.onosproject.net.group.DefaultGroupDescription)2 GroupDescription (org.onosproject.net.group.GroupDescription)2 GroupEvent (org.onosproject.net.group.GroupEvent)2 Dpid (org.onosproject.openflow.controller.Dpid)2