|
| 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 | + time.sleep(2) |
| 24 | + |
| 25 | + # 3. Add log marker to syslog |
| 26 | + marker = dvs.add_log_marker() |
| 27 | + |
| 28 | + # 4. Delete Ethernet0 from config DB. |
| 29 | + p.delete_from_config_db() |
| 30 | + time.sleep(2) |
| 31 | + |
| 32 | + # 5. Verify that we are waiting in portsorch for the port |
| 33 | + # to be removed from LAG, by looking at the log |
| 34 | + self.check_syslog(dvs, marker, "Unable to remove port Ethernet0: ref count 1", 1) |
| 35 | + |
| 36 | + # 6. Also verify that port is still present in ASIC DB. |
| 37 | + assert(p.exists_in_asic_db() == True) |
| 38 | + |
| 39 | + # 7. Remove port from LAG |
| 40 | + self.dvs_lag.remove_port_channel_member(lag, p.get_name()) |
| 41 | + |
| 42 | + # 8. Verify that port is removed from ASIC DB |
| 43 | + assert(p.not_exists_in_asic_db() == True) |
| 44 | + |
| 45 | + # 9. Re-create port Ethernet0 and verify that it is |
| 46 | + # present in CONFIG, APPL, and ASIC DBs |
| 47 | + p.write_to_config_db() |
| 48 | + p.verify_config_db() |
| 49 | + p.verify_app_db() |
| 50 | + p.verify_asic_db() |
| 51 | + |
| 52 | + # 10. Remove PortChannel0001 and verify that its removed. |
| 53 | + self.dvs_lag.remove_port_channel(lag) |
| 54 | + time.sleep(30) |
| 55 | + self.dvs_lag.get_and_verify_port_channel(0) |
| 56 | + |
| 57 | + |
| 58 | +# Add Dummy always-pass test at end as workaroud |
| 59 | +# for issue when Flaky fail on final test it invokes module tear-down before retrying |
| 60 | +def test_nonflaky_dummy(): |
| 61 | + pass |
0 commit comments