-
Notifications
You must be signed in to change notification settings - Fork 738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add fixtures to call dpus on smartswtich directly #15695
base: master
Are you sure you want to change the base?
Conversation
tests/conftest.py
Outdated
@param tbinfo: fixture provides information about testbed. | ||
""" | ||
try: | ||
host = DutHosts(ansible_adhoc, tbinfo, get_specified_dpus(request), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we be able to run sonic-dpu-mgmt-traffic.sh
on the NPU automatically here? It should be possible to get the ansible SSH ports using ansible_adhoc().options['inventory_manager'].get_host(<dpu hostname>).vars
, then we can avoid a manual step.
If we do this I think it also makes sense to change the fixture scope to 'module' in case any test module causes a device reload, that way we can ensure the DPU mgmt traffic rules are always applied
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for you quick response.
You mean when the smartswitch is up, the sonic-dpu-mgmt-traffic.sh will run automatically. Right?
If the script of sonic-dpu-mgmt-traffic.sh can save the config regradless of config reload or reboot, I think we can keep it as the scope as session.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but I have question: how the sonic-dpu-mgmt-traffic.sh to get the ssh ports information?
ansible_adhoc().options['inventory_manager'].get_host().vars depends on the config of inventory, Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to call sonic-dpu-mgmt-traffic.sh
at the start of every test session from inside of this fixture. If I understand the current implementation correctly, the user needs to manually call sonic-dpu-mgmt-traffic.sh
on the NPU before starting the test session.
Also, I'm not sure if the configs changed by sonic-dpu-mgmt-traffic.sh
will persist across a reload or reboot, it looks like mostly modifying iptables rules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If so, dpuhosts will depends on duthosts, we need to make sure to call duthosts before calling dpuhosts.
Additionally, currently sonic-dpu-mgmt-traffic.sh will not persist the config after reload or reboot. So, when the test does reload or reboot, we need to re-run the script again, which will make the implement of test more complex.
For now, to persist the nat config, in our regression we run the following code on NPU during deploying the image. Maybe we can offer the other solution which is to add one pre-test to configure the NAT. What do you think?
sudo su
sudo sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf
sudo echo net.ipv4.conf.eth0.forwarding=1 >> /etc/sysctl.conf
sudo sysctl -p
sudo iptables -t nat -A POSTROUTING -s 169.254.200.0/24 -o eth0 -j MASQUERADE
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 5021 -j DNAT --to-destination 169.254.200.1:22
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 5022 -j DNAT --to-destination 169.254.200.2:22
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 5023 -j DNAT --to-destination 169.254.200.3:22
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 5024 -j DNAT --to-destination 169.254.200.4:22
sudo iptables -t nat -L
sudo iptables-save > /etc/iptables/rules.v4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds like a good idea, or possibly even doing it in a session-scoped fixture, but it might be better to address this in a separate PR. We can leave this as-is for now, could you add a short comment here about needing to call sonic-dpu-mgmt-traffic.sh
before using the fixture?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tests/conftest.py
Outdated
############################ | ||
# SmartSwitch options # | ||
############################ | ||
parser.addoption("--dpu-pattern", action="store", default=None, help="dpu host name") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a scenario where we wouldn't want to have access to all DPUs on a device? It may be simpler to just grab all DPUs from the testbed file instead of manually specifying them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usage is same as the duthost(switch), if the value is all, it will grab all dpus.
For some common tests shared with regular switch, we don't need any dpus.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this CLI parameter and just always assume we want to grab all available DPUs? I don't see the benefit in only getting a subset of the available DPUs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @theasianpianist,
It will be convenient for us to run the test when we want to specify one dpu to test. so, it is better to keep it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I that case, what if we set the default value to "all" for this parameter? That way we don't need to change how the tests are called
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. Done
@nissampa @rameshraghupathy for viz |
Hi @theasianpianist , Can you please review the reply? |
c40bad7
to
9606cbb
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
…tswtich like calling switch with dpuhosts or duphost
9606cbb
to
92e1a77
Compare
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
1. remove dut with dpu string, otherwise when add topo, we don't need to add topo for dpu 2. remove space for duts, otherwise it when using echo to create fail will fail
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
The commit of update testbed-cli.sh is to resove the following issues:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will be great to have, thanks!
Description of PR
The mgmt IP of dpus on smartswitch is private IP(169.254.200.0/24), we cannot access it directly out of the switch. To operate dpu like operating switch when impmenting the test case(dash, platform on dup), we add two fixtures: dpuhost and fixture_dpuhosts. They are same as duthost and fixture_duthosts.
Before the calling the fixtures, we need to do the steps as follows:
[SmartSwitch] Added inbound traffic capability for DPU management traffic script sonic-buildimage#20635
e.g.
e.g.
e.g.
So, we can access the dpu directly out of switch such as "ssh [email protected] -p 5021"
Run tests usage:
When runing case only on dpu(For the exsiting tests such as platform, techsupport, we can run them without any case change):
When running case on smartswitch(NPU) and dpu:
Summary:
Fixes # (issue)
Type of change
Back port request
Approach
What is the motivation for this PR?
Add fixtures to operate dup directly out of switch like operating switch
How did you do it?
Add fixures : duthost and fixture_duthosts
How did you verify/test it?
run platform case on dpu only and dash case on smartswitch
Any platform specific information?
SmartSwtich
Supported testbed topology if it's a new test case?
Documentation