|
7 | 7 | @pytest.mark.usefixtures('dvs_mirror_manager')
|
8 | 8 | @pytest.mark.usefixtures('dvs_policer_manager')
|
9 | 9 | class TestMirror(object):
|
| 10 | + |
| 11 | + def check_syslog(self, dvs, marker, log, expected_cnt): |
| 12 | + (ec, out) = dvs.runcmd(['sh', '-c', "awk \'/%s/,ENDFILE {print;}\' /var/log/syslog | grep \'%s\' | wc -l" % (marker, log)]) |
| 13 | + assert out.strip() == str(expected_cnt) |
| 14 | + |
| 15 | + |
| 16 | + def test_PortMirrorQueue(self, dvs, testlog): |
| 17 | + """ |
| 18 | + This test covers valid and invalid values of the queue parameter. All sessions have source & dest port. |
| 19 | + Operation flow: |
| 20 | + 1. Create mirror session with queue 0, verify session becomes active and error not written to log. |
| 21 | + 2. Create mirror session with queue max valid value, verify session becomes active and error not written to log. |
| 22 | + 3. Create mirror session with queue max valid value + 1, verify session doesnt get created and error written to log. |
| 23 | + Due to lag in table operations, verify_no_mirror is necessary at the end of each step, to ensure cleanup before next step. |
| 24 | + Note that since orchagent caches max valid value during initialization, this test cannot simulate a value from SAI, e.g. |
| 25 | + by calling setReadOnlyAttr, because orchagent has already completed initialization and would never read the simulated value. |
| 26 | + Therefore, the default value must be used, MIRROR_SESSION_DEFAULT_NUM_TC which is defined in mirrororch.cpp as 255. |
| 27 | + """ |
| 28 | + |
| 29 | + session = "TEST_SESSION" |
| 30 | + dst_port = "Ethernet16" |
| 31 | + src_ports = "Ethernet12" |
| 32 | + |
| 33 | + # Sub Test 1 |
| 34 | + marker = dvs.add_log_marker() |
| 35 | + self.dvs_mirror.create_span_session(session, dst_port, src_ports, direction="BOTH", queue="0") |
| 36 | + self.dvs_mirror.verify_session_status(session) |
| 37 | + self.dvs_mirror.remove_mirror_session(session) |
| 38 | + self.dvs_mirror.verify_no_mirror() |
| 39 | + self.check_syslog(dvs, marker, "Failed to get valid queue 0", 0) |
| 40 | + |
| 41 | + # Sub Test 2 |
| 42 | + marker = dvs.add_log_marker() |
| 43 | + self.dvs_mirror.create_span_session(session, dst_port, src_ports, direction="RX", queue="254") |
| 44 | + self.dvs_mirror.verify_session_status(session) |
| 45 | + self.dvs_mirror.remove_mirror_session(session) |
| 46 | + self.dvs_mirror.verify_no_mirror() |
| 47 | + self.check_syslog(dvs, marker, "Failed to get valid queue 254", 0) |
| 48 | + |
| 49 | + # Sub Test 3 |
| 50 | + marker = dvs.add_log_marker() |
| 51 | + self.dvs_mirror.create_span_session(session, dst_port, src_ports, direction="TX", queue="255") |
| 52 | + self.dvs_mirror.verify_session_status(session, expected=0) |
| 53 | + self.dvs_mirror.remove_mirror_session(session) |
| 54 | + self.dvs_mirror.verify_no_mirror() |
| 55 | + self.check_syslog(dvs, marker, "Failed to get valid queue 255", 1) |
| 56 | + |
| 57 | + |
10 | 58 | def test_PortMirrorAddRemove(self, dvs, testlog):
|
11 | 59 | """
|
12 | 60 | This test covers the basic SPAN mirror session creation and removal operations
|
@@ -471,7 +519,6 @@ def test_PortLAGMirrorUpdateLAG(self, dvs, testlog):
|
471 | 519 | self.dvs_vlan.asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_LAG", 0)
|
472 | 520 |
|
473 | 521 |
|
474 |
| - |
475 | 522 | # Add Dummy always-pass test at end as workaroud
|
476 | 523 | # for issue when Flaky fail on final test it invokes module tear-down before retrying
|
477 | 524 | def test_nonflaky_dummy():
|
|
0 commit comments