use of org.onosproject.net.group.DefaultGroupKey in project onos by opennetworkinglab.
the class GroupManagerTest method testAuditWithConfirmedGroups.
// Test AUDIT with confirmed groups
private Group testAuditWithConfirmedGroups(DeviceId deviceId) {
GroupKey key = new DefaultGroupKey("group1BeforeAudit".getBytes());
Group createdGroup = groupService.getGroup(deviceId, key);
createdGroup = new DefaultGroup(createdGroup.id(), deviceId, Group.Type.SELECT, createdGroup.buckets());
List<Group> groupEntries = Collections.singletonList(createdGroup);
providerService.pushGroupMetrics(deviceId, groupEntries);
internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_ADDED));
return createdGroup;
}
use of org.onosproject.net.group.DefaultGroupKey in project onos by opennetworkinglab.
the class GroupManagerTest method testInitialAuditWithPendingGroupRequests.
// Test initial AUDIT process with pending group requests
private void testInitialAuditWithPendingGroupRequests(DeviceId deviceId) {
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);
// Non zero reference count will make the group manager to queue
// the extraneous groups until reference count is zero.
Group group2 = createSouthboundGroupEntry(gId2, Arrays.asList(ports2), 2, deviceId);
List<Group> groupEntries = Arrays.asList(group1, group2);
providerService.pushGroupMetrics(deviceId, groupEntries);
// First group metrics would trigger the device audit completion
// post which all pending group requests are also executed.
GroupKey key = new DefaultGroupKey("group1BeforeAudit".getBytes());
Group createdGroup = groupService.getGroup(deviceId, key);
int createdGroupId = createdGroup.id().id();
assertNotEquals(gId1.id().intValue(), createdGroupId);
assertNotEquals(gId2.id().intValue(), createdGroupId);
List<GroupOperation> expectedGroupOps = Arrays.asList(GroupOperation.createDeleteGroupOperation(gId1, Group.Type.SELECT), GroupOperation.createAddGroupOperation(createdGroup.id(), Group.Type.SELECT, createdGroup.buckets()));
if (deviceId.equals(DID)) {
internalProvider.validate(deviceId, expectedGroupOps);
} else {
this.validate(deviceId, expectedGroupOps);
}
}
use of org.onosproject.net.group.DefaultGroupKey in project onos by opennetworkinglab.
the class GroupManagerTest method testAddBuckets.
// Test group add bucket operations
private void testAddBuckets(DeviceId deviceId) {
GroupKey addKey = new DefaultGroupKey("group1AddBuckets".getBytes());
GroupKey prevKey = new DefaultGroupKey("group1BeforeAudit".getBytes());
Group createdGroup = groupService.getGroup(deviceId, prevKey);
List<GroupBucket> buckets = new ArrayList<>();
buckets.addAll(createdGroup.buckets().buckets());
PortNumber[] addPorts = { PortNumber.portNumber(51), PortNumber.portNumber(52) };
List<PortNumber> outPorts;
outPorts = new ArrayList<>();
outPorts.addAll(Arrays.asList(addPorts));
List<GroupBucket> addBuckets;
addBuckets = 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));
addBuckets.add(DefaultGroupBucket.createSelectGroupBucket(tBuilder.build()));
buckets.add(DefaultGroupBucket.createSelectGroupBucket(tBuilder.build()));
}
GroupBuckets groupAddBuckets = new GroupBuckets(addBuckets);
groupService.addBucketsToGroup(deviceId, prevKey, groupAddBuckets, addKey, appId);
GroupBuckets updatedBuckets = new GroupBuckets(buckets);
List<GroupOperation> expectedGroupOps = Collections.singletonList(GroupOperation.createModifyGroupOperation(createdGroup.id(), Group.Type.SELECT, updatedBuckets));
if (deviceId.equals(DID)) {
internalProvider.validate(deviceId, expectedGroupOps);
} else {
this.validate(deviceId, expectedGroupOps);
}
Group existingGroup = groupService.getGroup(deviceId, addKey);
List<Group> groupEntries = Collections.singletonList(existingGroup);
providerService.pushGroupMetrics(deviceId, groupEntries);
internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_UPDATED));
}
use of org.onosproject.net.group.DefaultGroupKey in project onos by opennetworkinglab.
the class GroupManagerTest method testRemoveGroup.
// Test group remove operations
private void testRemoveGroup(DeviceId deviceId) {
GroupKey currKey = new DefaultGroupKey("group1RemoveBuckets".getBytes());
Group existingGroup = groupService.getGroup(deviceId, currKey);
groupService.removeGroup(deviceId, currKey, appId);
List<GroupOperation> expectedGroupOps = Collections.singletonList(GroupOperation.createDeleteGroupOperation(existingGroup.id(), Group.Type.SELECT));
if (deviceId.equals(DID)) {
internalProvider.validate(deviceId, expectedGroupOps);
} else {
this.validate(deviceId, expectedGroupOps);
}
List<Group> groupEntries = Collections.emptyList();
providerService.pushGroupMetrics(deviceId, groupEntries);
internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_REMOVED));
}
use of org.onosproject.net.group.DefaultGroupKey in project onos by opennetworkinglab.
the class SimpleGroupStoreTest method testGroupStoreOperations.
/**
* Tests group store operations. The following operations are tested:
* a)Tests device group audit completion status change
* b)Tests storeGroup operation
* c)Tests getGroupCount operation
* d)Tests getGroup operation
* e)Tests getGroups operation
* f)Tests addOrUpdateGroupEntry operation from southbound
* g)Tests updateGroupDescription for ADD operation from northbound
* h)Tests updateGroupDescription for REMOVE operation from northbound
* i)Tests deleteGroupDescription operation from northbound
* j)Tests removeGroupEntry operation from southbound
*/
@Test
public void testGroupStoreOperations() {
// Set the Device AUDIT completed in the store
simpleGroupStore.deviceInitialAuditCompleted(D1, true);
// Testing storeGroup operation
GroupKey newKey = new DefaultGroupKey("group1".getBytes());
testStoreAndGetGroup(newKey);
// Testing addOrUpdateGroupEntry operation from southbound
GroupKey currKey = newKey;
testAddGroupEntryFromSB(currKey);
// Testing updateGroupDescription for ADD operation from northbound
newKey = new DefaultGroupKey("group1AddBuckets".getBytes());
testAddBuckets(currKey, newKey);
// Testing updateGroupDescription for REMOVE operation from northbound
currKey = newKey;
newKey = new DefaultGroupKey("group1RemoveBuckets".getBytes());
testRemoveBuckets(currKey, newKey);
// Testing updateGroupDescription for SET operation from northbound
currKey = newKey;
newKey = new DefaultGroupKey("group1SetBuckets".getBytes());
testSetBuckets(currKey, newKey);
// Testing addOrUpdateGroupEntry operation from southbound
currKey = newKey;
testUpdateGroupEntryFromSB(currKey);
// Testing deleteGroupDescription operation from northbound
testDeleteGroup(currKey);
// Testing removeGroupEntry operation from southbound
testRemoveGroupFromSB(currKey);
// Testing removing all groups on the given device by deviceid
newKey = new DefaultGroupKey("group1".getBytes());
testStoreAndGetGroup(newKey);
testDeleteGroupOnDevice(newKey);
// Testing removing all groups on the given device
newKey = new DefaultGroupKey("group1".getBytes());
testStoreAndGetGroup(newKey);
testPurgeGroupEntries();
}
Aggregations