Skip to content

multi-asic support for copp testcase#3060

Merged
abdosi merged 15 commits intosonic-net:masterfrom
abdosi:copp
Mar 12, 2021
Merged

multi-asic support for copp testcase#3060
abdosi merged 15 commits intosonic-net:masterfrom
abdosi:copp

Conversation

@abdosi
Copy link
Copy Markdown
Contributor

@abdosi abdosi commented Feb 28, 2021

What/Why I did:

This is PR continuation of #2627 where infra changes were done to support copp on multi-asic platforms. In this PR test is enhanced to work on multi-asic platforms. Following are major changes:

  • Multi-asic as of now will support installing of nanomsg and ptf_nn_agent in syncd directly mode. This way test case will randomly select any front-asic syncd for verification. To support this needed to add iptable rules for HTTP and PTF Traffic forwarding from host to asic namespace. swap_syncd mode is not supported as of now.

  • All the docker name are translated to particular namespace/asic that is under test. (Added utility api for same).

  • Remove disable_lldp_for_testing fixture as noted below since test case is not dependent on that.

How I Verify:

Verify test_copp.py on both single and multi-asic platforms.

@abdosi abdosi requested a review from daall February 28, 2021 02:06
@abdosi abdosi requested a review from a team as a code owner February 28, 2021 02:06
@abdosi
Copy link
Copy Markdown
Contributor Author

abdosi commented Mar 4, 2021

@daall can you please review this.

duthost = duthosts[rand_one_dut_hostname]

logging.info("Disabling LLDP for the COPP tests")
logging.info("Disabling LLDP Container auto-restart for the COPP tests")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC the reason we put this in a separate fixture was so that even if there was some issue during setup/teardown then this code should still execute and ensure that LLDP is brought back. Would it be possible to move the startup/shutdown of LLDP and BGP into this fixture and handle the multi-asic parts here as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, ok I will disable bgp and lldp feature itself (which make sure all instance will be down in multi-asic)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daall Looks like there is issue with LLDP where even if we stop the lldp the config reload will restart it . Looks like we don't need to stop LLDP then ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daall I have confirmed fixture disable_lldp_for_testing where we disable lldp gets restarted as part of config reload/swap_syncd. So I am planning to remove this fixture as test cases works fine and passes without needing to disable lldp.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daall Updated based on my above comment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to me, thanks for checking!

@abdosi
Copy link
Copy Markdown
Contributor Author

abdosi commented Mar 11, 2021

Hi @daall can you please review again.

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Mar 11, 2021

This pull request introduces 1 alert when merging 0b0d88a into 11c7344 - view on LGTM.com

new alerts:

  • 1 for Unused import

Signed-off-by: Abhishek Dosi <[email protected]>
Comment on lines +223 to +236
logging.info("Adding iptables rules and enabling eth0 port forwarding")
http_proxy, https_proxy = copp_utils._get_http_and_https_proxy_ip(creds)
# IP Table rule for http and ptf nn_agent traffic.
dut.command("sudo sysctl net.ipv4.conf.eth0.forwarding=1")
mgmt_ip = dut.host.options["inventory_manager"].get_host(dut.hostname).vars["ansible_host"]
# Rule to communicate to http/s proxy from namespace
dut.command("sudo iptables -t nat -A POSTROUTING -p tcp --dport 8080 -j SNAT --to-source {}".format(mgmt_ip))
dut.command("sudo ip -n {} rule add from all to {} pref 1 lookup default".format(test_params.nn_target_namespace, http_proxy))
if http_proxy != https_proxy:
dut.command("sudo ip -n {} rule add from all to {} pref 2 lookup default".format(test_params.nn_target_namespace, https_proxy))
# Rule to communicate to ptf nn agent client from namespace
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"]
dut.command("sudo iptables -t nat -A PREROUTING -p tcp --dport 10900 -j DNAT --to-destination {}".format(ns_ip))
dut.command("sudo ip -n {} rule add from {} to {} pref 3 lookup default".format(test_params.nn_target_namespace, ns_ip, tbinfo["ptf_ip"]))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability it would be good if this was a separate helper method like "setup_multi_asic_proxy" or something similar?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daall Updated.

Comment on lines +274 to +284
dut.command("sudo sysctl net.ipv4.conf.eth0.forwarding=0")

mgmt_ip = dut.host.options["inventory_manager"].get_host(dut.hostname).vars["ansible_host"]
dut.command("sudo iptables -t nat -D POSTROUTING -p tcp --dport 8080 -j SNAT --to-source {}".format(mgmt_ip))
dut.command("sudo ip -n {} rule delete from all to {} pref 1 lookup default".format(test_params.nn_target_namespace, http_proxy))
if http_proxy != https_proxy:
dut.command("sudo ip -n {} rule delete from all to {} pref 2 lookup default".format(test_params.nn_target_namespace, https_proxy))

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"]
dut.command("sudo iptables -t nat -D PREROUTING -p tcp --dport 10900 -j DNAT --to-destination {}".format(ns_ip))
dut.command("sudo ip -n {} rule delete from {} to {} pref 3 lookup default".format(test_params.nn_target_namespace, ns_ip, tbinfo["ptf_ip"]))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daall Updated

Signed-off-by: Abhishek Dosi <[email protected]>

enable_container_autorestart(duthost, testcase="test_copp", feature_list=feature_list)
def _setup_multi_asic_proxy(dut, creds, test_params, tbinfo):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for this extra line (same applies to below method)

Tears down the testbed, returning it to its initial state.
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space

Signed-off-by: Abhishek Dosi <[email protected]>
@abdosi abdosi merged commit 0db62d7 into sonic-net:master Mar 12, 2021
@abdosi abdosi deleted the copp branch March 12, 2021 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants