1*** Settings ***
2Documentation  Network stack stress tests using "nping" tool.
3
4# This Suite has few testcases which uses nping with ICMP.
5# ICMP creates a raw socket, which requires root privilege/sudo to run tests.
6
7Resource                ../lib/resource.robot
8Resource                ../lib/bmc_redfish_resource.robot
9Resource                ../lib/ipmi_client.robot
10
11Library                 OperatingSystem
12Library                 String
13Library                 ../lib/gen_robot_valid.py
14Library                 ../lib/bmc_network_utils.py
15Library                 ../lib/ipmi_utils.py
16
17Suite Setup             Suite Setup Execution
18
19Force Tags              Network_Nping
20
21*** Variables ***
22
23${delay}                1000ms
24${count}                4
25${program_name}         nping
26${iterations}           5000
27
28*** Test Cases ***
29
30Send ICMP Timestamp Request
31    [Documentation]  Send ICMP packet type 13 and check BMC drops such packets
32    [Tags]  Send_ICMP_Timestamp_Request
33
34    # Send ICMP packet type 13 to BMC and check packet loss.
35    ${packet_loss}=  Send Network Packets And Get Packet Loss
36    ...  ${OPENBMC_HOST}  ${count}  ${ICMP_PACKETS}  ${NETWORK_PORT}  ${ICMP_TIMESTAMP_REQUEST}
37    Should Be Equal As Numbers  ${packet_loss}  100.00
38    ...  msg=FAILURE: BMC is not dropping timestamp request messages.
39
40Send ICMP Netmask Request
41    [Documentation]  Send ICMP packet type 17 and check BMC drops such packets
42    [Tags]  Send_ICMP_Netmask_Request
43
44    # Send ICMP packet type 17 to BMC and check packet loss.
45    ${packet_loss}=  Send Network Packets And Get Packet Loss
46    ...  ${OPENBMC_HOST}  ${count}  ${ICMP_PACKETS}  ${NETWORK_PORT}  ${ICMP_NETMASK_REQUEST}
47    Should Be Equal As Numbers  ${packet_loss}  100.00
48    ...  msg=FAILURE: BMC is not dropping netmask request messages.
49
50Send Continuous ICMP Echo Request To BMC And Verify No Packet Loss
51    [Documentation]  Send ICMP packet type 8 continuously and check no packets are dropped from BMC
52    [Tags]  Send_Continuous_ICMP_Echo_Request_To_BMC_And_Verify_No_Packet_Loss
53
54    # Send ICMP packet type 8 to BMC and check packet loss.
55    ${packet_loss}=  Send Network Packets And Get Packet Loss
56    ...  ${OPENBMC_HOST}  ${iterations}  ${ICMP_PACKETS}
57    Should Be Equal As Numbers  ${packet_loss}  0.0
58    ...  msg=FAILURE: BMC is dropping packets.
59
60Send Network Packets Continuously To Redfish Interface
61    [Documentation]  Send network packets continuously to Redfish interface and verify stability.
62    [Tags]  Send_Network_Packets_Continuously_To_Redfish_Interface
63
64    # Send large number of packets to Redfish interface.
65    ${packet_loss}=  Send Network Packets And Get Packet Loss
66    ...  ${OPENBMC_HOST}  ${iterations}  ${TCP_PACKETS}  ${REDFISH_INTERFACE}
67    Should Be Equal As Numbers  ${packet_loss}  0.0
68    ...  msg=FAILURE: BMC is dropping some packets.
69
70    # Check if Redfish interface is functional.
71    Redfish.Login
72    Redfish.Logout
73
74
75Send Network Packets Continuously To IPMI Port
76    [Documentation]  Send network packets continuously to IPMI port and verify stability.
77    [Tags]  Send_Network_Packets_Continuously_To_IPMI_Port
78
79    # Send large number of packets to IPMI port.
80    ${packet_loss}=  Send Network Packets And Get Packet Loss
81    ...  ${OPENBMC_HOST}  ${iterations}  ${TCP_PACKETS}  ${IPMI_PORT}
82    Should Be Equal As Numbers  ${packet_loss}  0.0
83    ...  msg=FAILURE: BMC is dropping some packets.
84
85    # Check if IPMI interface is functional.
86    Run IPMI Standard Command  chassis status
87
88
89Send Network Packets Continuously To SSH Port
90    [Documentation]  Send network packets continuously to SSH port and verify stability.
91    [Tags]  Send_Network_Packets_Continuously_To_SSH_Port
92
93    # Send large number of packets to SSH port.
94    ${packet_loss}=  Send Network Packets And Get Packet Loss
95    ...  ${OPENBMC_HOST}  ${iterations}  ${TCP_PACKETS}  ${SSH_PORT}
96    Should Be Equal As Numbers  ${packet_loss}  0.0
97    ...  msg=FAILURE: BMC is dropping some packets.
98
99    # Check if SSH interface is functional.
100
101    SSHLibrary.Open Connection  ${OPENBMC_HOST}
102    Open Connection And Log In  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}
103
104
105Flood Redfish Interface With Packets With Flags And Check Stability
106    [Documentation]  Send large number of packets with flags to Redfish interface
107    ... and check stability.
108    [Tags]  Flood_Redfish_Interface_With_Packets_With_Flags_And_Check_Stability
109    [Template]  Send Network Packets With Flags And Verify Stability
110
111    # Target         No. Of packets  Interface              Flags
112
113    # Flood syn packets and check BMC behavior.
114    ${OPENBMC_HOST}  ${iterations}   ${REDFISH_INTERFACE}   ${SYN_PACKETS}
115
116    # Flood reset packets and check BMC behavior.
117    ${OPENBMC_HOST}  ${iterations}   ${REDFISH_INTERFACE}   ${RESET_PACKETS}
118
119    # Flood fin packets and check BMC behavior.
120    ${OPENBMC_HOST}  ${iterations}   ${REDFISH_INTERFACE}   ${FIN_PACKETS}
121
122    # Flood syn ack reset packets and check BMC behavior.
123    ${OPENBMC_HOST}  ${iterations}   ${REDFISH_INTERFACE}   ${SYN_ACK_RESET}
124
125    # Flood packets with all flags and check BMC behavior.
126    ${OPENBMC_HOST}  ${iterations}   ${REDFISH_INTERFACE}   ${ALL_FLAGS}
127
128
129*** Keywords ***
130
131Suite Setup Execution
132    [Documentation]  Validate the setup.
133
134    Valid Value  OPENBMC_HOST
135    Valid Program  program_name
136
137
138Verify Interface Stability
139    [Documentation]  Verify interface is up and active.
140    [Arguments]  ${port}
141
142    # Description of argument(s):
143    # port  Network port.
144
145    Run Keyword If  ${port} == ${REDFISH_INTERFACE}
146    ...  Redfish.Login
147    ...  ELSE IF  ${port} == ${SSH_PORT}
148    ...  Open Connection And Log In  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}
149    ...  ELSE IF  ${port} == ${IPMI_PORT}
150    ...  Run External IPMI Standard Command lan print
151    ...  ELSE IF  ${port} == ${HOST_SOL_PORT}
152    ...  Open Connection And Log In  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}  port=${HOST_SOL_PORT}
153    ...  ELSE
154    ...  Redfish.Login
155