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