Prashanth Katti | 01293ef | 2017-02-16 08:20:20 -0600 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Network stack stress tests using "nping" tool. |
| 3 | |
Sandhya Somashekar | 839a0c2 | 2019-01-31 05:05:43 -0600 | [diff] [blame] | 4 | Resource ../lib/resource.robot |
Prashanth Katti | 01293ef | 2017-02-16 08:20:20 -0600 | [diff] [blame] | 5 | |
| 6 | Library OperatingSystem |
| 7 | Library String |
| 8 | |
Steven Sombar | fac31e9 | 2017-12-15 09:40:34 -0600 | [diff] [blame] | 9 | Suite Setup Suite Setup Execution |
Prashanth Katti | 01293ef | 2017-02-16 08:20:20 -0600 | [diff] [blame] | 10 | |
Sweta Potthuri | b2c50f1 | 2017-06-28 03:53:30 -0500 | [diff] [blame] | 11 | Force Tags Network_Nping |
| 12 | |
Prashanth Katti | 01293ef | 2017-02-16 08:20:20 -0600 | [diff] [blame] | 13 | *** Variables *** |
| 14 | |
| 15 | ${delay} 200ms |
| 16 | ${count} 100 |
| 17 | ${bmc_packet_loss} ${EMPTY} |
| 18 | |
| 19 | *** Test Cases *** |
| 20 | |
| 21 | Verify Zero Network Packet Loss On BMC |
| 22 | [Documentation] Pump network packets to target. |
| 23 | [Tags] Verify_Zero_Network_Packet_Loss_On_BMC |
| 24 | |
| 25 | # Send packets to BMC and check packet loss. |
| 26 | ${bmc_packet_loss}= Send Network Packets |
| 27 | ... ${OPENBMC_HOST} ${PACKET_TYPE} ${NETWORK_PORT} |
| 28 | Should Contain |
| 29 | ... ${bmc_packet_loss} Lost: 0 (0.00%) msg=Fail, Packet loss on BMC. |
| 30 | |
| 31 | *** Keywords *** |
| 32 | |
Steven Sombar | fac31e9 | 2017-12-15 09:40:34 -0600 | [diff] [blame] | 33 | Suite Setup Execution |
Prashanth Katti | 01293ef | 2017-02-16 08:20:20 -0600 | [diff] [blame] | 34 | [Documentation] Validate the setup. |
| 35 | |
| 36 | Should Not Be Empty ${OPENBMC_HOST} msg=BMC IP address not provided. |
| 37 | ${output}= Run which nping |
| 38 | Should Not Be Empty ${output} msg="nping" tool not installed. |
| 39 | |
| 40 | Send Network Packets |
| 41 | [Documentation] Send TCP, UDP or ICMP packets to the target. |
| 42 | [Arguments] ${host} ${packet_type}=tcp ${port}=80 |
| 43 | |
| 44 | # Description of arguments: |
| 45 | # ${host}- Target system to which network packets to be sent. |
| 46 | # ${packet_type}- type of packets to be sent viz tcp, udp or icmp. |
| 47 | # ${port}- Network port. |
| 48 | |
| 49 | # This program expects host, port, type and number of packets to be sent |
Gunnar Mills | 917ba1a | 2018-04-08 16:42:12 -0500 | [diff] [blame] | 50 | # and rate at which packets to be sent, should be given in command line |
Prashanth Katti | 01293ef | 2017-02-16 08:20:20 -0600 | [diff] [blame] | 51 | # by default it sends 100 TCP packets at 5 packets/second. |
| 52 | |
| 53 | ${cmd_buff}= Run Keyword If '${packet_type}' == 'icmp' |
manimozhik | 5beee8a | 2023-11-08 18:55:34 +0000 | [diff] [blame] | 54 | ... Set Variable |
| 55 | ... echo ${CLIENT_PASSWORD} | sudo -S nping --delay ${delay} ${host} -c ${count} --${packet_type} |
Prashanth Katti | 01293ef | 2017-02-16 08:20:20 -0600 | [diff] [blame] | 56 | ... ELSE |
| 57 | ... Set variable |
manimozhik | 5beee8a | 2023-11-08 18:55:34 +0000 | [diff] [blame] | 58 | ... echo ${CLIENT_PASSWORD} | sudo -S nping --delay ${delay} ${host} -c ${count} -p ${port} --${packet_type} |
Prashanth Katti | 01293ef | 2017-02-16 08:20:20 -0600 | [diff] [blame] | 59 | ${rc} ${output} Run And Return RC And Output ${cmd_buff} |
| 60 | Should Be Equal As Integers ${rc} 0 msg=Command execution failed. |
| 61 | ${packet_loss} Get Packet Loss ${host} ${output} |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 62 | RETURN ${packet_loss} |
Prashanth Katti | 01293ef | 2017-02-16 08:20:20 -0600 | [diff] [blame] | 63 | |
| 64 | Get Packet Loss |
| 65 | [Documentation] Check packet loss percentage. |
| 66 | |
| 67 | # Sample Output from "nping" command: |
| 68 | # Starting Nping 0.6.47 ( http://nmap.org/nping ) at 2017-02-21 22:05 IST |
Joy Onyerikwu | f4a807b | 2018-06-20 08:43:54 -0500 | [diff] [blame] | 69 | # SENT (0.0181s) TCP Source IP:37577 > |
| 70 | # Destination IP:80 S ttl=64 id=39113 iplen=40 seq=629782493 win=1480 |
| 71 | # SENT (0.2189s) TCP Source IP:37577 > |
| 72 | # Destination IP:80 S ttl=64 id=39113 iplen=40 seq=629782493 win=1480 |
| 73 | # RCVD (0.4120s) TCP Destination IP:80 > |
| 74 | # Source IP:37577 SA ttl=49 id=0 iplen=44 seq=1078301364 win=5840 <mss 1380> |
Prashanth Katti | 01293ef | 2017-02-16 08:20:20 -0600 | [diff] [blame] | 75 | # Max rtt: 193.010ms | Min rtt: 193.010ms | Avg rtt: 193.010ms |
| 76 | # Raw packets sent: 2 (80B) | Rcvd: 1 (46B) | Lost: 1 (50.00%) |
| 77 | # Nping done: 1 IP address pinged in 0.43 seconds |
| 78 | |
| 79 | [Arguments] ${host} ${traffic_details} |
| 80 | |
| 81 | # Description of arguments: |
| 82 | # ${host}- System on which packet loss to be checked. |
| 83 | # ${traffic_details}- Details of the network traffic sent. |
| 84 | |
| 85 | ${summary}= Get Lines Containing String ${traffic_details} Rcvd: |
| 86 | Log To Console \nPacket loss summary on ${host}\n********************* |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame] | 87 | RETURN ${summary} |