blob: 4cef11cbfdca8e94ab18439dcd0d99fd1bc54b27 [file] [log] [blame]
Prashanth Katti081b3d92018-06-15 05:13:11 -05001*** Settings ***
Naman Navin Hegdebf181332019-06-26 02:08:18 -05002Documentation This testing requires special setup where SNMP trapd is
Prashanth Katti081b3d92018-06-15 05:13:11 -05003... configured and installed. For download, installation and
4... configuration refer http://www.net-snmp.org/.
5
George Keishing9e5626d2024-03-26 11:40:20 +05306Resource ../../lib/snmp/resource.robot
7Resource ../../lib/snmp/snmp_utils.robot
8Resource ../../lib/openbmc_ffdc.robot
9Resource ../../lib/logging_utils.robot
Prashanth Katti081b3d92018-06-15 05:13:11 -050010
George Keishing9e5626d2024-03-26 11:40:20 +053011Library String
12Library SSHLibrary
Prashanth Katti081b3d92018-06-15 05:13:11 -050013
George Keishing9e5626d2024-03-26 11:40:20 +053014Test Teardown FFDC On Test Case Fail
Prashanth Katti7dae0e82019-01-09 01:35:42 -060015
George Keishing9e5626d2024-03-26 11:40:20 +053016Force Tags BMC_SNMP_Config
George Keishing87dc4422023-10-20 12:56:30 +053017
Anves Kumar rayankula9d385de2021-03-09 23:25:28 -060018*** Variables ***
19
20${CMD_INTERNAL_FAILURE} busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
21... xyz.openbmc_project.Logging.Create Create ssa{ss} xyz.openbmc_project.Common.Error.InternalFailure
22... xyz.openbmc_project.Logging.Entry.Level.Error 0
23
24${CMD_FRU_CALLOUT} busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
25... xyz.openbmc_project.Logging.Create Create ssa{ss} xyz.openbmc_project.Common.Error.Timeout
26... xyz.openbmc_project.Logging.Entry.Level.Error 2 "TIMEOUT_IN_MSEC" "5"
27... "CALLOUT_INVENTORY_PATH" "/xyz/openbmc_project/inventory/system/chassis/motherboard"
28
29${CMD_INFORMATIONAL_ERROR} busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging
30... xyz.openbmc_project.Logging.Create Create ssa{ss} xyz.openbmc_project.Common.Error.TestError2
31... xyz.openbmc_project.Logging.Entry.Level.Informational 0
32
33${CMD_DEBUG_TRABALL_ERROR}= /tmp/tarball/bin/logging-test -c AutoTestSimple
34${SNMP_TRAP_BMC_INTERNAL_FAILURE} xyz.openbmc_project.Common.Error.InternalFailure
35${SNMP_TRAP_BMC_CALLOUT_ERROR} xyz.openbmc_project.Common.Error.Timeout
36${SNMP_TRAP_BMC_INFORMATIONAL_ERROR} xyz.openbmc_project.Common.Error.TestError2
37
Prashanth Katti081b3d92018-06-15 05:13:11 -050038*** Test Cases ***
39Configure SNMP Manager On BMC And Verify
40 [Documentation] Configure SNMP Manager On BMC And Verify.
41 [Tags] Configure_SNMP_Manager_On_BMC_And_Verify
42
43 Configure SNMP Manager On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} Valid
44 Verify SNMP Manager ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
45
46 Delete SNMP Manager And Object ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
47
George Keishingb98036a2022-01-31 12:39:47 -060048Configure SNMP Manager On BMC With Non Default Port And Verify
Prashanth Katti081b3d92018-06-15 05:13:11 -050049 [Documentation] Configure SNMP Manager On BMC And Verify.
50 [Tags] Configure_SNMP_Manager_On_BMC_With_Non_Default_Port_And_Verify
51
52 Configure SNMP Manager On BMC ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1} Valid
53 Verify SNMP Manager ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1}
54
55 Delete SNMP Manager And Object ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1}
56
57Configure SNMP Manager On BMC With Out Of Range Port And Verify
Prashanth Katti081b3d92018-06-15 05:13:11 -050058 [Documentation] Configure SNMP Manager On BMC with out-of range port and verify.
59 [Tags] Configure_SNMP_Manager_On_BMC_With_Out_Of_Range_Port_And_Verify
Prashanth Katti081b3d92018-06-15 05:13:11 -050060 [Template] Configure SNMP Manager On BMC
61
George Keishing5abfe602018-07-05 11:54:37 -050062 # SNMP manager IP Port Scenario
63 ${SNMP_MGR1_IP} ${out_of_range_port} error
64
Prashanth Katti081b3d92018-06-15 05:13:11 -050065Configure SNMP Manager On BMC With Alpha Port And Verify
Prashanth Katti081b3d92018-06-15 05:13:11 -050066 [Documentation] Configure SNMP Manager On BMC with alpha port and verify.
67 [Tags] Configure_SNMP_Manager_On_BMC_With_Alpha_Port_And_Verify
Prashanth Katti081b3d92018-06-15 05:13:11 -050068 [Template] Configure SNMP Manager On BMC
69
George Keishing5abfe602018-07-05 11:54:37 -050070 # SNMP manager IP Port Scenario
71 ${SNMP_MGR1_IP} ${alpha_port} error
72
Prashanth Katti081b3d92018-06-15 05:13:11 -050073Configure SNMP Manager On BMC With Negative Port And Verify
Prashanth Katti081b3d92018-06-15 05:13:11 -050074 [Documentation] Configure SNMP Manager On BMC with negative port and verify.
75 [Tags] Configure_SNMP_Manager_On_BMC_With_Negative_Port_And_Verify
Prashanth Katti081b3d92018-06-15 05:13:11 -050076 [Template] Configure SNMP Manager On BMC
77
George Keishing5abfe602018-07-05 11:54:37 -050078 # SNMP manager IP Port Scenario
79 ${SNMP_MGR1_IP} ${negative_port} error
80
Prashanth Katti081b3d92018-06-15 05:13:11 -050081Configure SNMP Manager On BMC With Empty Port And Verify
Prashanth Katti081b3d92018-06-15 05:13:11 -050082 [Documentation] Configure SNMP Manager On BMC with empty port and verify.
83 [Tags] Configure_SNMP_Manager_On_BMC_With_Empty_Port_And_Verify
Prashanth Katti081b3d92018-06-15 05:13:11 -050084 [Template] Configure SNMP Manager On BMC
85
George Keishing5abfe602018-07-05 11:54:37 -050086 # SNMP manager IP Port Scenario
87 ${SNMP_MGR1_IP} ${empty_port} error
88
Prashanth Katti081b3d92018-06-15 05:13:11 -050089Configure SNMP Manager On BMC With Out Of Range IP And Verify
Prashanth Katti081b3d92018-06-15 05:13:11 -050090 [Documentation] Configure SNMP Manager On BMC with out-of range IP and verify.
91 [Tags] Configure_SNMP_Manager_On_BMC_With_Out_Of_Range_IP_And_Verify
Prashanth Katti081b3d92018-06-15 05:13:11 -050092 [Template] Configure SNMP Manager On BMC
93
George Keishing5abfe602018-07-05 11:54:37 -050094 # SNMP manager IP Port Scenario
95 ${out_of_range_ip} ${SNMP_DEFAULT_PORT} error
96
Prashanth Katti081b3d92018-06-15 05:13:11 -050097Configure Multiple SNMP Managers And Verify
98 [Documentation] Configure multiple SNMP Managers And Verify.
99 [Tags] Configure_Multiple_SNMP_Managers_And_Verify
100
101 Configure SNMP Manager On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} Valid
102 Configure SNMP Manager On BMC ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT} Valid
103 Verify SNMP Manager ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
104 Verify SNMP Manager ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT}
105
106 Delete SNMP Manager And Object ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
107 Delete SNMP Manager And Object ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT}
108
George Keishingb98036a2022-01-31 12:39:47 -0600109Configure Multiple SNMP Managers With Non Default Port And Verify
Prashanth Katti081b3d92018-06-15 05:13:11 -0500110 [Documentation] Configure multiple SNMP Managers with non-default port And Verify.
111 [Tags] Configure_Multiple_SNMP_Managers_With_Non_Default_Port_And_Verify
112
113 Configure SNMP Manager On BMC ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1} Valid
114 Configure SNMP Manager On BMC ${SNMP_MGR2_IP} ${NON_DEFAULT_PORT1} Valid
115 Verify SNMP Manager ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1}
116 Verify SNMP Manager ${SNMP_MGR2_IP} ${NON_DEFAULT_PORT1}
117
118 Delete SNMP Manager And Object ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1}
119 Delete SNMP Manager And Object ${SNMP_MGR2_IP} ${NON_DEFAULT_PORT1}
120
121Configure Multiple SNMP Managers With Different Ports And Verify
122 [Documentation] Configure multiple SNMP Managers with different ports And Verify.
123 [Tags] Configure_Multiple_SNMP_Managers_With_Different_Ports_And_Verify
124
125 Configure SNMP Manager On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} Valid
126 Configure SNMP Manager On BMC ${SNMP_MGR2_IP} ${NON_DEFAULT_PORT1} Valid
127 Configure SNMP Manager On BMC ${SNMP_MGR3_IP} ${NON_DEFAULT_PORT2} Valid
128
129 Verify SNMP Manager ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
130 Verify SNMP Manager ${SNMP_MGR2_IP} ${NON_DEFAULT_PORT1}
131 Verify SNMP Manager ${SNMP_MGR3_IP} ${NON_DEFAULT_PORT2}
132
133 Delete SNMP Manager And Object ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
134 Delete SNMP Manager And Object ${SNMP_MGR2_IP} ${NON_DEFAULT_PORT1}
135 Delete SNMP Manager And Object ${SNMP_MGR3_IP} ${NON_DEFAULT_PORT2}
136
Naman Navin Hegdebf181332019-06-26 02:08:18 -0500137Generate Error On BMC And Verify If Trap Is Sent
138 [Documentation] Generate Error On BMC And Verify If Trap Is Sent.
139 [Tags] Generate_Error_On_BMC_And_Verify_If_Trap_Is_Sent
140 [Setup] Install Tarball
Anves Kumar rayankula9d385de2021-03-09 23:25:28 -0600141 [Template] Create Error On BMC And Verify If Trap Is Sent
142
143 # event_log expected_error
144 ${CMD_DEBUG_TRABALL_ERROR} ${SNMP_TRAP_BMC_ERROR}
145
146Generate Error On BMC And Verify Trap On SNMP
147 [Documentation] Generate error on bmc and verify trap on SNMP.
148 [Tags] Generate_Error_On_BMC_And_Verify_Trap_On_SNMP
149 [Template] Create Error On BMC And Verify If Trap Is Sent
150
151 # event_log expected_error
152 ${CMD_INTERNAL_FAILURE} ${SNMP_TRAP_BMC_INTERNAL_FAILURE}
153 ${CMD_FRU_CALLOUT} ${SNMP_TRAP_BMC_CALLOUT_ERROR}
154 ${CMD_INFORMATIONAL_ERROR} ${SNMP_TRAP_BMC_INFORMATIONAL_ERROR}
155
Anves Kumar rayankulabce13df2021-04-09 06:58:51 -0500156Configure SNMP Manager With Less Octet IP And Verify
157 [Documentation] Configure SNMP manager on BMC with less octet IP and verify.
158 [Tags] Configure_SNMP_Manager_With_Less_Octet_IP_And_Verify
159 [Template] Configure SNMP Manager On BMC
160
161 # SNMP manager IP Port Scenario
162 10.10.10 ${SNMP_DEFAULT_PORT} error
163
Prashanth Katti04b9ab92021-06-03 08:54:35 -0500164Verify SNMP SysUpTime
165 [Documentation] Verify SNMP SysUpTime.
166 [Tags] Verify_SNMP_SysUpTime
167
168 Generate Error And Verify System Up Time
169
170
171Verify SNMP SysUpTime On BMC Reboot
172 [Documentation] Verify SNMP SysUpTime on BMC reboot.
173 [Tags] Verify_SNMP_SysUpTime_On_BMC_Reboot
174
175 # Reboot BMC to reset system uptime.
176 OBMC Reboot (off)
177
178 ${uptime}= Generate Error And Verify System Up Time
179
180 # Check if uptime is reset after reboot.
181 Should Be True ${uptime} <= 1 msg=SNMP SysUpTime is not reset on reboot
182
183
Anves Kumar rayankula9d385de2021-03-09 23:25:28 -0600184*** Keywords ***
185
186Create Error On BMC And Verify If Trap Is Sent
Prashanth Katti04b9ab92021-06-03 08:54:35 -0500187 [Documentation] Generate error on BMC and verify if trap is sent.
188 [Arguments] ${event_log}=${CMD_INTERNAL_FAILURE} ${expected_error}=${SNMP_TRAP_BMC_INTERNAL_FAILURE}
Anves Kumar rayankula9d385de2021-03-09 23:25:28 -0600189
190 # Description of argument(s):
191 # event_log Event logs to be created.
192 # expected_error Expected error on SNMP.
Naman Navin Hegdebf181332019-06-26 02:08:18 -0500193
194 Configure SNMP Manager On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} Valid
195
196 Start SNMP Manager
Anves Kumar rayankula9d385de2021-03-09 23:25:28 -0600197 BMC Execute Command ${event_log}
Naman Navin Hegdebf181332019-06-26 02:08:18 -0500198 SSHLibrary.Switch Connection snmp_server
199 ${SNMP_LISTEN_OUT}= Read delay=1s
Prashanth Kattic6a0acf2019-08-09 04:16:41 -0500200 Delete SNMP Manager And Object ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
Naman Navin Hegdebf181332019-06-26 02:08:18 -0500201 SSHLibrary.Execute Command sudo killall snmptrapd
Anves Kumar rayankula9d385de2021-03-09 23:25:28 -0600202 ${lines} = Split To Lines ${SNMP_LISTEN_OUT}
203 ${trap_info}= Get From List ${lines} -1
204 ${SNMP_TRAP} = Split String ${trap_info} \t
Naman Navin Hegdebf181332019-06-26 02:08:18 -0500205
Anves Kumar rayankula9d385de2021-03-09 23:25:28 -0600206 Should Contain ${SNMP_TRAP}[0] DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks:
207 Should Be Equal ${SNMP_TRAP}[1] SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-SMI::enterprises.49871.1.0.0.1
208 Should Match Regexp ${SNMP_TRAP}[2] SNMPv2-SMI::enterprises.49871.1.0.1.1 = Gauge32: \[0-9]*
209 Should Match Regexp ${SNMP_TRAP}[3] SNMPv2-SMI::enterprises.49871.1.0.1.2 = Opaque: UInt64: \[0-9]*
210 Should Match Regexp ${SNMP_TRAP}[4] SNMPv2-SMI::enterprises.49871.1.0.1.3 = INTEGER: \[0-9]
211 Should Be Equal ${SNMP_TRAP}[5] SNMPv2-SMI::enterprises.49871.1.0.1.4 = STRING: "${expected_error}"
Prashanth Katti04b9ab92021-06-03 08:54:35 -0500212
George Keishing409df052024-01-17 22:36:14 +0530213 RETURN ${SNMP_TRAP}
Prashanth Katti04b9ab92021-06-03 08:54:35 -0500214
215
216Generate Error And Verify System Up Time
217 [Documentation] Generate error and verify system up time.
218
219 # Get system uptime on BMC.
220 # Example output of uptime:
221 # (8055.79 15032.86)
222
223 ${cmd_output} ${stderr} ${rc}= BMC Execute Command cat /proc/uptime
224 @{times}= Split String ${cmd_output}
225
226 ${bmc_uptime_in_minutes}= Evaluate int(${times}[0])/60
227
228 ${trap}= Create Error On BMC And Verify If Trap Is Sent
229
230 # Extract System up time from SNMP trap.
231 # Example - SNMP trap:
232 # DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (252367) 0:42:03.67
233 # SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-SMI::enterprises.49871.1.0.0.1
234 # SNMPv2-SMI::enterprises.49871.1.0.1.1 = Gauge32: 54
235 # SNMPv2-SMI::enterprises.49871.1.0.1.2 = Opaque: UInt64: 4622921648578756984
236 # SNMPv2-SMI::enterprises.49871.1.0.1.3 = INTEGER: 3
237 # SNMPv2-SMI::enterprises.49871.1.0.1.4 = STRING:
238
239 @{words}= Split String ${trap}[0] =
240
241 ${timeticks}= Fetch From Right ${words}[1] (
242 ${snmp_sysuptime}= Fetch From Left ${timeticks} )
243
244 # SNMP SysUptime will be in milli seconds.
245 # Convert into minutes.
246 ${sysuptime_in_minutes}= Evaluate int(${snmp_sysuptime})/6000
247
248 Should Be Equal As Integers ${bmc_uptime_in_minutes} ${sysuptime_in_minutes}
249
George Keishing409df052024-01-17 22:36:14 +0530250 RETURN ${sysuptime_in_minutes}