From 7b73c977072a2f33e417eaa03dcfd46201345fa4 Mon Sep 17 00:00:00 2001 From: Jie Feng Date: Fri, 6 Oct 2023 19:30:08 -0700 Subject: [PATCH] Add test for fabric daemon --- tests/test_fabric_port.py | 50 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/test_fabric_port.py diff --git a/tests/test_fabric_port.py b/tests/test_fabric_port.py new file mode 100644 index 0000000000..ea3dd6bc8a --- /dev/null +++ b/tests/test_fabric_port.py @@ -0,0 +1,50 @@ +from swsscommon import swsscommon +from dvslib.dvs_database import DVSDatabase + + +class TestVirtualChassis(object): + def test_voq_switch_fabric_link(self, vst): + """Test fabric link manual isolation commands in VOQ switch. + + By issuing config fabric port isolation command, the value + of isolateStatus field in config_db get changed. This test validates appl_db + updates of a fabric link isolateStatus as the value in config_db changed. + """ + + dvss = vst.dvss + for name in dvss.keys(): + dvs = dvss[name] + # Get the config info + config_db = dvs.get_config_db() + metatbl = config_db.get_entry("DEVICE_METADATA", "localhost") + + cfg_switch_type = metatbl.get("switch_type") + if cfg_switch_type == "fabric": + + # get config_db information + cdb = dvs.get_config_db() + # check if the link isolateStatus in config_db is False as a start value. + cdb.wait_for_field_match("FABRIC_PORT", "Fabric1", {"isolateStatus": "False"}) + + # set config_db to isolateStatus: True + cdb.update_entry("FABRIC_PORT", "Fabric1", {"isolateStatus": "True"}) + cdb.wait_for_field_match("FABRIC_PORT", "Fabric1", {"isolateStatus": "True"}) + + # check if appl_db value changes to isolateStatus: True + adb = dvs.get_app_db() + adb.wait_for_field_match("FABRIC_PORT_TABLE", "Fabric1", {"isolateStatus": "True"}) + + # cleanup + cdb.update_entry("FABRIC_PORT", "Fabric1", {"isolateStatus": "False"}) + cdb.wait_for_field_match("FABRIC_PORT", "Fabric1", {"isolateStatus": "False"}) + adb.wait_for_field_match("FABRIC_PORT_TABLE", "Fabric1", {"isolateStatus": "False"}) + else: + print( "We do not check switch type:", cfg_switch_type ) + + +# Add Dummy always-pass test at end as workaroud +# for issue when Flaky fail on final test it invokes module tear-down before retrying +def test_nonflaky_dummy(): + pass + +