xref: /openbmc/openbmc-test-automation/network/test_network_nping.robot (revision 6fb70d98f2f1cb9273ba912deaa2cebe3c23ea86)
1f0199a08SGeorge Keishing*** Settings ***
2f0199a08SGeorge KeishingDocumentation  Network stack stress tests using "nping" tool.
3f0199a08SGeorge Keishing
4839a0c27SSandhya SomashekarResource  ../lib/resource.robot
5f0199a08SGeorge Keishing
6f0199a08SGeorge KeishingLibrary  OperatingSystem
7f0199a08SGeorge KeishingLibrary  String
8f0199a08SGeorge Keishing
9f0199a08SGeorge KeishingSuite Setup  Suite Setup Execution
10f0199a08SGeorge Keishing
11*6fb70d98SMatt FischerTest Tags  Network_Nping
12f0199a08SGeorge Keishing
13f0199a08SGeorge Keishing*** Variables ***
14f0199a08SGeorge Keishing
15f0199a08SGeorge Keishing${delay}             200ms
16f0199a08SGeorge Keishing${count}             100
17f0199a08SGeorge Keishing${bmc_packet_loss}   ${EMPTY}
18f0199a08SGeorge Keishing
19f0199a08SGeorge Keishing*** Test Cases ***
20f0199a08SGeorge Keishing
21f0199a08SGeorge KeishingVerify Zero Network Packet Loss On BMC
22f0199a08SGeorge Keishing    [Documentation]  Pump network packets to target.
23f0199a08SGeorge Keishing    [Tags]  Verify_Zero_Network_Packet_Loss_On_BMC
24f0199a08SGeorge Keishing
25f0199a08SGeorge Keishing    # Send packets to BMC and check packet loss.
26f0199a08SGeorge Keishing    ${bmc_packet_loss}=  Send Network Packets
27f0199a08SGeorge Keishing    ...  ${OPENBMC_HOST}  ${PACKET_TYPE}  ${NETWORK_PORT}
28f0199a08SGeorge Keishing    Should Contain
29f0199a08SGeorge Keishing    ...  ${bmc_packet_loss}  Lost: 0 (0.00%)  msg=Fail, Packet loss on BMC.
30f0199a08SGeorge Keishing
31f0199a08SGeorge Keishing*** Keywords ***
32f0199a08SGeorge Keishing
33f0199a08SGeorge KeishingSuite Setup Execution
34f0199a08SGeorge Keishing    [Documentation]  Validate the setup.
35f0199a08SGeorge Keishing
36f0199a08SGeorge Keishing    Should Not Be Empty  ${OPENBMC_HOST}  msg=BMC IP address not provided.
37f0199a08SGeorge Keishing    ${output}=  Run  which nping
38f0199a08SGeorge Keishing    Should Not Be Empty  ${output}  msg="nping" tool not installed.
39f0199a08SGeorge Keishing
40f0199a08SGeorge KeishingSend Network Packets
41f0199a08SGeorge Keishing    [Documentation]  Send TCP, UDP or ICMP packets to the target.
42f0199a08SGeorge Keishing    [Arguments]  ${host}  ${packet_type}=tcp  ${port}=80
43f0199a08SGeorge Keishing
44f0199a08SGeorge Keishing    # Description of arguments:
45f0199a08SGeorge Keishing    # ${host}- Target system to which network packets to be sent.
46f0199a08SGeorge Keishing    # ${packet_type}- type of packets to be sent viz tcp, udp or icmp.
47f0199a08SGeorge Keishing    # ${port}- Network port.
48f0199a08SGeorge Keishing
49f0199a08SGeorge Keishing    # This program expects host, port, type and number of packets to be sent
50f0199a08SGeorge Keishing    # and rate at which packets to be sent, should be given in command line
51f0199a08SGeorge Keishing    # by default it sends 100 TCP packets at 5 packets/second.
52f0199a08SGeorge Keishing
53f0199a08SGeorge Keishing    ${cmd_buff}=  Run Keyword If  '${packet_type}' == 'icmp'
545beee8a0Smanimozhik    ...  Set Variable
555beee8a0Smanimozhik    ...  echo ${CLIENT_PASSWORD} | sudo -S nping --delay ${delay} ${host} -c ${count} --${packet_type}
56f0199a08SGeorge Keishing    ...  ELSE
57f0199a08SGeorge Keishing    ...  Set variable
585beee8a0Smanimozhik    ...  echo ${CLIENT_PASSWORD} | sudo -S nping --delay ${delay} ${host} -c ${count} -p ${port} --${packet_type}
59f0199a08SGeorge Keishing    ${rc}  ${output}  Run And Return RC And Output  ${cmd_buff}
60f0199a08SGeorge Keishing    Should Be Equal As Integers  ${rc}  0  msg=Command execution failed.
61f0199a08SGeorge Keishing    ${packet_loss}  Get Packet Loss  ${host}  ${output}
62409df05dSGeorge Keishing    RETURN  ${packet_loss}
63f0199a08SGeorge Keishing
64f0199a08SGeorge KeishingGet Packet Loss
65f0199a08SGeorge Keishing    [Documentation]  Check packet loss percentage.
66f0199a08SGeorge Keishing
67f0199a08SGeorge Keishing    # Sample Output from "nping" command:
68f0199a08SGeorge Keishing    # Starting Nping 0.6.47 ( http://nmap.org/nping ) at 2017-02-21 22:05 IST
69f4a807bfSJoy Onyerikwu    # SENT (0.0181s) TCP Source IP:37577 >
70f4a807bfSJoy Onyerikwu    #   Destination IP:80 S ttl=64 id=39113 iplen=40  seq=629782493 win=1480
71f4a807bfSJoy Onyerikwu    # SENT (0.2189s) TCP Source IP:37577 >
72f4a807bfSJoy Onyerikwu    #   Destination IP:80 S ttl=64 id=39113 iplen=40  seq=629782493 win=1480
73f4a807bfSJoy Onyerikwu    # RCVD (0.4120s) TCP Destination IP:80 >
74f4a807bfSJoy Onyerikwu    #   Source IP:37577 SA ttl=49 id=0 iplen=44  seq=1078301364 win=5840 <mss 1380>
75f0199a08SGeorge Keishing    # Max rtt: 193.010ms | Min rtt: 193.010ms | Avg rtt: 193.010ms
76f0199a08SGeorge Keishing    # Raw packets sent: 2 (80B) | Rcvd: 1 (46B) | Lost: 1 (50.00%)
77f0199a08SGeorge Keishing    # Nping done: 1 IP address pinged in 0.43 seconds
78f0199a08SGeorge Keishing
79f0199a08SGeorge Keishing    [Arguments]  ${host}  ${traffic_details}
80f0199a08SGeorge Keishing
81f0199a08SGeorge Keishing    # Description of arguments:
82f0199a08SGeorge Keishing    # ${host}- System on which packet loss to be checked.
83f0199a08SGeorge Keishing    # ${traffic_details}- Details of the network traffic sent.
84f0199a08SGeorge Keishing
85f0199a08SGeorge Keishing    ${summary}=  Get Lines Containing String  ${traffic_details}  Rcvd:
86f0199a08SGeorge Keishing    Log To Console  \nPacket loss summary on ${host}\n*********************
87409df05dSGeorge Keishing    RETURN  ${summary}
88