Skip to content

Commit

Permalink
Add VS test to check metric fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed May 25, 2021
1 parent 2dcdaab commit 9d80c9e
Showing 1 changed file with 54 additions and 1 deletion.
55 changes: 54 additions & 1 deletion tests/test_mux.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,51 @@ def create_and_test_acl(self, appdb, asicdb, dvs, dvs_acl):
self.set_mux_state(appdb, "Ethernet4", "active")
dvs_acl.verify_no_acl_rules()

def create_and_test_metrics(self, appdb, statedb, dvs):

# Set to active and test attributes for start and end time
self.set_mux_state(appdb, "Ethernet0", "active")
keys = statedb.get_keys("MUX_METRICS_TABLE")
assert len(keys) != 0

for key in keys:
if key != "Ethernet0":
continue
fvs = statedb.get_entry("MUX_METRICS_TABLE", key)
assert fvs != {}

start = end = False
for f,v in fvs.items():
if f == "orch_switch_active_start":
start = True
elif f == "orch_switch_active_end":
end = True

assert start
assert end

# Set to standby and test attributes for start and end time
self.set_mux_state(appdb, "Ethernet0", "standby")

keys = statedb.get_keys("MUX_METRICS_TABLE")
assert len(keys) != 0

for key in keys:
if key != "Ethernet0":
continue
fvs = statedb.get_entry("MUX_METRICS_TABLE", key)
assert fvs != {}

start = end = False
for f,v in fvs.items():
if f == "orch_switch_standby_start":
start = True
elif f == "orch_switch_standby_end":
end = True

assert start
assert end


def check_interface_exists_in_asicdb(self, asicdb, sai_oid):
asicdb.wait_for_entry(self.ASIC_RIF_TABLE, sai_oid)
Expand Down Expand Up @@ -643,13 +688,21 @@ def test_Route(self, dvs, dvs_route, testlog):


def test_acl(self, dvs, dvs_acl, testlog):
""" test Route entries and mux state change """
""" test acl and mux state change """

appdb = swsscommon.DBConnector(swsscommon.APPL_DB, dvs.redis_sock, 0)
asicdb = dvs.get_asic_db()

self.create_and_test_acl(appdb, asicdb, dvs, dvs_acl)

def test_mux_metrics(self, dvs, testlog):
""" test metrics for mux state change """

appdb = swsscommon.DBConnector(swsscommon.APPL_DB, dvs.redis_sock, 0)
statedb = dvs.get_state_db()

self.create_and_test_metrics(appdb, statedb, dvs)


# Add Dummy always-pass test at end as workaroud
# for issue when Flaky fail on final test it invokes module tear-down before retrying
Expand Down

0 comments on commit 9d80c9e

Please sign in to comment.