Skip to content

Commit

Permalink
Added a test case to verify that invalid mirror session enties are no…
Browse files Browse the repository at this point in the history
…t created.

Signed-off-by: Mahdi Ramezani <mramezani@microsoft.com>
  • Loading branch information
mramezani95 committed Nov 15, 2024
1 parent 2781d66 commit 219647b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,25 @@ def get_mirror_session_state(self, name):
assert len(fvs) > 0
return { fv[0]: fv[1] for fv in fvs }

def mirror_session_entry_exists(self, name):
tbl = swsscommon.Table(self.sdb, "MIRROR_SESSION_TABLE")
(status, _) = tbl.get(name)
return status

def check_syslog(self, dvs, marker, log, expected_cnt):
(ec, out) = dvs.runcmd(['sh', '-c', "awk \'/%s/,ENDFILE {print;}\' /var/log/syslog | grep \'%s\' | wc -l" % (marker, log)])
assert out.strip() == str(expected_cnt)

def test_MirrorInvalidEntry(self):
"""
This test ensures that an invalid mirror session entry is not created.
Here, "invalid" means an entry in which src IP is IPv4 while dst IP is IPv6
(or vice versa).
"""
session = "TEST_SESSION"
self.create_mirror_session(session, "1.1.1.1", "fc00::2:2:2:2", "0x6558", "8", "100", "0")
assert self.mirror_session_entry_exists(session) == False

def _test_MirrorAddRemove(self, dvs, testlog, v6_encap=False):
"""
This test covers the basic mirror session creation and removal operations
Expand Down

0 comments on commit 219647b

Please sign in to comment.