diff --git a/tests/conftest.py b/tests/conftest.py index 220beb6d55dc..6a2fe190cc40 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -79,15 +79,18 @@ def __init__(self, dvs): self.neighTbl = swsscommon.Table(appl_db, "NEIGH_TABLE") def __del__(self): - # Make sure no neighbors on vEthernet - keys = self.neighTbl.getKeys(); + # Make sure no neighbors on physical interfaces + keys = self.neighTbl.getKeys() for key in keys: - assert not key.startswith("vEthernet") + m = re.match("eth(\d+)", key) + if not m: + continue + assert int(m.group(1)) > 0 class VirtualServer(object): def __init__(self, ctn_name, pid, i): self.nsname = "%s-srv%d" % (ctn_name, i) - self.vifname = "vEthernet%d" % (i * 4) + self.pifname = "eth%d" % (i + 1) self.cleanup = True # create netns @@ -97,9 +100,9 @@ def __init__(self, ctn_name, pid, i): ensure_system("ip netns add %s" % self.nsname) # create vpeer link - ensure_system("ip link add %s type veth peer name %s" % (self.nsname[0:12], self.vifname)) + ensure_system("ip link add %s type veth peer name %s" % (self.nsname[0:12], self.pifname)) ensure_system("ip link set %s netns %s" % (self.nsname[0:12], self.nsname)) - ensure_system("ip link set %s netns %d" % (self.vifname, pid)) + ensure_system("ip link set %s netns %d" % (self.pifname, pid)) # bring up link in the virtual server ensure_system("ip netns exec %s ip link set dev %s name eth0" % (self.nsname, self.nsname[0:12])) @@ -107,11 +110,11 @@ def __init__(self, ctn_name, pid, i): ensure_system("ip netns exec %s ethtool -K eth0 tx off" % (self.nsname)) # bring up link in the virtual switch - ensure_system("nsenter -t %d -n ip link set dev %s up" % (pid, self.vifname)) + ensure_system("nsenter -t %d -n ip link set dev %s up" % (pid, self.pifname)) - # disable arp, so no neigh on vEthernet(s) - ensure_system("nsenter -t %d -n ip link set arp off dev %s" % (pid, self.vifname)) - ensure_system("nsenter -t %d -n sysctl -w net.ipv6.conf.%s.disable_ipv6=1" % (pid, self.vifname)) + # disable arp, so no neigh on physical interfaces + ensure_system("nsenter -t %d -n ip link set arp off dev %s" % (pid, self.pifname)) + ensure_system("nsenter -t %d -n sysctl -w net.ipv6.conf.%s.disable_ipv6=1" % (pid, self.pifname)) def destroy(self): if self.cleanup: @@ -188,6 +191,7 @@ def __init__(self, name=None, keeptb=False): self.mount = "/var/run/redis-vs/{}".format(ctn_sw_name) + self.net_cleanup() self.restart() else: self.ctn_sw = self.client.containers.run('debian:jessie', privileged=True, detach=True, @@ -216,7 +220,7 @@ def __init__(self, name=None, keeptb=False): # temp fix: remove them once they are moved to vs start.sh self.ctn.exec_run("sysctl -w net.ipv6.conf.default.disable_ipv6=0") for i in range(0, 128, 4): - self.ctn.exec_run("sysctl -w net.ipv6.conf.vEthernet%d.disable_ipv6=1" % i) + self.ctn.exec_run("sysctl -w net.ipv6.conf.eth%d.disable_ipv6=1" % (i + 1)) self.check_ready() self.init_asicdb_validator() self.appldb = ApplDbValidator(self) @@ -276,6 +280,29 @@ def check_ready(self, timeout=30): time.sleep(1) + def net_cleanup(self): + """clean up network, remove extra links""" + + re_space = re.compile('\s+') + + res = self.ctn.exec_run("ip link show") + try: + out = res.output + except AttributeError: + out = res + for l in out.split('\n'): + m = re.compile('^\d+').match(l) + if not m: + continue + fds = re_space.split(l) + if len(fds) > 1: + pname = fds[1].rstrip(":") + m = re.compile("(eth|lo|Bridge|Ethernet)").match(pname) + if not m: + self.ctn.exec_run("ip link del {}".format(pname)) + print "remove extra link {}".format(pname) + return + def restart(self): self.ctn.restart() diff --git a/tests/test_acl_portchannel.py b/tests/test_acl_portchannel.py index 4671267ba749..90cf2003aba5 100644 --- a/tests/test_acl_portchannel.py +++ b/tests/test_acl_portchannel.py @@ -134,6 +134,8 @@ def test_PortChannelAfterAcl(self, dvs): # create ACL table self.create_acl_table(dvs, "LAG_ACL_TABLE", "PortChannel01") + time.sleep(1) + # check ASIC table self.check_asic_table_existed(dvs) @@ -154,6 +156,8 @@ def test_PortChannelBeforeAcl(self, dvs): # create port channel self.create_port_channel(dvs, "PortChannel01") + time.sleep(1) + # check ASIC table self.check_asic_table_existed(dvs) @@ -179,6 +183,8 @@ def test_AclOnPortChannelMember(self, dvs): # create ACL table self.create_acl_table(dvs, "LAG_ACL_TABLE", "Ethernet0") + time.sleep(1) + # check ASIC table self.check_asic_table_absent(dvs) diff --git a/tests/test_admin_status.py b/tests/test_admin_status.py index 37f187c1d71b..73312a0b76ee 100644 --- a/tests/test_admin_status.py +++ b/tests/test_admin_status.py @@ -70,8 +70,8 @@ def test_PortChannelMemberAdminStatus(self, dvs, testlog): self.check_admin_status(dvs, "Ethernet8", "up") # remove port channel members - self.remove_port_channel_members(dvs, "PortCHannel6", + self.remove_port_channel_members(dvs, "PortChannel6", ["Ethernet0", "Ethernet4", "Ethernet8"]) # remove port channel - self.remove_port_channel(dvs, "PortCHannel6") + self.remove_port_channel(dvs, "PortChannel6") diff --git a/tests/test_speed.py b/tests/test_speed.py index 4425d7f3b620..f698aaec5b6b 100644 --- a/tests/test_speed.py +++ b/tests/test_speed.py @@ -28,16 +28,13 @@ def test_SpeedAndBufferSet(self, dvs, testlog): buffer_profiles = cfg_buffer_profile_table.getKeys() expected_buffer_profiles_num = len(buffer_profiles) - # buffers.json used for the test defines 7 static profiles: + # buffers.json used for the test defines 4 static profiles: # "ingress_lossless_profile" # "ingress_lossy_profile" # "egress_lossless_profile" # "egress_lossy_profile" - # "pg_lossy_profile" - # "q_lossless_profile" - # "q_lossy_profile" # check if they get the DB - assert expected_buffer_profiles_num == 7 + assert expected_buffer_profiles_num == 4 # and if they were successfully created on ASIC assert len(asic_profile_table.getKeys()) == expected_buffer_profiles_num