@@ -126,10 +126,10 @@ def copp_testbed(
126126 pytest .skip ("Topology not supported by COPP tests" )
127127
128128 try :
129- _setup_testbed (duthost , creds , ptfhost , test_params )
129+ _setup_testbed (duthost , creds , ptfhost , test_params , tbinfo )
130130 yield test_params
131131 finally :
132- _teardown_testbed (duthost , creds , ptfhost , test_params )
132+ _teardown_testbed (duthost , creds , ptfhost , test_params , tbinfo )
133133
134134@pytest .fixture (autouse = True )
135135def ignore_expected_loganalyzer_exceptions (rand_one_dut_hostname , loganalyzer ):
@@ -144,10 +144,6 @@ def ignore_expected_loganalyzer_exceptions(rand_one_dut_hostname, loganalyzer):
144144 loganalyzer: Loganalyzer utility fixture
145145 """
146146 ignoreRegex = [
147- ".*ERR monit.*'lldpd_monitor' process is not running.*" ,
148- ".*ERR monit.* 'lldp\|lldpd_monitor' status failed.*-- 'lldpd:' is not running.*" ,
149- ".*ERR monit.*'lldp_syncd' process is not running.*" ,
150- ".*ERR monit.*'lldp\|lldp_syncd' status failed.*'python2 -m lldp_syncd' is not running.*" ,
151147 ".*snmp#snmp-subagent.*" ,
152148 ".*kernel reports TIME_ERROR: 0x4041: Clock Unsynchronized.*"
153149 ]
@@ -208,33 +204,37 @@ def _gather_test_params(tbinfo, duthost, request):
208204 peerip = bgp_peer ["peer_addr" ]
209205 break
210206
211- logging .info ("nn_target_port {} nn_target_interface {}" .format (nn_target_port , nn_target_interface ))
207+ nn_target_namespace = mg_facts ["minigraph_neighbors" ][nn_target_interface ]['namespace' ]
208+
209+ logging .info ("nn_target_port {} nn_target_interface {} nn_target_namespace {}" .format (nn_target_port , nn_target_interface , nn_target_namespace ))
212210
213211 return _COPPTestParameters (nn_target_port = nn_target_port ,
214212 swap_syncd = swap_syncd ,
215213 topo = topo ,
216214 myip = myip ,
217215 peerip = peerip ,
218216 nn_target_interface = nn_target_interface ,
219- nn_target_namespace = mg_facts [ "minigraph_neighbors" ][ nn_target_interface ][ 'namespace' ] )
217+ nn_target_namespace = nn_target_namespace )
220218
221- def _setup_testbed (dut , creds , ptf , test_params ):
219+ def _setup_testbed (dut , creds , ptf , test_params , tbinfo ):
222220 """
223221 Sets up the testbed to run the COPP tests.
224222 """
225223 if dut .is_multi_asic :
226224 logging .info ("Adding iptables rules and enabling eth0 port forwarding" )
225+ http_proxy , https_proxy = copp_utils ._get_http_and_https_proxy_ip (creds )
227226 # IP Table rule for http and ptf nn_agent traffic.
228227 dut .command ("sudo sysctl net.ipv4.conf.eth0.forwarding=1" )
229228 mgmt_ip = dut .host .options ["inventory_manager" ].get_host (dut .hostname ).vars ["ansible_host" ]
229+ # Rule to communicate to http/s proxy from namespace
230230 dut .command ("sudo iptables -t nat -A POSTROUTING -p tcp --dport 8080 -j SNAT --to-source {}" .format (mgmt_ip ))
231- ip_ifs = dut .show_ip_interface (namespace = test_params .nn_target_namespace )["ansible_facts" ]
232- dut .command ("sudo iptables -t nat -A PREROUTING -p tcp --dport 10900 -j DNAT --to-destination {}" .format (ip_ifs ["ip_interfaces" ]["eth0" ]["ipv4" ]))
233- http_proxy = re .findall (r'[0-9]+(?:\.[0-9]+){3}' , creds .get ('proxy_env' , {}).get ('http_proxy' , '' ))[0 ]
234- https_proxy = re .findall (r'[0-9]+(?:\.[0-9]+){3}' , creds .get ('proxy_env' , {}).get ('https_proxy' , '' ))[0 ]
235231 dut .command ("sudo ip -n {} rule add from all to {} pref 1 lookup default" .format (test_params .nn_target_namespace , http_proxy ))
236232 if http_proxy != https_proxy :
237233 dut .command ("sudo ip -n {} rule add from all to {} pref 2 lookup default" .format (test_params .nn_target_namespace , https_proxy ))
234+ # Rule to communicate to ptf nn agent client from namespace
235+ ns_ip = dut .shell ("sudo ip -n {} -4 -o addr show eth0" .format (test_params .nn_target_namespace ) + " | awk '{print $4}' | cut -d'/' -f1" )["stdout" ]
236+ dut .command ("sudo iptables -t nat -A PREROUTING -p tcp --dport 10900 -j DNAT --to-destination {}" .format (ns_ip ))
237+ dut .command ("sudo ip -n {} rule add from {} to {} pref 3 lookup default" .format (test_params .nn_target_namespace , ns_ip , tbinfo ["ptf_ip" ]))
238238
239239
240240
@@ -258,33 +258,31 @@ def _setup_testbed(dut, creds, ptf, test_params):
258258 # NOTE: Even if the rpc syncd image is already installed, we need to restart
259259 # SWSS for the COPP changes to take effect.
260260 logging .info ("Reloading config and restarting swss..." )
261- config_reload (dut , wait = 180 )
261+ config_reload (dut )
262262
263263 logging .info ("Configure syncd RPC for testing" )
264264 copp_utils .configure_syncd (dut , test_params .nn_target_port , test_params .nn_target_interface ,
265265 test_params .nn_target_namespace , creds )
266266
267- def _teardown_testbed (dut , creds , ptf , test_params ):
267+ def _teardown_testbed (dut , creds , ptf , test_params , tbinfo ):
268268 """
269269 Tears down the testbed, returning it to its initial state.
270270 """
271271 if dut .is_multi_asic :
272272 logging .info ("Removing iptables rules and disabling eth0 port forwarding" )
273+ http_proxy , https_proxy = copp_utils ._get_http_and_https_proxy_ip (creds )
273274
274275 dut .command ("sudo sysctl net.ipv4.conf.eth0.forwarding=0" )
275276
276277 mgmt_ip = dut .host .options ["inventory_manager" ].get_host (dut .hostname ).vars ["ansible_host" ]
277278 dut .command ("sudo iptables -t nat -D POSTROUTING -p tcp --dport 8080 -j SNAT --to-source {}" .format (mgmt_ip ))
278-
279- ip_ifs = dut .show_ip_interface (namespace = test_params .nn_target_namespace )["ansible_facts" ]
280- dut .command ("sudo iptables -t nat -D PREROUTING -p tcp --dport 10900 -j DNAT --to-destination {}" .format (ip_ifs ["ip_interfaces" ]["eth0" ]["ipv4" ]))
281- http_proxy = re .findall (r'[0-9]+(?:\.[0-9]+){3}' , creds .get ('proxy_env' , {}).get ('http_proxy' , '' ))[0 ]
282- https_proxy = re .findall (r'[0-9]+(?:\.[0-9]+){3}' , creds .get ('proxy_env' , {}).get ('https_proxy' , '' ))[0 ]
283279 dut .command ("sudo ip -n {} rule delete from all to {} pref 1 lookup default" .format (test_params .nn_target_namespace , http_proxy ))
284280 if http_proxy != https_proxy :
285281 dut .command ("sudo ip -n {} rule delete from all to {} pref 2 lookup default" .format (test_params .nn_target_namespace , https_proxy ))
286282
287-
283+ ns_ip = dut .shell ("sudo ip -n {} -4 -o addr show eth0" .format (test_params .nn_target_namespace ) + " | awk '{print $4}' | cut -d'/' -f1" )["stdout" ]
284+ dut .command ("sudo iptables -t nat -D PREROUTING -p tcp --dport 10900 -j DNAT --to-destination {}" .format (ns_ip ))
285+ dut .command ("sudo ip -n {} rule delete from {} to {} pref 3 lookup default" .format (test_params .nn_target_namespace , ns_ip , tbinfo ["ptf_ip" ]))
288286
289287 logging .info ("Restore PTF post COPP test" )
290288 copp_utils .restore_ptf (ptf )
0 commit comments