Add CsonicHost for docker-exec based neighbor access in cSONiC testbeds#22705
Add CsonicHost for docker-exec based neighbor access in cSONiC testbeds#22705securely1g wants to merge 1 commit intosonic-net:masterfrom
Conversation
cSONiC (docker-sonic-vs) neighbor containers don't have SSH access,
admin users, or management IPs — they are Docker containers on the
VM host, not full VMs. This makes the existing SonicHost class
(which requires SSH/Ansible connectivity) unusable for cSONiC neighbors.
Add CsonicHost, a lightweight host class that executes commands via
'docker exec' instead of SSH. This provides the same command/shell
interface that tests expect from neighbor hosts.
Changes:
- tests/common/devices/csonic.py: New CsonicHost class with command(),
shell(), shutdown(), no_shutdown(), get_route(), get_port_channel_status(),
and config() methods, all backed by 'docker exec' via subprocess
- tests/conftest.py: Add 'csonic' to --neighbor_type choices; create
CsonicHost instances in nbrhosts fixture using container naming
convention 'csonic_{group-name}_{vm_name}'
- tests/vlan/test_vlan_ping.py: Handle cSONiC interface naming
(PortChannel1 instead of po1, Ethernet0 instead of eth1)
Tested on cSONiC KVM testbed (T0, 4 docker-sonic-vs neighbors):
pytest --neighbor_type csonic
- vlan/test_vlan_ping: PASSED
- bgp/test_bgp_fact: PASSED (with --neighbor_type sonic)
- lldp/test_lldp: PASSED (with --neighbor_type sonic)
Signed-off-by: securely1g <securely1g@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Hi @wangxin @hdwhdw — would appreciate your review on this PR. @wangxin A few questions for you:
@hdwhdw — since you've been working on the cSONiC testbed infrastructure, would love your thoughts on this approach as well. |
Add remote dpu db to bfdmon.
Description
cSONiC (docker-sonic-vs) neighbor containers run as Docker containers on the VM host — they have no SSH daemon, no
adminuser, and no management IP. This makes the existingSonicHostclass (which requires Ansible/SSH connectivity) unusable for cSONiC neighbors.This PR adds
CsonicHost, a lightweight host class that executes commands viadocker exec(subprocess) instead of SSH, providing the samecommand()/shell()interface that tests expect from neighbor hosts.Motivation
When running sonic-mgmt tests with
--neighbor_type sonicon a cSONiC testbed, thenbrhostsfixture fails at setup becauseSonicHost.__init__()tries to SSH into each neighbor and gather facts. With--neighbor_type csonic, tests can now access cSONiC neighbors without SSH infrastructure.Changes
tests/common/devices/csonic.py (new):
CsonicHostclass with:command()/shell()— run commands viadocker exec, returns Ansible-compatible dict (stdout,stdout_lines,rc, etc.)shutdown()/no_shutdown()— interface up/down viaip link setget_route()— query FRR routing table viavtyshget_port_channel_status()— query teamd stateconfig()— configure FRR viavtyshtests/conftest.py:
csonicto--neighbor_typechoicesCsonicHostinstances innbrhostsfixture using container naming conventioncsonic_{group-name}_{vm_name}csonicin techsupport collection checktests/vlan/test_vlan_ping.py:
PortChannel1instead ofpo1,Ethernet0instead ofeth1) when--neighbor_type csonicUsage
# Run tests against cSONiC testbed pytest --neighbor_type csonic --testbed vms-kvm-t0-csonic ...Test Results
Tested on cSONiC KVM testbed (T0 topology, 4 docker-sonic-vs neighbors with PortChannels):
Related PRs