├── sonic-mgmt-testbed ├── ansible │ ├── group_vars │ │ ├── all │ │ │ ├── inv_mapping.json │ │ │ └── inv_mapping.yml │ │ ├── snappi-sonic │ │ │ ├── secrets.yml │ │ │ └── snappi-sonic.yml │ │ └── lab │ │ │ └── lab.yml │ ├── files │ │ ├── snappi_sonic_devices.csv │ │ ├── snappi_sonic_link.csv │ │ └── snappi_sonic_connection_graph.xml │ ├── snappi-sonic │ └── testbed.csv ├── dev-env.sh ├── README.md └── DockerCommands.md └── sonic └── sonic_contributing.md /sonic-mgmt-testbed/ansible/group_vars/all/inv_mapping.json: -------------------------------------------------------------------------------- 1 | { 2 | "lab": "lab_connection_graph.xml", 3 | "snappi-sonic": "snappi_sonic_connection_graph.xml" 4 | } 5 | 6 | 7 | -------------------------------------------------------------------------------- /sonic-mgmt-testbed/ansible/group_vars/all/inv_mapping.yml: -------------------------------------------------------------------------------- 1 | # Specify all public mappings below 2 | lab: lab_connection_graph.xml 3 | # snappi 4 | snappi-sonic: snappi_sonic_connection_graph.xml 5 | -------------------------------------------------------------------------------- /sonic-mgmt-testbed/ansible/group_vars/snappi-sonic/secrets.yml: -------------------------------------------------------------------------------- 1 | ansible_ssh_pass: YourPaSsWoRd 2 | ansible_become_pass: YourPaSsWoRd 3 | sonicadmin_user: admin 4 | sonicadmin_password: YourPaSsWoRd 5 | sonicadmin_initial_password: YourPaSsWoRd 6 | -------------------------------------------------------------------------------- /sonic-mgmt-testbed/ansible/files/snappi_sonic_devices.csv: -------------------------------------------------------------------------------- 1 | Hostname,ManagementIp,HwSku,Type 2 | snappi-sonic,10.36.78.53/32,SNAPPI-tester,DevSnappiChassis 3 | sonic-s6100-dut,10.36.79.243/32,Arista-7060CX-32S-C32,DevSonic 4 | snappi-sonic-api-serv,10.36.78.96/32,SNAPPI-tester,DevSnappiApiServ 5 | 6 | -------------------------------------------------------------------------------- /sonic-mgmt-testbed/ansible/files/snappi_sonic_link.csv: -------------------------------------------------------------------------------- 1 | StartDevice,StartPort,EndDevice,EndPort,BandWidth,VlanID,VlanMode 2 | sonic-s6100-dut,Ethernet64,snappi-sonic,Card4/Port1,100000,2,Access 3 | sonic-s6100-dut,Ethernet68,snappi-sonic,Card4/Port2,100000,2,Access 4 | sonic-s6100-dut,Ethernet72,snappi-sonic,Card4/Port3,100000,2,Access 5 | sonic-s6100-dut,Ethernet76,snappi-sonic,Card4/Port4,100000,2,Access 6 | 7 | -------------------------------------------------------------------------------- /sonic-mgmt-testbed/ansible/snappi-sonic: -------------------------------------------------------------------------------- 1 | [sonic_dell64_40] 2 | sonic-s6100-dut ansible_host=10.36.79.243 3 | 4 | [sonic_dell64_40:vars] 5 | hwsku="Force10-S6100" 6 | iface_speed='40000' 7 | 8 | [Server_6] 9 | snappi-sonic ansible_host=10.36.78.53 os=snappi 10 | 11 | [sonic:children] 12 | sonic_dell64_40 13 | 14 | [sonic:vars] 15 | mgmt_subnet_mask_length='23' 16 | 17 | [snappi-sonic:children] 18 | sonic 19 | snappi_chassis 20 | 21 | [ptf] 22 | snappi-sonic-ptf ansible_host='10.36.78.96' 23 | -------------------------------------------------------------------------------- /sonic-mgmt-testbed/ansible/group_vars/snappi-sonic/snappi-sonic.yml: -------------------------------------------------------------------------------- 1 | --- 2 | #testlab (lab) group variables 3 | # file: group_vars/lab.yml 4 | 5 | # ntp variables 6 | ntp_servers: ['10.0.0.1', '10.0.0.2'] 7 | 8 | # syslog variables 9 | syslog_servers: ['10.0.0.5', '10.0.0.6'] 10 | 11 | # dns variables 12 | dns_servers: ['10.0.0.5', '10.0.0.6'] 13 | 14 | # forced_mgmt_routes 15 | forced_mgmt_routes: [] 16 | 17 | # ErspanDestinationIpv4 18 | erspan_dest: ['10.0.0.7'] 19 | 20 | radius_servers: [] 21 | 22 | tacacs_servers: ['10.0.0.9', '10.0.0.8'] 23 | 24 | tacacs_passkey: testing123 25 | tacacs_rw_user: test_rwuser 26 | tacacs_rw_user_passwd: '123456' 27 | tacacs_ro_user: test_rouser 28 | tacacs_ro_user_passwd: '123456' 29 | 30 | # tacacs grous 31 | tacacs_group: 'testlab' 32 | 33 | # snmp servers 34 | snmp_servers: ['10.0.0.9'] 35 | 36 | # dhcp relay servers 37 | dhcp_servers: ['192.0.0.1', '192.0.0.2', '192.0.0.3', '192.0.0.4'] 38 | 39 | # snmp variables 40 | snmp_rocommunity: public 41 | snmp_location: testlab 42 | 43 | # bgp slb passive range 44 | bgp_slb_passive_range: 10.255.0.0/25 45 | 46 | #For Arista fanout switch deployment only 47 | fanout_admin_user: "fanoutadminuser" 48 | fanout_admin_password: "fanoutadminpassword" 49 | 50 | secret_group_vars: {snappi_api_server: {user: admin, password: admin, rest_port: 443, session_id: "None"}} 51 | -------------------------------------------------------------------------------- /sonic-mgmt-testbed/ansible/group_vars/lab/lab.yml: -------------------------------------------------------------------------------- 1 | --- 2 | #testlab (lab) group variables 3 | # file: group_vars/lab.yml 4 | 5 | # ntp variables 6 | ntp_servers: ['10.0.0.1', '10.0.0.2'] 7 | 8 | # syslog variables 9 | syslog_servers: ['10.0.0.5', '10.0.0.6'] 10 | #syslog_servers: ['11.11.11.11', '10.0.0.6'] 11 | 12 | # dns variables 13 | dns_servers: ['10.0.0.5', '10.0.0.6'] 14 | 15 | # forced_mgmt_routes 16 | forced_mgmt_routes: [] 17 | 18 | # ErspanDestinationIpv4 19 | erspan_dest: ['10.0.0.7'] 20 | 21 | radius_servers: [] 22 | 23 | tacacs_servers: ['10.0.0.9', '10.0.0.8'] 24 | 25 | tacacs_passkey: testing123 26 | tacacs_rw_user: test_rwuser 27 | tacacs_rw_user_passwd: '123456' 28 | tacacs_ro_user: test_rouser 29 | tacacs_ro_user_passwd: '123456' 30 | 31 | # tacacs grous 32 | tacacs_group: 'testlab' 33 | 34 | # snmp servers 35 | snmp_servers: ['10.0.0.9'] 36 | 37 | # dhcp relay servers 38 | dhcp_servers: ['192.0.0.1', '192.0.0.2', '192.0.0.3', '192.0.0.4'] 39 | 40 | # snmp variables 41 | snmp_rocommunity: public 42 | snmp_location: testlab 43 | 44 | # bgp slb passive range 45 | bgp_slb_passive_range: 10.255.0.0/25 46 | 47 | #For Arista fanout switch deployment only 48 | fanout_admin_user: "fanoutadminuser" 49 | fanout_admin_password: "fanoutadminpassword" 50 | 51 | #For snappi specific entry 52 | secret_group_vars: {snappi_api_server: {user: admin, password: admin, rest_port: 443, session_id: "None"}} 53 | -------------------------------------------------------------------------------- /sonic-mgmt-testbed/ansible/testbed.csv: -------------------------------------------------------------------------------- 1 | # conf-name,group-name,topo,ptf_image_name,ptf,ptf_ip,ptf_ipv6,server,vm_base,dut,comment 2 | ptf1-m,ptf1,ptf32,docker-ptf-sai-mlnx,ptf-unknown,10.255.0.188/24,,server_1,,str-msn2700-01,Test ptf Mellanox 3 | ptf2-b,ptf2,ptf64,docker-ptf-sai-brcm,ptf-unknown,10.255.0.189/24,,server_1,,lab-s6100-01,Test ptf Broadcom 4 | vms-sn2700-t1,vms1-1,t1,docker-ptf-sai-mlnx,ptf-unknown,10.255.0.178/24,,server_1,VM0100,str-msn2700-01,Tests Mellanox SN2700 vms 5 | vms-sn2700-t1-lag,vms1-1,t1-lag,docker-ptf-sai-mlnx,ptf-unknown,10.255.0.178/24,,server_1,VM0100,str-msn2700-01,Tests Mellanox SN2700 vms 6 | vms-sn2700-t0,vms1-1,t0,docker-ptf-sai-mlnx,ptf-unknown,10.255.0.178/24,,server_1,VM0100,str-msn2700-01,Tests Mellanox SN2700 vms 7 | vms-s6000-t0,vms2-1,t0,docker-ptf-sai-brcm,ptf-unknown,10.255.0.179/24,,server_1,VM0100,lab-s6000-01,Tests Dell S6000 vms 8 | vms-a7260-t0,vms3-1,t0-116,docker-ptf-sai-brcm,ptf-unknown,10.255.0.180/24,,server_1,VM0100,lab-a7260-01,Tests Arista A7260 vms 9 | vms-s6100-t0,vms4-1,t0-64,docker-ptf-sai-brcm,ptf-unknown,10.255.0.181/24,,server_1,VM0100,lab-s6100-01,Tests Dell S6100 vms 10 | vms-s6100-t1,vms4-1,t1-64,docker-ptf-sai-brcm,ptf-unknown,10.255.0.182/24,,server_1,VM0100,lab-s6100-01,Tests Dell S6100 vms 11 | vms-s6100-t1-lag,vms5-1,t1-64-lag,docker-ptf-sai-brcm,ptf-unknown,10.255.0.183/24,,server_1,VM0100,lab-s6100-01,Tests Dell S6100 vms 12 | vms-snappi-sonic,vms6-1,t0-64,docker-ptf-snappi,snappi-sonic-ptf,10.36.78.96,,Server_6,VM0600,sonic-s6100-dut,Batman 13 | -------------------------------------------------------------------------------- /sonic-mgmt-testbed/dev-env.sh: -------------------------------------------------------------------------------- 1 | SCRIPT_DIR=`pwd` 2 | DATE_TIME=`date | sed 's/ //g' | sed 's/://g'` 3 | sudo chown -R johnar:gjohnar ~/sonic-mgmt 4 | #cp -rf ~/sonic-mgmt ~/sonic-mgmt-bkp-$DATE_TIME 5 | sudo rm -f ~/sonic-mgmt/ansible/group_vars/all/inv_mapping.yml 6 | sudo rm -f ~/sonic-mgmt/ansible/group_vars/all/inv_mapping.json 7 | sudo rm -f ~/sonic-mgmt/ansible/group_vars/lab/lab.yml 8 | sudo rm -f ~/sonic-mgmt/ansible/testbed.csv 9 | sudo rm -f ~/sonic-mgmt/ansible/files/snappi_sonic_connection_graph.xml 10 | sudo rm -f ~/sonic-mgmt/ansible/files/snappi_sonic_devices.csv 11 | sudo rm -f ~/sonic-mgmt/ansible/files/snappi_sonic_link.csv 12 | sudo rm -rf ~/sonic-mgmt/ansible/group_vars/snappi-sonic/ 13 | sudo rm -f ~/sonic-mgmt/ansible/snappi-sonic 14 | 15 | cp -f $SCRIPT_DIR/ansible/group_vars/all/inv_mapping.yml ~/sonic-mgmt/ansible/group_vars/all/inv_mapping.yml 16 | cp -f $SCRIPT_DIR/ansible/group_vars/all/inv_mapping.json ~/sonic-mgmt/ansible/group_vars/all/inv_mapping.json 17 | cp -f $SCRIPT_DIR/ansible/group_vars/lab/lab.yml ~/sonic-mgmt/ansible/group_vars/lab/lab.yml 18 | cp -f $SCRIPT_DIR/ansible/testbed.csv ~/sonic-mgmt/ansible/testbed.csv 19 | cp -f $SCRIPT_DIR/ansible/files/snappi_sonic_connection_graph.xml ~/sonic-mgmt/ansible/files/snappi_sonic_connection_graph.xml 20 | cp -f $SCRIPT_DIR/ansible/files/snappi_sonic_devices.csv ~/sonic-mgmt/ansible/files/snappi_sonic_devices.csv 21 | cp -f $SCRIPT_DIR/ansible/files/snappi_sonic_link.csv ~/sonic-mgmt/ansible/files/snappi_sonic_link.csv 22 | cp -rf $SCRIPT_DIR/ansible/group_vars/snappi-sonic/ ~/sonic-mgmt/ansible/group_vars/snappi-sonic/ 23 | cp -f $SCRIPT_DIR/ansible/snappi-sonic ~/sonic-mgmt/ansible/snappi-sonic 24 | -------------------------------------------------------------------------------- /sonic-mgmt-testbed/ansible/files/snappi_sonic_connection_graph.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /sonic/sonic_contributing.md: -------------------------------------------------------------------------------- 1 | # How to automate tests using ixia and contribute to sonic-mgmt 2 | 3 | This document intends to achieve the following 4 | - Ways to automate tests with ixia 5 | - Guidelines around test file organization 6 | - How to raise pull requests to sonic-mgmt repo 7 | 8 | ## Automate tests with ixia 9 | There are two ways to automate tests with ixia 10 | 1) using `snappi`(python library) that conforms to open-traffic-generator models. 11 | 2) using `ixnetwork-restpy`(python library) a client side script development tool maps to IxNetwork API tree. 12 | 13 | ## Test file organization 14 | Before writing the tests, make sure the testbed is updated properly as per workflow mentioned here 15 | https://github.com/ANISH-GOTTAPU/sonic-testbed-manager 16 | 17 | 1) using `snappi` 18 | - The `snappi_api` fixture is available in ixia_fixtures. 19 | ``` 20 | tests 21 | |_ common 22 | |_ixia 23 | |_ixia_fixtures.py 24 | |_ixia_helpers.py 25 | |_ ixia 26 | |_bgp 27 | |_ test_bgp_community.py 28 | |_ files 29 | |_ all helpers for the bgp feature 30 | ``` 31 | 32 | 2) using `ixnetwork-restpy` 33 | - The `ixia_api` fixture is available in ixia_fixtures. 34 | - Any new API related to ixia can be added as part of ixia_helpers. 35 | ``` 36 | tests 37 | |_ common 38 | |_ixia 39 | |_ixia_fixtures.py 40 | |_ixia_helpers.py 41 | |_ ixia 42 | |_bgp 43 | |_ test_bgp_community.py 44 | |_ files 45 | |_ all helpers for the bgp feature 46 | ``` 47 | 48 | ## Raise pull requests to sonic-mgmt 49 | * Each developer should fork this repository and [add the team as a Contributor](https://help.github.com/articles/adding-collaborators-to-a-personal-repository) 50 | * Push your changes to your private fork and do "pull-request" to this repository 51 | * Use a pull request to do code review 52 | * Use issues to keep track of what is going on -------------------------------------------------------------------------------- /sonic-mgmt-testbed/README.md: -------------------------------------------------------------------------------- 1 | # SONiC Testbed with Keysight IxNetwork as Traffic Generator 2 | Refer the below document to know about Deployment of Keysight ixNetwork API Server Docker 3 | https://github.com/Azure/sonic-mgmt/blob/master/docs/testbed/README.testbed.Overview.md 4 | 5 | # Workflow to run tests with SONiC Testbed with Keysight IxNetwork 6 | Before going to the workflow please take a look at [basic docker commands to create the sonic-mgmt environment](DockerCommands.md). 7 | 8 | * Load the sonic-mgmt docker image 9 | ``` 10 | sudo docker run -it --name sonic docker-sonic-mgmt 11 | ``` 12 | 13 | * Inside the container clone the forked version of sonic-mgmt(https://github.com/Azure/sonic-mgmt.git) 14 | 15 | * Inside the container clone docs repo.(https://github.com/open-traffic-generator/docs.git) 16 | * Update the following files 17 | - ptf-ip for ptf(snappi-sonic-ptf) in sonic-mgmt-testbed/ansible/testbed.csv 18 | - ansible_host ips for DUT, Chassis & PTF in sonic-mgmt-testbed/ansible/snappi-sonic 19 | - Interface links in sonic-mgmt-testbed/ansible/files/snappi_sonic_connection_graph.xml 20 | - links in sonic-mgmt-testbed/ansible/files/snappi_sonic_link.csv 21 | - ManagementIp in sonic-mgmt-testbed/ansible/files/snappi_sonic_devices.csv 22 | - DUT ansible password in sonic-mgmt-testbed/ansible/group-vars/snappi-sonic/secrets.yml 23 | 24 | * Run the script dev-env.sh from the directory /var/johnar/docs/sonic-mgmt-testbed, running this script 25 | updates the testbed files needed for the test to run with Keysight ixNetwork 26 | ``` 27 | cd /var/johnar/docs/sonic-mgmt-testbed 28 | sh ./dev-env.sh 29 | ``` 30 | 31 | * To Run a single test using pytest 32 | * Add environment variables and run the test 33 | ``` 34 | cd ~/sonic-mgmt/tests/ 35 | export ANSIBLE_CONFIG=../ansible 36 | export ANSIBLE_LIBRARY=../ansible 37 | ``` 38 | ``` 39 | py.test --inventory ../ansible/snappi-sonic --host-pattern sonic-s6100-dut --testbed vms-snappi-sonic --testbed_file ../ansible/testbed.csv --show-capture=stdout --log-cli- level info --showlocals -ra --allow_recover --skip_sanity --disable_loganalyzer snappi/test_snappi.py 40 | ``` 41 | 42 | * For Batch runs and nightly tests etc.., please refer to https://github.com/Azure/sonic-mgmt/blob/master/docs/tests/pytest.run.md 43 | -------------------------------------------------------------------------------- /sonic-mgmt-testbed/DockerCommands.md: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | * An Ubuntu Linux box 3 | * The sonic docker image in your home directory. 4 | * Pre-built sonic-mgmt can also be downloaded from [here](https://sonic-jenkins.westus2.cloudapp.azure.com/job/bldenv/job/docker-sonic-mgmt/lastSuccessfulBuild/artifact/sonic-buildimage/target/docker-sonic-mgmt.gz) 5 | * Basic knowledge of docker commands. 6 | * Docker-tools should be there installed in your system. 7 | # sonic-mgmt docker environment preparation: useful commands (for Ubuntu system) 8 | * Installing docker 9 | ``` 10 | sudo apt-get update 11 | sudo apt-get remove docker docker-engine docker.io 12 | sudo apt install docker.io 13 | sudo systemctl start docker 14 | sudo systemctl enable docker 15 | ``` 16 | 17 | * Unzip sonic Image 18 | ``` 19 | gzip -d docker-sonic-mgmt.gz 20 | ``` 21 | 22 | * Load the docker Image 23 | ``` 24 | sudo docker images 25 | sudo docker load -i docker-sonic-mgmt 26 | sudo docker run -it --name sonic docker-sonic-mgmt 27 | ``` 28 | 29 | * Stopping a docker session 30 | ``` 31 | sudo docker stop sonic 32 | ``` 33 | 34 | * Reconnect to a stopped docker session 35 | ``` 36 | sudo docker start -i sonic 37 | ``` 38 | 39 | * When you are done you may remove the image sonic 40 | ``` 41 | sudo docker rm sonic 42 | ``` 43 | 44 | * Remove docker by image Id 45 | ``` 46 | sudo docker rmi -f 47 | ``` 48 | 49 | * Running a sonic docker with local directory mounted in it. 50 | ``` 51 | sudo docker run -it --name sonic --privileged -v /home/ubuntu/adhar/:/var/johnar/adhar --workdir /var/johnar/adhar --user johnar:gjohnar docker-sonic-mgmt 52 | ``` 53 | 54 | 55 | # How to run a docker with a port number 56 | * Run a docker container with port number -p 57 | * -itd will run docker in a detached state, using port 2222 for example you can use any port 58 | ``` 59 | sudo docker run -itd --name sonic -p 2222:22 docker-sonic-mgmt 60 | ``` 61 | 62 | * Enter the docker container using exec 63 | ``` 64 | sudo docker exec -it sonic bash 65 | ``` 66 | 67 | * Check ssh service is running inside the docker 68 | ``` 69 | johnar@1ed3a9afe70f:~$ service --status-all 70 | ``` 71 | 72 | * If ssh service is not running restart ssh service 73 | ``` 74 | johnar@1ed3a9afe70f:~$ sudo service ssh start 75 | ``` 76 | 77 | * Update johnar user passwd, update passwd of your choice 78 | ``` 79 | johnar@1ed3a9afe70f:~$ sudo passwd johnar 80 | ``` 81 | 82 | * Use ssh from any machine in the network to login to docker directly 83 | ``` 84 | ssh johnar@10.39.71.246 -p 2222 85 | ``` 86 | 87 | 88 | 89 | 90 | 91 | --------------------------------------------------------------------------------