Skip to content

Commit a1f7a91

Browse files
committed
Add LAG / Port dependency test
1 parent 03f7551 commit a1f7a91

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

tests/test_port_dpb_lag.py

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import time
2+
import pytest
3+
from port_dpb import Port
4+
from port_dpb import DPB
5+
6+
@pytest.mark.usefixtures('dpb_setup_fixture')
7+
@pytest.mark.usefixtures('dvs_lag_manager')
8+
class TestPortDPBLag(object):
9+
def check_syslog(self, dvs, marker, log, expected_cnt):
10+
(exitcode, num) = dvs.runcmd(['sh', '-c', "awk \'/%s/,ENDFILE {print;}\' /var/log/syslog | grep \"%s\" | wc -l" % (marker, log)])
11+
assert num.strip() >= str(expected_cnt)
12+
13+
def test_dependency(self, dvs):
14+
lag = "0001"
15+
p = Port(dvs, "Ethernet0")
16+
p.sync_from_config_db()
17+
18+
# 1. Create PortChannel0001
19+
self.dvs_lag.create_port_channel(lag)
20+
21+
# 2. Add Ethernet0 to PortChannel0001
22+
self.dvs_lag.create_port_channel_member(lag, p.get_name())
23+
24+
# 3. Add log marker to syslog
25+
marker = dvs.add_log_marker()
26+
27+
# 4. Delete Ethernet0 from config DB. Sleep for 2 seconds.
28+
p.delete_from_config_db()
29+
time.sleep(2)
30+
31+
# 5. Verify that we are waiting in portsorch for the port
32+
# to be removed from LAG, by looking at the log
33+
self.check_syslog(dvs, marker, "Unable to remove port Ethernet0: ref count 1", 1)
34+
35+
# 6. Also verify that port is still present in ASIC DB.
36+
assert(p.exists_in_asic_db() == True)
37+
38+
# 7. Remove port from LAG
39+
self.dvs_lag.remove_port_channel_member(lag, p.get_name())
40+
41+
# 8. Verify that port is removed from ASIC DB
42+
assert(p.not_exists_in_asic_db() == True)
43+
44+
# 9. Re-create port Ethernet0 and verify that it is
45+
# present in CONFIG, APPL, and ASIC DBs
46+
p.write_to_config_db()
47+
p.verify_config_db()
48+
p.verify_app_db()
49+
p.verify_asic_db()
50+
51+
# 10. Remove PortChannel0001 and verify that its removed.
52+
self.dvs_lag.remove_port_channel(lag)
53+
self.dvs_lag.get_and_verify_port_channel(0)
54+
55+
56+
# Add Dummy always-pass test at end as workaroud
57+
# for issue when Flaky fail on final test it invokes module tear-down before retrying
58+
def test_nonflaky_dummy():
59+
pass

0 commit comments

Comments
 (0)