@@ -103,6 +103,9 @@ def get_mirror_session_state(self, name):
103103 assert len (fvs ) > 0
104104 return { fv [0 ]: fv [1 ] for fv in fvs }
105105
106+ def check_syslog (self , dvs , marker , log , expected_cnt ):
107+ (ec , out ) = dvs .runcmd (['sh' , '-c' , "awk \' /%s/,ENDFILE {print;}\' /var/log/syslog | grep \' %s\' | wc -l" % (marker , log )])
108+ assert out .strip () == str (expected_cnt )
106109
107110 def test_MirrorAddRemove (self , dvs , testlog ):
108111 """
@@ -120,9 +123,11 @@ def test_MirrorAddRemove(self, dvs, testlog):
120123
121124 session = "TEST_SESSION"
122125
126+ marker = dvs .add_log_marker ()
123127 # create mirror session
124128 self .create_mirror_session (session , "1.1.1.1" , "2.2.2.2" , "0x6558" , "8" , "100" , "0" )
125129 assert self .get_mirror_session_state (session )["status" ] == "inactive"
130+ self .check_syslog (dvs , marker , "Attached next hop observer .* for destination IP 2.2.2.2" , 1 )
126131
127132 # bring up Ethernet16
128133 self .set_interface_status (dvs , "Ethernet16" , "up" )
@@ -193,8 +198,10 @@ def test_MirrorAddRemove(self, dvs, testlog):
193198 self .set_interface_status (dvs , "Ethernet16" , "down" )
194199 assert self .get_mirror_session_state (session )["status" ] == "inactive"
195200
201+ marker = dvs .add_log_marker ()
196202 # remove mirror session
197203 self .remove_mirror_session (session )
204+ self .check_syslog (dvs , marker , "Detached next hop observer for destination IP 2.2.2.2" , 1 )
198205
199206 def create_vlan (self , dvs , vlan ):
200207 #dvs.runcmd("ip link del Bridge")
@@ -251,9 +258,11 @@ def test_MirrorToVlanAddRemove(self, dvs, testlog):
251258
252259 session = "TEST_SESSION"
253260
261+ marker = dvs .add_log_marker ()
254262 # create mirror session
255263 self .create_mirror_session (session , "5.5.5.5" , "6.6.6.6" , "0x6558" , "8" , "100" , "0" )
256264 assert self .get_mirror_session_state (session )["status" ] == "inactive"
265+ self .check_syslog (dvs , marker , "Attached next hop observer .* for destination IP 6.6.6.6" , 1 )
257266
258267 # create vlan; create vlan member
259268 self .create_vlan (dvs , "6" )
@@ -339,8 +348,10 @@ def test_MirrorToVlanAddRemove(self, dvs, testlog):
339348 self .remove_vlan_member ("6" , "Ethernet4" )
340349 self .remove_vlan ("6" )
341350
351+ marker = dvs .add_log_marker ()
342352 # remove mirror session
343353 self .remove_mirror_session (session )
354+ self .check_syslog (dvs , marker , "Detached next hop observer for destination IP 6.6.6.6" , 1 )
344355
345356 def create_port_channel (self , dvs , channel ):
346357 tbl = swsscommon .ProducerStateTable (self .pdb , "LAG_TABLE" )
@@ -388,9 +399,11 @@ def test_MirrorToLagAddRemove(self, dvs, testlog):
388399
389400 session = "TEST_SESSION"
390401
402+ marker = dvs .add_log_marker ()
391403 # create mirror session
392404 self .create_mirror_session (session , "10.10.10.10" , "11.11.11.11" , "0x6558" , "8" , "100" , "0" )
393405 assert self .get_mirror_session_state (session )["status" ] == "inactive"
406+ self .check_syslog (dvs , marker , "Attached next hop observer .* for destination IP 11.11.11.11" , 1 )
394407
395408 # create port channel; create port channel member
396409 self .create_port_channel (dvs , "008" )
@@ -436,8 +449,10 @@ def test_MirrorToLagAddRemove(self, dvs, testlog):
436449 self .remove_port_channel_member ("008" , "Ethernet88" )
437450 self .remove_port_channel (dvs , "008" )
438451
452+ marker = dvs .add_log_marker ()
439453 # remove mirror session
440454 self .remove_mirror_session (session )
455+ self .check_syslog (dvs , marker , "Detached next hop observer for destination IP 11.11.11.11" , 1 )
441456
442457
443458 # Ignore testcase in Debian Jessie
0 commit comments