def test_port_breakout_simple(self, dvs, root_port, breakout_mode): dvs.setup_db() dpb = DPB() dvs.change_port_breakout_mode(root_port, breakout_mode) dpb.verify_port_breakout_mode(dvs, root_port, breakout_mode) expected_ports = dpb.get_child_ports(root_port, breakout_mode) self.verify_only_ports_exist(dvs, expected_ports)
def test_port_breakout_multiple(self, dvs): dpb = DPB() port_names = ["Ethernet0", "Ethernet12", "Ethernet64", "Ethernet112"] for pname in port_names: dpb.breakout(dvs, pname, maxBreakOut) dpb.breakin(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"]) dpb.breakin(dvs, ["Ethernet12", "Ethernet13", "Ethernet14", "Ethernet15"]) dpb.breakin(dvs, ["Ethernet64", "Ethernet65", "Ethernet66", "Ethernet67"]) dpb.breakin(dvs, ["Ethernet112", "Ethernet113", "Ethernet114", "Ethernet115"])
def test_port_breakout_with_acl(self, dvs, dvs_acl): dvs.setup_db() dpb = DPB() # Create ACL table "test" and bind it to Ethernet0 bind_ports = ["Ethernet0"] dvs_acl.create_acl_table("test", "L3", bind_ports) # Verify ACL table is created dvs_acl.verify_acl_table_count(1) # Verify that ACL group OID is created. # Just FYI: Usually one ACL group OID is created per port, # even when port is bound to multiple ACL tables dvs_acl.verify_acl_table_groups(1) # Verify that port is correctly bound to table by looking into # ACL member table, which binds ACL group OID of a port and # ACL table OID. acl_table_ids = dvs_acl.get_acl_table_ids(1) dvs_acl.verify_acl_table_port_binding(acl_table_ids[0], bind_ports, 1) # Verify current breakout mode, perform breakout without force dependency # delete option dpb.verify_port_breakout_mode(dvs, "Ethernet0", "1x100G[40G]") dvs.change_port_breakout_mode("Ethernet0", "4x25G[10G]") # Verify that breakout did NOT succeed dpb.verify_port_breakout_mode(dvs, "Ethernet0", "1x100G[40G]") # Do breakout with force option, and verify that it succeeds dvs.change_port_breakout_mode("Ethernet0", "4x25G[10G]", "-f") dpb.verify_port_breakout_mode(dvs, "Ethernet0", "4x25G[10G]") # Verify port is removed from ACL table dvs_acl.verify_acl_table_count(1) dvs_acl.verify_acl_table_groups(0) # Verify child ports are created. self.verify_only_ports_exist( dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"]) # Move back to 1x100G[40G] mode and verify current mode dvs.change_port_breakout_mode("Ethernet0", "1x100G[40G]", "-f") dpb.verify_port_breakout_mode(dvs, "Ethernet0", "1x100G[40G]") # Remove ACL table and verify the same dvs_acl.remove_acl_table("test") dvs_acl.verify_acl_table_count(0)
def test_dpb_arp_flush_on_vlan_member_remove(self, dvs): dvs.setup_db() dvs_asic_db = dvs.get_asic_db() dpb = DPB() self.clear_srv_config(dvs) vlanID = "100" portName = "Ethernet0" vlanName = "Vlan" + str(vlanID) vrfName = "" ipAddress = "10.0.0.0/31" srv0MAC = "00:00:00:00:01:11" self.dvs_vlan.create_vlan(vlanID) self.dvs_vlan.create_vlan_member(vlanID, portName) # bring up interface self.set_admin_status(dvs, portName, "up") self.set_admin_status(dvs, vlanName, "up") # create vlan interface rif_oid = self.create_l3_intf(dvs, vlanName, vrfName) # assign IP to interface self.add_ip_address(dvs, vlanName, ipAddress) # Set IP address and default route cmd = "ip link set eth0 address " + srv0MAC dvs.servers[0].runcmd(cmd) dvs.servers[0].runcmd("ip address add 10.0.0.1/31 dev eth0") dvs.servers[0].runcmd("ip route add default via 10.0.0.0") # Get neighbor and ARP entry dvs.servers[0].runcmd("ping -c 1 10.0.0.0") intf_entries = dvs_asic_db.wait_for_n_keys( "ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY", 1) route = json.loads(intf_entries[0]) assert route["ip"] == "10.0.0.1" assert route["rif"] == rif_oid dvs_asic_db.wait_for_exact_match("ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY", \ intf_entries[0], \ {"SAI_NEIGHBOR_ENTRY_ATTR_DST_MAC_ADDRESS":srv0MAC}) # Remove port from VLAN self.dvs_vlan.remove_vlan_member(vlanID, portName) #Verify ARP/Neighbor entry is removed dvs_asic_db.wait_for_deleted_entry("ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY", \ intf_entries[0], ARP_FLUSH_POLLING) # Remove IP from interface, and then remove interface self.remove_ip_address(dvs, vlanName, ipAddress) self.remove_l3_intf(dvs, vlanName) # Remove VLAN self.dvs_vlan.remove_vlan(vlanID)
def test_one_port_many_acl_tables(self, dvs, dvs_acl): # Create 4 ACL tables and bind them to Ethernet0 bind_ports = ["Ethernet0"] acl_tables = ["test1", "test2", "test3", "test4"] for acl_tbl in acl_tables: dvs_acl.create_acl_table(acl_tbl, "L3", bind_ports) dvs_acl.verify_acl_table_count(len(acl_tables)) dvs_acl.verify_acl_table_groups(len(bind_ports)) acl_table_ids = dvs_acl.get_acl_table_ids(len(acl_tables)) for acl_tbl_id in acl_table_ids: dvs_acl.verify_acl_table_port_binding(acl_tbl_id, bind_ports, len(acl_tables)) # Update bind list and verify bind_ports = [] for acl_tbl in acl_tables: dvs_acl.update_acl_table_port_list(acl_tbl, bind_ports) dvs_acl.verify_acl_table_groups(0) # Breakout Ethernet0 dpb = DPB() dpb.breakout(dvs, "Ethernet0", maxBreakout) # Breakin Ethernet0, 1, 2, 3 dpb.breakin(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"]) for acl_tbl in acl_tables: dvs_acl.remove_acl_table(acl_tbl)
def test_dpb_arp_flush(self, dvs): dvs.setup_db() dvs_asic_db = dvs.get_asic_db() dpb = DPB() portName = "Ethernet0" vrfName = "" ipAddress = "10.0.0.0/31" srv0MAC = "00:00:00:00:01:11" self.clear_srv_config(dvs) # Create l3 interface rif_oid = self.create_l3_intf(dvs, portName, vrfName) # set ip address self.add_ip_address(dvs, portName, ipAddress) # bring up interface self.set_admin_status(dvs, portName, "up") # Set IP address and default route cmd = "ip link set eth0 address " + srv0MAC dvs.servers[0].runcmd(cmd) dvs.servers[0].runcmd("ip address add 10.0.0.1/31 dev eth0") dvs.servers[0].runcmd("ip route add default via 10.0.0.0") # Get neighbor and ARP entry dvs.servers[0].runcmd("ping -c 3 10.0.0.0") intf_entries = dvs_asic_db.wait_for_n_keys( "ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY", 1) route = json.loads(intf_entries[0]) assert route["ip"] == "10.0.0.1" assert route["rif"] == rif_oid dvs_asic_db.wait_for_exact_match("ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY", \ intf_entries[0], \ {"SAI_NEIGHBOR_ENTRY_ATTR_DST_MAC_ADDRESS":srv0MAC}) # Breakout port and make sure NEIGHBOR entry is removed dpb.verify_port_breakout_mode(dvs, "Ethernet0", "1x100G[40G]") dvs.change_port_breakout_mode("Ethernet0", "4x25G[10G]", "-f") dpb.verify_port_breakout_mode(dvs, "Ethernet0", "4x25G[10G]") #Verify ARP/Neighbor entry is removed dvs_asic_db.wait_for_deleted_entry("ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY", \ intf_entries[0], ARP_FLUSH_POLLING) dvs.change_port_breakout_mode("Ethernet0", "1x100G[40G]") dpb.verify_port_breakout_mode(dvs, "Ethernet0", "1x100G[40G]")
def test_port_breakout_with_vlan(self, dvs): dvs.setup_db() dpb = DPB() portName = "Ethernet0" vlanID = "100" breakoutMode1 = "1x100G[40G]" breakoutMode2 = "4x25G[10G]" breakoutOption = "-f" #Force breakout by deleting dependencies # Create VLAN self.dvs_vlan.create_vlan(vlanID) # Verify VLAN is created self.dvs_vlan.get_and_verify_vlan_ids(1) # Add port to VLAN self.dvs_vlan.create_vlan_member(vlanID, portName) # Verify VLAN member is created self.dvs_vlan.get_and_verify_vlan_member_ids(1) # Breakout port from 1x100G[40G] --> 4x25G[10G] dpb.verify_port_breakout_mode(dvs, "Ethernet0", breakoutMode1) dvs.change_port_breakout_mode("Ethernet0", breakoutMode2, breakoutOption) # Verify DPB is successful dpb.verify_port_breakout_mode(dvs, "Ethernet0", breakoutMode2) # Verify port is removed from VLAN self.dvs_vlan.get_and_verify_vlan_member_ids(0) # Delete VLAN self.dvs_vlan.remove_vlan(vlanID) # Verify VLAN is deleted self.dvs_vlan.get_and_verify_vlan_ids(0) # Breakout port from 4x25G[10G] --> 1x100G[40G] dvs.change_port_breakout_mode("Ethernet0", breakoutMode1) # Verify DPB is successful dpb.verify_port_breakout_mode(dvs, "Ethernet0", breakoutMode1)
def test_many_ports_many_acl_tables(self, dvs): # Prepare ACL table names aclTableNames = [] for i in range(maxAclTables): aclTableNames.append("aclTable" + str(i+1)) # Prepare all port names portNames = [] for i in range(maxPorts): portNames.append("Ethernet" + str(i)) # Prepare root port names rootPortNames = [] for i in range(0, maxPorts, maxBreakout): rootPortNames.append("Ethernet" + str(i)) # Create ACL tables and bind root ports for aclTable in aclTableNames: self.dvs_acl.create_acl_table(aclTable, "L3", rootPortNames) self.dvs_acl.verify_acl_group_num(maxRootPorts) # Remove the dependency on all root ports by # unbinding them from all ACL tables. bind_ports = [] for aclTable in aclTableNames: self.dvs_acl.update_acl_table(aclTable, bind_ports) self.dvs_acl.verify_acl_group_num(0) # Breakout all root ports dpb = DPB() for pName in rootPortNames: #print "Breaking out %s"%pName dpb.breakout(dvs, pName, maxBreakout) # Add all ports to aclTable1 self.dvs_acl.update_acl_table(aclTableNames[0], portNames) self.dvs_acl.verify_acl_group_num(maxPorts) # Remove all ports from aclTable1 bind_ports = [] self.dvs_acl.update_acl_table(aclTableNames[0], bind_ports) self.dvs_acl.verify_acl_group_num(0) # Breakin all ports for i in range(0, maxPorts, maxBreakout): #print "Breaking in %s"%portNames[i:i+maxBreakout] dpb.breakin(dvs, portNames[i:i+maxBreakout]) for aclTable in aclTableNames: self.dvs_acl.remove_acl_table(aclTable) self.dvs_acl.verify_acl_table_count(0)
def test_one_acl_table_many_ports(self, dvs): # Create ACL table and bind it to Ethernet0 and Ethernet4 bind_ports = ["Ethernet0", "Ethernet4"] self.dvs_acl.create_acl_table("test", "L3", bind_ports) self.dvs_acl.verify_acl_table_count(1) self.dvs_acl.verify_acl_group_num(2) acl_table_ids = self.dvs_acl.get_acl_table_ids() self.dvs_acl.verify_acl_table_ports_binding(bind_ports, acl_table_ids[0]) # Update bind list and verify bind_ports = ["Ethernet4"] self.dvs_acl.update_acl_table("test", bind_ports) self.dvs_acl.verify_acl_group_num(1) acl_table_ids = self.dvs_acl.get_acl_table_ids() self.dvs_acl.verify_acl_table_ports_binding(bind_ports, acl_table_ids[0]) # Breakout Ethernet0 dpb = DPB() dpb.breakout(dvs, "Ethernet0", maxBreakout) time.sleep(2) #Update bind list and verify bind_ports = ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3","Ethernet4"] self.dvs_acl.update_acl_table("test", bind_ports) self.dvs_acl.verify_acl_group_num(5) self.dvs_acl.verify_acl_table_ports_binding(bind_ports, acl_table_ids[0]) # Update bind list and verify bind_ports = ["Ethernet4"] self.dvs_acl.update_acl_table("test", bind_ports) self.dvs_acl.verify_acl_group_num(1) self.dvs_acl.verify_acl_table_ports_binding(bind_ports, acl_table_ids[0]) #Breakin Ethernet0, 1, 2, 3 dpb.breakin(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"]) time.sleep(2) # Update bind list and verify bind_ports = ["Ethernet0", "Ethernet4"] self.dvs_acl.update_acl_table("test", bind_ports) self.dvs_acl.verify_acl_group_num(2) self.dvs_acl.verify_acl_table_ports_binding(bind_ports, acl_table_ids[0]) #Delete ACL table self.dvs_acl.remove_acl_table("test") self.dvs_acl.verify_acl_group_num(0)
def test_one_acl_table_many_ports(self, dvs, dvs_acl): # Create ACL table and bind it to Ethernet0 and Ethernet4 bind_ports = ["Ethernet0", "Ethernet4"] dvs_acl.create_acl_table("test", "L3", bind_ports) dvs_acl.verify_acl_table_count(1) dvs_acl.verify_acl_table_groups(2) acl_table_ids = dvs_acl.get_acl_table_ids(1) dvs_acl.verify_acl_table_port_binding(acl_table_ids[0], bind_ports, 1) # Update bind list and verify bind_ports = ["Ethernet4"] dvs_acl.update_acl_table_port_list("test", bind_ports) dvs_acl.verify_acl_table_groups(1) acl_table_ids = dvs_acl.get_acl_table_ids(1) dvs_acl.verify_acl_table_port_binding(acl_table_ids[0], bind_ports, 1) # Breakout Ethernet0 dpb = DPB() dpb.breakout(dvs, "Ethernet0", maxBreakout) # Update bind list and verify bind_ports = ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3", "Ethernet4"] dvs_acl.update_acl_table_port_list("test", bind_ports) dvs_acl.verify_acl_table_groups(5) dvs_acl.verify_acl_table_port_binding(acl_table_ids[0], bind_ports, 1) # Update bind list and verify bind_ports = ["Ethernet4"] dvs_acl.update_acl_table_port_list("test", bind_ports) dvs_acl.verify_acl_table_groups(1) dvs_acl.verify_acl_table_port_binding(acl_table_ids[0], bind_ports, 1) # Breakin Ethernet0, 1, 2, 3 dpb.breakin(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"]) # Update bind list and verify bind_ports = ["Ethernet0", "Ethernet4"] dvs_acl.update_acl_table_port_list("test", bind_ports) dvs_acl.verify_acl_table_groups(2) dvs_acl.verify_acl_table_port_binding(acl_table_ids[0], bind_ports, 1) # Delete ACL table dvs_acl.remove_acl_table("test") dvs_acl.verify_acl_table_groups(0)
def test_port_breakout_all(self, dvs): dpb = DPB() port_names = [] for i in range(32): pname = "Ethernet" + str(i*4) port_names.append(pname) for pname in port_names: dpb.breakout(dvs, pname, 4) child_port_names = [] for i in range(128): cpname = "Ethernet" + str(i) child_port_names.append(cpname) for i in range(32): start = i*4 end = start+4 dpb.breakin(dvs, child_port_names[start:end])
def test_port_breakout_all(self, dvs): dpb = DPB() port_names = [] for i in range(maxRootPorts): pname = "Ethernet" + str(i*maxBreakOut) port_names.append(pname) for pname in port_names: dpb.breakout(dvs, pname, maxBreakOut) child_port_names = [] for i in range(maxPorts): cpname = "Ethernet" + str(i) child_port_names.append(cpname) for i in range(32): start = i*maxBreakOut end = start+maxBreakOut dpb.breakin(dvs, child_port_names[start:end])
def test_cli_command_with_load_port_breakout_config_option( self, dvs, dvs_acl): dvs.setup_db() dpb = DPB() # Note below definitions are dependent on port_breakout_config_db.json # That is vlanIDs, aclTableNames are all should match with # VLANs and ACL tables in port_breakout_config_db.json portGroup = ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"] rootPortName = portGroup[0] vlanIDs = ["100", "101"] aclTableNames = ["DPB_ACL_TBL_1", "DPB_ACL_TBL_2"] breakoutMode1x = "1x100G[40G]" breakoutMode2x = "2x50G" breakoutMode4x = "4x25G[10G]" breakoutOption = "-l" # Lets create ACL and VLAN tables bind_ports = [] for aclTableName in aclTableNames: dvs_acl.create_acl_table(aclTableName, "L3", bind_ports) for vlanID in vlanIDs: self.dvs_vlan.create_vlan(vlanID) # Breakout port and expect that newly created ports are # automatically added to VLANs and ACL tables as per # port_breakout_config_db.json dvs_acl.verify_acl_table_groups(0) self.dvs_vlan.get_and_verify_vlan_member_ids(0) dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode1x) dvs.change_port_breakout_mode(rootPortName, breakoutMode4x, breakoutOption) dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode4x) dvs_acl.verify_acl_table_groups(len(portGroup)) self.dvs_vlan.get_and_verify_vlan_member_ids(len(portGroup)) # Breakout port and expect that root port remains in VLAN and ACL tables dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode4x) dvs.change_port_breakout_mode(rootPortName, breakoutMode1x, breakoutOption + " -f") dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode1x) dvs_acl.verify_acl_table_groups(1) self.dvs_vlan.get_and_verify_vlan_member_ids(1) # Breakout port with "-f" and WITHOUT "-l" and expect that # breakout succeeds and root port gets removed from # VLAN and ACL table dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode1x) dvs.change_port_breakout_mode(rootPortName, breakoutMode4x, "-f") dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode4x) dvs_acl.verify_acl_table_groups(0) self.dvs_vlan.get_and_verify_vlan_member_ids(0) #-------------------------------------------------------------------- # Exercise port group spanned across different VLAN and ACl table | #-------------------------------------------------------------------- portGroup = ["Ethernet4", "Ethernet5", "Ethernet6", "Ethernet7"] rootPortName = portGroup[0] breakoutMode2x = "2x50G" # Breakout port and expect that newly created ports are # automatically added to VLANs and ACL tables as per # port_breakout_config_db.json dvs_acl.verify_acl_table_groups(0) self.dvs_vlan.get_and_verify_vlan_member_ids(0) dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode1x) dvs.change_port_breakout_mode(rootPortName, breakoutMode4x, breakoutOption) dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode4x) dvs_acl.verify_acl_table_groups(len(portGroup)) self.dvs_vlan.get_and_verify_vlan_member_ids(len(portGroup)) # Breakout port and expect that Ethernet4 and Ethernet6 remain in # ACL and VLAN where as Ethernet5 and Ethernet7 get removed from # ACL and VLAN table dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode4x) dvs.change_port_breakout_mode(rootPortName, breakoutMode2x, breakoutOption + " -f") dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode2x) dvs_acl.verify_acl_table_groups(2) self.dvs_vlan.get_and_verify_vlan_member_ids(2) # Breakout again and verify that only root port (Ethernet4) remains in # in VLAN and ACL and Ethernet6 gets removed. dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode2x) dvs.change_port_breakout_mode(rootPortName, breakoutMode1x, breakoutOption + " -f") dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode1x) dvs_acl.verify_acl_table_groups(1) self.dvs_vlan.get_and_verify_vlan_member_ids(1) # Breakout port without "-l" option and ensure that root port # gets removed from VLAN and ACL dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode1x) dvs.change_port_breakout_mode(rootPortName, breakoutMode2x, "-f") dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode2x) dvs_acl.verify_acl_table_groups(0) self.dvs_vlan.get_and_verify_vlan_member_ids(0) #Cleanup # Move both Ethernet0 and Ethernet4 back to default mode dvs.change_port_breakout_mode("Ethernet0", breakoutMode1x) dpb.verify_port_breakout_mode(dvs, "Ethernet0", breakoutMode1x) dvs.change_port_breakout_mode("Ethernet4", breakoutMode1x) dpb.verify_port_breakout_mode(dvs, "Ethernet4", breakoutMode1x) # Delete VLANs and ACL tables bind_ports = [] for aclTableName in aclTableNames: dvs_acl.remove_acl_table(aclTableName) for vlanID in vlanIDs: self.dvs_vlan.remove_vlan(vlanID) # Verify cleanup dvs_acl.verify_acl_table_count(0) self.dvs_vlan.get_and_verify_vlan_ids(0) ##### Interface dependency test ############ # check ASIC router interface database # one loopback router interface dvs.get_asic_db().wait_for_n_keys( "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 1) # Breakout Ethernet8 WITH "-l" option and ensure # ip address gets configured as per port_breakout_config_db.json dpb.verify_port_breakout_mode(dvs, "Ethernet8", breakoutMode1x) dvs.change_port_breakout_mode("Ethernet8", breakoutMode2x, breakoutOption) dpb.verify_port_breakout_mode(dvs, "Ethernet8", breakoutMode2x) # one loopback router interface and one port based router interface dvs.get_asic_db().wait_for_n_keys( "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 2) def _check_route_present(): routes = dvs.get_asic_db().get_keys( "ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY") subnet_found = False ip2me_found = False for route in routes: rt = json.loads(route) if rt["dest"] == Ethernet8_IP: subnet_found = True if rt["dest"] == Ethernet8_IPME: ip2me_found = True return ((subnet_found and ip2me_found), routes) # check ASIC route database status, result = wait_for_result(_check_route_present, ROUTE_CHECK_POLLING) assert status == True # Breakout Ethernet8 WITH "-f" option and ensure cleanup happened dpb.verify_port_breakout_mode(dvs, "Ethernet8", breakoutMode2x) dvs.change_port_breakout_mode("Ethernet8", breakoutMode1x, "-f") dpb.verify_port_breakout_mode(dvs, "Ethernet8", breakoutMode1x) # check ASIC router interface database # one loopback router interface dvs.get_asic_db().wait_for_n_keys( "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 1) def _check_route_absent(): routes = dvs.get_asic_db().get_keys( "ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY") for route in routes: rt = json.loads(route) if rt["dest"] == Ethernet8_IP or \ rt["dest"] == Ethernet8_IPME: return (False, route) return (True, routes) # check ASIC database status, result = wait_for_result(_check_route_absent, ROUTE_CHECK_POLLING) assert status == True
def test_cli_command_with_force_option(self, dvs, dvs_acl): dvs.setup_db() dpb = DPB() portGroup = ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"] rootPortName = portGroup[0] vlanID = "100" aclTableName = "DPB_ACL_TBL_1" breakoutMode1x = "1x100G[40G]" breakoutMode2x = "2x50G" breakoutMode4x = "4x25G[10G]" breakoutOption = "-f" #Force breakout by deleting dependencies # Breakout port with no dependency using "-f" option dvs.change_port_breakout_mode(rootPortName, breakoutMode4x, breakoutOption) dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode4x) dvs.change_port_breakout_mode(rootPortName, breakoutMode1x, breakoutOption) dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode1x) # Breakout port with VLAN and ACL dependency # Create ACL table and bind port dvs_acl.verify_acl_table_groups(0) bind_ports = [] bind_ports.append(rootPortName) dvs_acl.create_acl_table(aclTableName, "L3", bind_ports) dvs_acl.verify_acl_table_groups(1) # Create VLAN and add port to VLAN self.dvs_vlan.create_vlan(vlanID) self.dvs_vlan.create_vlan_member(vlanID, rootPortName) self.dvs_vlan.get_and_verify_vlan_member_ids(1) # Breakout port and make sure it succeeds and associations are removed dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode1x) dvs.change_port_breakout_mode(rootPortName, breakoutMode4x, breakoutOption) dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode4x) dvs_acl.verify_acl_table_groups(0) self.dvs_vlan.get_and_verify_vlan_member_ids(0) # Add all ports to ACL and VLAN tables dvs_acl.update_acl_table_port_list(aclTableName, portGroup) for p in portGroup: self.dvs_vlan.create_vlan_member(vlanID, p) dvs_acl.verify_acl_table_groups(len(portGroup)) self.dvs_vlan.get_and_verify_vlan_member_ids(len(portGroup)) # Breakout with "-f" option and ensure it succeeds and associations are removed dvs.change_port_breakout_mode(rootPortName, breakoutMode1x, breakoutOption) dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode1x) dvs_acl.verify_acl_table_groups(0) self.dvs_vlan.get_and_verify_vlan_member_ids(0) # Cleanup # Remove ACL and VLAN tables dvs_acl.remove_acl_table(aclTableName) self.dvs_vlan.remove_vlan(vlanID) # Verify cleanup dvs_acl.verify_acl_table_count(0) self.dvs_vlan.get_and_verify_vlan_ids(0) # check ASIC router interface database # one loopback router interface dvs.get_asic_db().wait_for_n_keys( "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 1) # Bring up port self.set_admin_status(dvs, "Ethernet8", "up") # Create L3 interface self.create_l3_intf(dvs, "Ethernet8", "") # Configure IPv4 address on Ethernet8 self.add_ip_address(dvs, "Ethernet8", Ethernet8_IP) # one loopback router interface and one port based router interface dvs.get_asic_db().wait_for_n_keys( "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 2) def _check_route_present(): routes = dvs.get_asic_db().get_keys( "ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY") subnet_found = False ip2me_found = False for route in routes: rt = json.loads(route) if rt["dest"] == Ethernet8_IP: subnet_found = True if rt["dest"] == Ethernet8_IPME: ip2me_found = True return ((subnet_found and ip2me_found), routes) # check ASIC route database status, result = wait_for_result(_check_route_present, ROUTE_CHECK_POLLING) assert status == True # Breakout Ethernet8 WITH "-f" option and ensure cleanup happened dpb.verify_port_breakout_mode(dvs, "Ethernet8", breakoutMode1x) dvs.change_port_breakout_mode("Ethernet8", breakoutMode2x, breakoutOption) dpb.verify_port_breakout_mode(dvs, "Ethernet8", breakoutMode2x) # check ASIC router interface database # one loopback router interface dvs.get_asic_db().wait_for_n_keys( "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE", 1) def _check_route_absent(): routes = dvs.get_asic_db().get_keys( "ASIC_STATE:SAI_OBJECT_TYPE_ROUTE_ENTRY") for route in routes: rt = json.loads(route) if rt["dest"] == Ethernet8_IP or \ rt["dest"] == Ethernet8_IPME: return (False, route) return (True, routes) # check ASIC database status, result = wait_for_result(_check_route_absent, ROUTE_CHECK_POLLING) assert status == True dpb.verify_port_breakout_mode(dvs, "Ethernet8", breakoutMode2x) dvs.change_port_breakout_mode("Ethernet8", breakoutMode1x) dpb.verify_port_breakout_mode(dvs, "Ethernet8", breakoutMode1x)
def test_port_breakout_one(self, dvs): dpb = DPB() dpb.breakout(dvs, "Ethernet0", maxBreakOut) #print "**** 1X40G --> 4X10G passed ****" dpb.change_speed_and_verify(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"], speed25G) #print "**** 4X10G --> 4X25G passed ****" dpb.change_speed_and_verify(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"], speed10G) #print "**** 4X25G --> 4X10G passed ****" dpb.breakin(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"]) #print "**** 4X10G --> 1X40G passed ****" dpb.change_speed_and_verify(dvs, ["Ethernet0"], speed100G) #print "**** 1X40G --> 1X100G passed ****" dpb.breakout(dvs, "Ethernet0", maxBreakOut) #print "**** 1X100G --> 4X25G passed ****" dpb.change_speed_and_verify(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"], speed10G) #print "**** 4X25G --> 4X10G passed ****" dpb.change_speed_and_verify(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"], speed25G) #print "**** 4X10G --> 4X25G passed ****" dpb.breakin(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"]) #print "**** 4X25G --> 1X100G passed ****" dpb.breakout(dvs, "Ethernet0", maxBreakOut/2) #print "**** 1X100G --> 2X50G passed ****" dpb.breakin(dvs, ["Ethernet0", "Ethernet2"]) #print "**** 2X50G --> 1X100G passed ****" dpb.change_speed_and_verify(dvs, ["Ethernet0"], speed40G)
def test_one_port_one_vlan(self, dvs): dpb = DPB() vlan = "100" # 1. Create VLAN100 and add Ethernet0 as member self.dvs_vlan.create_vlan(vlan) self.dvs_vlan.create_vlan_member(vlan, "Ethernet0") self.dvs_vlan.get_and_verify_vlan_member_ids(1) # 2. Delete Ethernet0 from config DB. Verify that its deleted # CONFIG and APPL DB and its still present in ASIC DB p = Port(dvs, "Ethernet0") p.sync_from_config_db() p.delete_from_config_db() assert (p.exists_in_config_db() == False) assert (p.exists_in_app_db() == False) assert (p.exists_in_asic_db() == True) # 3. Verify that Ethernet0 gets deleted from ASIC DB once # its removed from VLAN100. self.dvs_vlan.remove_vlan_member(vlan, "Ethernet0") self.dvs_vlan.get_and_verify_vlan_member_ids(0) assert (p.not_exists_in_asic_db() == True) # 4. To simulate port breakout, 1x100G --> 4x25G, create 4 ports dpb.create_child_ports(dvs, p, 4) # 5. Add all 4 ports to VLAN100 port_names = ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"] vlan_member_count = 0 for pname in port_names: self.dvs_vlan.create_vlan_member(vlan, pname) vlan_member_count = vlan_member_count + 1 self.dvs_vlan.get_and_verify_vlan_member_ids(vlan_member_count) # 6. Delete 4 ports from CONFIG DB. Verify that they are all deleted # from CONFIG and APPL DB but still present in ASIC DB child_ports = [] for pname in port_names: cp = Port(dvs, pname) cp.sync_from_config_db() cp.delete_from_config_db() assert (cp.exists_in_config_db() == False) assert (cp.exists_in_app_db() == False) assert (cp.exists_in_asic_db() == True) child_ports.append(cp) # 7. Remove all 4 ports from VLAN100 and verify that they all get # deleted from ASIC DB for cp in child_ports: self.dvs_vlan.remove_vlan_member(vlan, cp.get_name()) vlan_member_count = vlan_member_count - 1 self.dvs_vlan.get_and_verify_vlan_member_ids(vlan_member_count) assert (cp.not_exists_in_asic_db() == True) # 8. Re-create Ethernet0 and verify that its created all 3 DBs p.write_to_config_db() p.verify_config_db() p.verify_app_db() p.verify_asic_db() # 9. Remove VLAN100 and verify the same self.dvs_vlan.remove_vlan(vlan) self.dvs_vlan.get_and_verify_vlan_ids(0)
def test_one_port_multiple_vlan(self, dvs): dpb = DPB() vlans = ["100", "101", "102"] # 1. Create 3 VLANs for vlan in vlans: self.dvs_vlan.create_vlan(vlan) # 2. Add Ethernet0 to all 3 VLANs and verify for vlan in vlans: self.dvs_vlan.create_vlan_member(vlan, "Ethernet0") self.dvs_vlan.get_and_verify_vlan_member_ids(len(vlans)) # 3. Delete Ethernet0 from CONFIG DB. Verify that it is deleted # from CONFIG and APPl DB, whereas still present in ASIC DB. p = Port(dvs, "Ethernet0") p.sync_from_config_db() p.delete_from_config_db() assert (p.exists_in_config_db() == False) assert (p.exists_in_app_db() == False) assert (p.exists_in_asic_db() == True) # 4. Remove Ethernet0 from one of the VLANs and verify that # its still present in ASIC DB self.dvs_vlan.remove_vlan_member(vlans[0], "Ethernet0") self.dvs_vlan.get_and_verify_vlan_member_ids(len(vlans) - 1) assert (p.exists_in_asic_db() == True) # 5. Remove Ethernet0 from one more VLAN and verify that # its still present in ASIC DB self.dvs_vlan.remove_vlan_member(vlans[1], "Ethernet0") self.dvs_vlan.get_and_verify_vlan_member_ids(len(vlans) - 2) assert (p.exists_in_asic_db() == True) # 6. Remove Ethernet0 from last VLAN as well and verify that # its deleted from ASIC DB self.dvs_vlan.remove_vlan_member(vlans[2], "Ethernet0") self.dvs_vlan.get_and_verify_vlan_member_ids(0) assert (p.not_exists_in_asic_db() == True) # 7. To Simulate 1x40G --> 4x10G, create 4 ports dpb.create_child_ports(dvs, p, 4) # 8. To Simulate 4x10G --> 1x40G, delete all 4 ports and re-create Ethernet0 port_names = ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"] for pname in port_names: cp = Port(dvs, pname) cp.sync_from_config_db() cp.delete_from_config_db() assert (cp.exists_in_config_db() == False) assert (cp.exists_in_app_db() == False) assert (cp.not_exists_in_asic_db() == True) p.write_to_config_db() p.verify_config_db() p.verify_app_db() p.verify_asic_db() # 9. Remove all 3 VLANs and verify the same self.dvs_vlan.remove_vlan("100") self.dvs_vlan.remove_vlan("101") self.dvs_vlan.remove_vlan("102") self.dvs_vlan.get_and_verify_vlan_ids(0)
def test_port_breakout_one(self, dvs): dpb = DPB() dpb.breakout(dvs, "Ethernet0", 4) #print "**** 1X40G --> 4X10G passed ****" dpb.change_speed_and_verify(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"], 25000) #print "**** 4X10G --> 4X25G passed ****" dpb.change_speed_and_verify(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"], 10000) #print "**** 4X25G --> 4X10G passed ****" dpb.breakin(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"]) #print "**** 4X10G --> 1X40G passed ****" dpb.change_speed_and_verify(dvs, ["Ethernet0"], 100000) #print "**** 1X40G --> 1X100G passed ****" dpb.breakout(dvs, "Ethernet0", 4) #print "**** 1X100G --> 4X25G passed ****" dpb.change_speed_and_verify(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"], 10000) #print "**** 4X25G --> 4X10G passed ****" dpb.change_speed_and_verify(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"], 25000) #print "**** 4X10G --> 4X25G passed ****" dpb.breakin(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"]) #print "**** 4X25G --> 1X100G passed ****" dpb.breakout(dvs, "Ethernet0", 2) #print "**** 1X100G --> 2X50G passed ****" dpb.breakin(dvs, ["Ethernet0", "Ethernet2"]) #print "**** 2X50G --> 1X100G passed ****" dpb.change_speed_and_verify(dvs, ["Ethernet0"], 40000)
def test_cli_command_negative(self, dvs, dvs_acl): dvs.setup_db() dpb = DPB() portGroup = ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"] rootPortName = portGroup[0] vlanIDs = ["100", "101"] aclTableNames = ["DPB_ACL_TBL_1", "DPB_ACL_TBL_2"] breakoutMode1x = "1x100G[40G]" breakoutMode4x = "4x25G[10G]" # Create only one ACL table and one VLAN table bind_ports = [] dvs_acl.create_acl_table(aclTableNames[0], "L3", bind_ports) self.dvs_vlan.create_vlan(vlanIDs[0]) # Add root port to ACL and VLAN tables bind_ports = [] bind_ports.append(rootPortName) dvs_acl.update_acl_table_port_list(aclTableNames[0], bind_ports) self.dvs_vlan.create_vlan_member(vlanIDs[0], rootPortName) # Breakout port WITHOUT "-f" option when dependencies exist # TBD: Verify the list of dependencies returned by CLI command dvs_acl.verify_acl_table_groups(1) self.dvs_vlan.get_and_verify_vlan_member_ids(1) dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode1x) dvs.change_port_breakout_mode(rootPortName, breakoutMode4x) dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode1x) dvs_acl.verify_acl_table_groups(1) self.dvs_vlan.get_and_verify_vlan_member_ids(1) # Breakout port WITH "-f" option, and WITHOUT "-l" option dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode1x) dvs.change_port_breakout_mode(rootPortName, breakoutMode4x, "-f") dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode4x) dvs_acl.verify_acl_table_groups(0) self.dvs_vlan.get_and_verify_vlan_member_ids(0) # Delete VLAN table, ensure breakout WITH "-l" fails self.dvs_vlan.remove_vlan(vlanIDs[0]) self.dvs_vlan.get_and_verify_vlan_ids(0) dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode4x) dvs.change_port_breakout_mode(rootPortName, breakoutMode1x, "-l") dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode4x) dvs_acl.verify_acl_table_groups(0) self.dvs_vlan.get_and_verify_vlan_member_ids(0) # Delete ACL table, Add back VLAN table and # ensure breakout WITH "-l" fails dvs_acl.remove_acl_table(aclTableNames[0]) dvs_acl.verify_acl_table_count(0) self.dvs_vlan.create_vlan(vlanIDs[0]) dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode4x) dvs.change_port_breakout_mode(rootPortName, breakoutMode1x, "-l") dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode4x) dvs_acl.verify_acl_table_groups(0) self.dvs_vlan.get_and_verify_vlan_member_ids(0) # Create both ACL tables (as per port_breakout_config_db.json, # Ethernet0 is in both ACL tables and one VLAN table) # and ensure, breakout succeeds bind_ports = [] dvs_acl.create_acl_table(aclTableNames[0], "L3", bind_ports) dvs_acl.create_acl_table(aclTableNames[1], "L3", bind_ports) dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode4x) dvs.change_port_breakout_mode(rootPortName, breakoutMode1x, "-l") dpb.verify_port_breakout_mode(dvs, rootPortName, breakoutMode1x) dvs_acl.verify_acl_table_groups(1) self.dvs_vlan.get_and_verify_vlan_member_ids(1) # Delete ACL and VLAN tables self.dvs_vlan.remove_vlan_member(vlanIDs[0], rootPortName) self.dvs_vlan.remove_vlan(vlanIDs[0]) dvs_acl.remove_acl_table(aclTableNames[0]) dvs_acl.remove_acl_table(aclTableNames[1]) # TBD: Provide "-l" option without port_breakout_config_db.json file # Verify cleanup dvs_acl.verify_acl_table_count(0) self.dvs_vlan.get_and_verify_vlan_ids(0)
def test_one_acl_table_many_ports(self, dvs): dvs.setup_db() # Create ACL table and bind it to Ethernet0 and Ethernet4 bind_ports = ["Ethernet0", "Ethernet4"] dvs.create_acl_table("test", "L3", bind_ports) time.sleep(2) acl_table_ids = dvs.get_acl_table_ids() assert len(acl_table_ids) == 1 dvs.verify_acl_group_num(2) acl_group_ids = dvs.get_acl_group_ids() dvs.verify_acl_group_member(acl_group_ids[0], acl_table_ids[0]) dvs.verify_acl_group_member(acl_group_ids[1], acl_table_ids[0]) dvs.verify_acl_port_binding(bind_ports) # Update bind list and verify bind_ports = ["Ethernet4"] fvs = swsscommon.FieldValuePairs([("ports", ",".join(bind_ports))]) dvs.update_acl_table("test", fvs) time.sleep(2) dvs.verify_acl_group_num(1) acl_group_ids = dvs.get_acl_group_ids() dvs.verify_acl_group_member(acl_group_ids[0], acl_table_ids[0]) dvs.verify_acl_port_binding(bind_ports) # Breakout Ethernet0 dpb = DPB() dpb.breakout(dvs, "Ethernet0", 4) time.sleep(2) #Update bind list and verify bind_ports = ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3","Ethernet4"] fvs = swsscommon.FieldValuePairs([("ports", ",".join(bind_ports))]) dvs.update_acl_table("test", fvs) time.sleep(2) dvs.verify_acl_group_num(5) acl_group_ids = dvs.get_acl_group_ids() dvs.verify_acl_group_member(acl_group_ids[0], acl_table_ids[0]) dvs.verify_acl_group_member(acl_group_ids[1], acl_table_ids[0]) dvs.verify_acl_group_member(acl_group_ids[2], acl_table_ids[0]) dvs.verify_acl_group_member(acl_group_ids[3], acl_table_ids[0]) dvs.verify_acl_group_member(acl_group_ids[4], acl_table_ids[0]) dvs.verify_acl_port_binding(bind_ports) time.sleep(2) # Update bind list and verify bind_ports = ["Ethernet4"] fvs = swsscommon.FieldValuePairs([("ports", ",".join(bind_ports))]) dvs.update_acl_table("test", fvs) dvs.verify_acl_group_num(1) acl_group_ids = dvs.get_acl_group_ids() dvs.verify_acl_group_member(acl_group_ids[0], acl_table_ids[0]) dvs.verify_acl_port_binding(bind_ports) #Breakin Ethernet0, 1, 2, 3 dpb.breakin(dvs, ["Ethernet0", "Ethernet1", "Ethernet2", "Ethernet3"]) time.sleep(2) # Update bind list and verify bind_ports = ["Ethernet0", "Ethernet4"] fvs = swsscommon.FieldValuePairs([("ports", ",".join(bind_ports))]) dvs.update_acl_table("test", fvs) time.sleep(2) dvs.verify_acl_group_num(2) acl_group_ids = dvs.get_acl_group_ids() dvs.verify_acl_group_member(acl_group_ids[0], acl_table_ids[0]) dvs.verify_acl_group_member(acl_group_ids[1], acl_table_ids[0]) dvs.verify_acl_port_binding(bind_ports) #Delete ACL table dvs.remove_acl_table("test") time.sleep(2) dvs.verify_acl_group_num(0)