This article will introduce the detailed processing of entire PTF-SAIv2 testing, including:
- Build PTF-SAIv2 infras leveraged by sonic-buildimage
- Setup the testbed by sonic-mgmt
- Setup saiserverv2 docker on DUT (Device under testing)
- Prepare the testing env and start PTF-SAIv2 testing within ptf-sai docker
In this part, we will build PTF-SAIv2 infras using sonic-buildimage.
- Check the sonic image version and commit id: Check SAI Header Version And SONiC Branch
- Reset the sonic-buildimage with the branch and commit id previous checked
rm -rf ./sonic-buildimage git clone https://github.com/sonic-net/sonic-buildimage.git cd sonic-buildimage git checkout <specific branch> git reset --hard <specific commit id>
- Build PTF-SAIv2 infras
# Init env make init # BLDENV=buster: Current image is buster # PLATFORM=<vendor name> Setup platform environment e.g. broadcom make BLDENV=buster configure PLATFORM=broadcom # SAITHRIFT_V2=y: build the saiserver version 2rd # build brcm saiserverv2 docker make BLDENV=buster SAITHRIFT_V2=y -f Makefile.work target/docker-saiserverv2-brcm.gz # build ptf-sai docker # Clean environment make reset # Setup platform environment e.g. virtul switch make BLDENV=buster configure PLATFORM=vs make BLDENV=buster SAITHRIFT_V2=y -f Makefile.work target/docker-ptf-sai.gz
In this section, we will setup the physical switch testbed.
- Install the sonic image in the DUT, as for how to install a sonic image on supported switch, please refer to this doc Install sonic eos image
- Remove the topology for the current Testbed
- Deploy the non-topology
- Push the mini-graph to DUT
For the detailed command of step 2-4, please check Deploy SAI Test Topology With SONiC-MGMT
For the setup of ptf-sai docker, you can refer to this section Setup Docker Registry for docker-ptf, please replace the docker-ptf
with docker-ptf-sai
In this section, we will introduce how to setup the saiserverv2 docker in DUT.
-
Stop all the other services besides
database
, which might impact PTF-SAIv2 testing. (Recommanded)You may activate some services acording to your scenario, but please be sure to stop
swss
andsyncd
.services=("swss" "syncd" "radv" "lldp" "dhcp_relay" "teamd" "bgp" "pmon" "telemetry" "acms" "snmp") stop_service(){ for serv in ${services[*]}; do echo "stop service: [$serv]." sudo systemctl stop $serv done } stop_service
-
Upload the saiserverv2 docker you built from previous section to your DUT or Pull saiserverv2 docker image from registry, as for the detailed setup of docker registry, please refer to Example: Start SaiServer Docker In DUT
-
Start your saiserver binary from saiserverv2 docker, as for detailed information, please refer to this section Prepare testing environment on DUT:
After successfully starting the saiserver binary, we can get those output from shell:
admin@s6000:~$ usr/sbin/saiserver -p /etc/sai.d/sai.profile -f /usr/share/sonic/hwsku/port_config.ini
profile map file: /usr/share/sonic/hwsku/sai.profile
port map file: /usr/share/sonic/hwsku/port_config.ini
insert: SAI_INIT_CONFIG_FILE:/usr/share/sonic/hwsku/td2-s6000-32x40G.config.bcm
insert: SAI_NUM_ECMP_MEMBERS:32
Starting SAI RPC server on port 9092
In the last section, we will setup our testing environment and run a sanity test on PTF side.
-
Login to the ptf-sai docker, you can find the ip address of docker which is connected to the DUT in testbed.yaml.
-
Install the sai python header
python-saithriftv2_0.9.4_amd64.deb
into ptf-sai docker.# install the deb package into ptf-sai docker dpkg -i python-saithriftv2_0.9.4_amd64.deb
-
Make sure Github is accessible on ptf-sai docker and download the SAI repo which contains PTF-SAIv2 test cases
rm -rf ./SAI git clone https://github.com/opencomputeproject/SAI.git cd SAI git checkout v1.9
-
Start PTF-SAIv2 testing within ptf-sai docker
Note: Prepare a port_map_file named default_interface_to_front_map.ini in advance
# set the platform name export PLATFORM=<vendor name> # run a sanitytest ptf --test-dir ptf saisanity.L2SanityTest --interface '<used port number and dataplane interface>' -t "thrift_server='<DUT ip address>';port_map_file='default_interface_to_front_map.ini'" # use a broadcom switch with 32-port as exmaple export PLATFORM=brcm ptf --test-dir /tmp/SAI/ptf saisanity.L2SanityTest --interface '0-0@eth0' --interface '0-1@eth1' --interface '0-2@eth2' --interface '0-3@eth3' --interface '0-4@eth4' --interface '0-5@eth5' --interface '0-6@eth6' --interface '0-7@eth7' --interface '0-8@eth8' --interface '0-9@eth9' --interface '0-10@eth10' --interface '0-11@eth11' --interface '0-12@eth12' --interface '0-13@eth13' --interface '0-14@eth14' --interface '0-15@eth15' --interface '0-16@eth16' --interface '0-17@eth17' --interface '0-18@eth18' --interface '0-19@eth19' --interface '0-20@eth20' --interface '0-21@eth21' --interface '0-22@eth22' --interface '0-23@eth23' --interface '0-24@eth24' --interface '0-25@eth25' --interface '0-26@eth26' --interface '0-27@eth27' --interface '0-28@eth28' --interface '0-29@eth29' --interface '0-30@eth30' --interface '0-31@eth31' "--test-params=thrift_server='<DUT ip address>'"
Finally, we can see the result as shown below:
Using packet manipulation module: ptf.packet_scapy
saisanity.L2SanityTest ... Waiting for switch to get ready, 5 seconds ...
...
Check port31 forwarding...
ok
----------------------------------------------------------------------
Ran 1 test in 21.184s
OK