""" | |
Group table test | |
Verify each group table can created correctly | |
""" | |
from oftest import config | |
import logging | |
import random | |
from oftest import config | |
import oftest | |
import oftest.base_tests as base_tests | |
import ofp | |
from oftest.testutils import * | |
from accton_util import * | |
def getkey(type): | |
def byGroupId(stats_entry): | |
return stats_entry.group_id | |
def byGroupType(stats_entry): | |
return stats_entry.group_type | |
if type == "group_id": | |
return byGroupId | |
elif type == "group_type": | |
return byGroupType | |
return byGroupId | |
class L2InterfaceGroupOne(base_tests.SimpleDataPlane): | |
def runTest(self): | |
delete_all_flows(self.controller) | |
delete_all_groups(self.controller) | |
group_list1, msg1 = add_one_l2_interface_grouop(self.controller, config["port_map"].keys()[0], 1, False, False) | |
stats = get_stats(self, ofp.message.group_desc_stats_request()) | |
verify_group_stats=[ofp.group_desc_stats_entry( | |
group_type=msg1.group_type, | |
group_id=msg1.group_id, | |
buckets=msg1.buckets)] | |
self.maxDiff=None | |
self.assertEquals(stats, verify_group_stats) | |
class L2InterfaceGroup(base_tests.SimpleDataPlane): | |
def runTest(self): | |
delete_all_flows(self.controller) | |
delete_all_groups(self.controller) | |
group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False) | |
group_list2, msg2 =add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False) | |
stats = get_stats(self, ofp.message.group_desc_stats_request()) | |
verify_group_stats=[] | |
for msg in msg1: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets)) | |
for msg in msg2: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets)) | |
verify_group_stats=sorted(verify_group_stats, key=getkey("group_id")) | |
stats=sorted(stats, key=getkey("group_id")) | |
#self.maxDiff=None | |
self.assertEquals(stats, verify_group_stats) | |
class L2McastGroup(base_tests.SimpleDataPlane): | |
def runTest(self): | |
delete_all_flows(self.controller) | |
delete_all_groups(self.controller) | |
group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False) | |
msg2=add_l2_mcast_group(self.controller, config["port_map"].keys(), 1, 1) | |
group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False) | |
msg4=add_l2_mcast_group(self.controller, config["port_map"].keys(), 2, 2) | |
stats = get_stats(self, ofp.message.group_desc_stats_request()) | |
verify_group_stats=[] | |
for msg in msg1: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg2.group_type, | |
group_id=msg2.group_id, | |
buckets=msg2.buckets) | |
) | |
for msg in msg3: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg4.group_type, | |
group_id=msg4.group_id, | |
buckets=msg4.buckets) | |
) | |
verify_group_stats=sorted(verify_group_stats, key=getkey("group_id")) | |
stats=sorted(stats, key=getkey("group_id")) | |
self.maxDiff=None | |
self.assertEquals(stats, verify_group_stats) | |
class L2FloodGroup(base_tests.SimpleDataPlane): | |
def runTest(self): | |
delete_all_flows(self.controller) | |
delete_all_groups(self.controller) | |
group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False) | |
msg2=add_l2_flood_group(self.controller, config["port_map"].keys(), 1, 1) | |
group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False) | |
msg4=add_l2_flood_group(self.controller, config["port_map"].keys(), 2, 2) | |
stats = get_stats(self, ofp.message.group_desc_stats_request()) | |
verify_group_stats=[] | |
for msg in msg1: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg2.group_type, | |
group_id=msg2.group_id, | |
buckets=msg2.buckets) | |
) | |
for msg in msg3: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg4.group_type, | |
group_id=msg4.group_id, | |
buckets=msg4.buckets) | |
) | |
verify_group_stats=sorted(verify_group_stats, key=getkey("group_id")) | |
stats=sorted(stats, key=getkey("group_id")) | |
self.maxDiff=None | |
self.assertEquals(stats, verify_group_stats) | |
class L2RewriteGroup(base_tests.SimpleDataPlane): | |
def runTest(self): | |
delete_all_flows(self.controller) | |
delete_all_groups(self.controller) | |
group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False) | |
msg2=add_l2_rewrite_group(self.controller, config["port_map"].keys()[0], 1, 1, [00,11,22,33,44,55], [00,22,22,22,22,22]) | |
group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False) | |
msg4=add_l2_rewrite_group(self.controller, config["port_map"].keys()[0], 2, 2, [00,11,22,33,44,55], [00,33,33,33,33,33]) | |
stats = get_stats(self, ofp.message.group_desc_stats_request()) | |
verify_group_stats=[] | |
for msg in msg1: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg2.group_type, | |
group_id=msg2.group_id, | |
buckets=msg2.buckets) | |
) | |
for msg in msg3: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg4.group_type, | |
group_id=msg4.group_id, | |
buckets=msg4.buckets) | |
) | |
verify_group_stats=sorted(verify_group_stats, key=getkey("group_id")) | |
stats=sorted(stats, key=getkey("group_id")) | |
self.maxDiff=None | |
self.assertEquals(stats, verify_group_stats) | |
class L3UnicastGroup(base_tests.SimpleDataPlane): | |
def runTest(self): | |
delete_all_flows(self.controller) | |
delete_all_groups(self.controller) | |
group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False) | |
msg2=add_l3_unicast_group(self.controller, config["port_map"].keys()[0], 1, 1, [0x00,0x11,0x22,0x33,0x44,0x55], [00,0x22,0x22,0x22,0x22,0x22]) | |
group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False) | |
msg4=add_l3_unicast_group(self.controller, config["port_map"].keys()[0], 2, 2, [0x00,0x11,0x22,0x33,0x44,0x55], [00,0x33,0x33,0x33,0x33,0x33]) | |
stats = get_stats(self, ofp.message.group_desc_stats_request()) | |
verify_group_stats=[] | |
for msg in msg1: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg2.group_type, | |
group_id=msg2.group_id, | |
buckets=msg2.buckets) | |
) | |
for msg in msg3: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg4.group_type, | |
group_id=msg4.group_id, | |
buckets=msg4.buckets) | |
) | |
verify_group_stats=sorted(verify_group_stats, key=getkey("group_id")) | |
stats=sorted(stats, key=getkey("group_id")) | |
self.maxDiff=None | |
self.assertEquals(stats, verify_group_stats) | |
class L3ECMPGroup(base_tests.SimpleDataPlane): | |
def runTest(self): | |
delete_all_flows(self.controller) | |
delete_all_groups(self.controller) | |
group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False) | |
msg2=add_l3_unicast_group(self.controller, config["port_map"].keys()[0], 1, 1, [0x00,0x11,0x22,0x33,0x44,0x55], [00,0x22,0x22,0x22,0x22,0x22]) | |
group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False) | |
msg4=add_l3_unicast_group(self.controller, config["port_map"].keys()[0], 2, 2, [0x00,0x11,0x22,0x33,0x44,0x55], [00,0x33,0x33,0x33,0x33,0x33]) | |
group_ids=[msg2.group_id, msg4.group_id] | |
msg5=add_l3_ecmp_group(self.controller, 1, group_ids) | |
stats = get_stats(self, ofp.message.group_desc_stats_request()) | |
verify_group_stats=[] | |
for msg in msg1: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg2.group_type, | |
group_id=msg2.group_id, | |
buckets=msg2.buckets) | |
) | |
for msg in msg3: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg4.group_type, | |
group_id=msg4.group_id, | |
buckets=msg4.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg5.group_type, | |
group_id=msg5.group_id, | |
buckets=msg5.buckets) | |
) | |
verify_group_stats=sorted(verify_group_stats, key=getkey("group_id")) | |
stats=sorted(stats, key=getkey("group_id")) | |
self.maxDiff=None | |
self.assertEquals(stats, verify_group_stats) | |
class L3InterfaceGroup(base_tests.SimpleDataPlane): | |
def runTest(self): | |
delete_all_flows(self.controller) | |
delete_all_groups(self.controller) | |
group_list1, msg1 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False) | |
msg2=add_l3_interface_group(self.controller, config["port_map"].keys()[0], 1, 1, [0x00,0x11,0x22,0x33,0x44,0x55]) | |
group_list1, msg3 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 2, False, False) | |
msg4=add_l3_interface_group(self.controller, config["port_map"].keys()[0], 2, 2, [0x00,0x11,0x22,0x33,0x44,0x66]) | |
stats = get_stats(self, ofp.message.group_desc_stats_request()) | |
verify_group_stats=[] | |
for msg in msg1: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg2.group_type, | |
group_id=msg2.group_id, | |
buckets=msg2.buckets) | |
) | |
for msg in msg3: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg4.group_type, | |
group_id=msg4.group_id, | |
buckets=msg4.buckets) | |
) | |
verify_group_stats=sorted(verify_group_stats, key=getkey("group_id")) | |
stats=sorted(stats, key=getkey("group_id")) | |
self.maxDiff=None | |
self.assertEquals(stats, verify_group_stats) | |
class L3McastGroup(base_tests.SimpleDataPlane): | |
def runTest(self): | |
delete_all_flows(self.controller) | |
delete_all_groups(self.controller) | |
# Vlan 3 forward to vlan 3 port 1 and 2 | |
# Vlan 3 foward to vlan 1 port 1 | |
# Vlan 3 foward to vlan 2 port 1 | |
# Vlan 3 foward to vlan 2 port 2 | |
group_list1_1, msg1 = add_l2_interface_grouop(self.controller, [config["port_map"].keys()[0]], 1, False, False) | |
msg2=add_l3_interface_group(self.controller, config["port_map"].keys()[0], 1, 1, [0x00,0x11,0x22,0x33,0x44,0x11]) | |
group_list1_2, msg3 = add_l2_interface_grouop(self.controller, [config["port_map"].keys()[0]], 2, False, False) | |
msg4=add_l3_interface_group(self.controller, config["port_map"].keys()[0], 2, 2, [0x00,0x11,0x22,0x33,0x44,0x22]) | |
group_list2_1, msg5 = add_l2_interface_grouop(self.controller, [config["port_map"].keys()[1]], 2, False, False) | |
msg6=add_l3_interface_group(self.controller, config["port_map"].keys()[1], 2, 3, [0x00,0x11,0x22,0x33,0x44,0x33]) | |
group_list3, msg7 = add_l2_interface_grouop(self.controller, config["port_map"].keys(), 3, False, False) | |
group_actions=[msg2.group_id, msg4.group_id, msg6.group_id] | |
group_actions.extend(group_list3) | |
msg8=add_l3_mcast_group(self.controller, 3, 1, group_actions) | |
stats = get_stats(self, ofp.message.group_desc_stats_request()) | |
verify_group_stats=[] | |
for msg in msg1: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg2.group_type, | |
group_id=msg2.group_id, | |
buckets=msg2.buckets) | |
) | |
for msg in msg3: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg4.group_type, | |
group_id=msg4.group_id, | |
buckets=msg4.buckets) | |
) | |
for msg in msg5: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg6.group_type, | |
group_id=msg6.group_id, | |
buckets=msg6.buckets) | |
) | |
for msg in msg7: | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg.group_type, | |
group_id=msg.group_id, | |
buckets=msg.buckets) | |
) | |
verify_group_stats.append(ofp.group_desc_stats_entry( | |
group_type=msg8.group_type, | |
group_id=msg8.group_id, | |
buckets=msg8.buckets) | |
) | |
verify_group_stats=sorted(verify_group_stats, key=getkey("group_id")) | |
stats=sorted(stats, key=getkey("group_id")) | |
self.maxDiff=None | |
self.assertEquals(stats, verify_group_stats) | |