Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 1 | *** Settings *** |
Naman Navin Hegde | bf18133 | 2019-06-26 02:08:18 -0500 | [diff] [blame] | 2 | Documentation This testing requires special setup where SNMP trapd is |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 3 | ... configured and installed. For download, installation and |
| 4 | ... configuration refer http://www.net-snmp.org/. |
| 5 | |
George Keishing | 9e5626d | 2024-03-26 11:40:20 +0530 | [diff] [blame] | 6 | Resource ../../lib/snmp/resource.robot |
| 7 | Resource ../../lib/snmp/snmp_utils.robot |
| 8 | Resource ../../lib/openbmc_ffdc.robot |
| 9 | Resource ../../lib/logging_utils.robot |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 10 | |
George Keishing | 9e5626d | 2024-03-26 11:40:20 +0530 | [diff] [blame] | 11 | Library String |
| 12 | Library SSHLibrary |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 13 | |
George Keishing | 9e5626d | 2024-03-26 11:40:20 +0530 | [diff] [blame] | 14 | Test Teardown FFDC On Test Case Fail |
Prashanth Katti | 7dae0e8 | 2019-01-09 01:35:42 -0600 | [diff] [blame] | 15 | |
George Keishing | 9e5626d | 2024-03-26 11:40:20 +0530 | [diff] [blame] | 16 | Force Tags BMC_SNMP_Config |
George Keishing | 87dc442 | 2023-10-20 12:56:30 +0530 | [diff] [blame] | 17 | |
Anves Kumar rayankula | 9d385de | 2021-03-09 23:25:28 -0600 | [diff] [blame] | 18 | *** 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 Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 38 | *** Test Cases *** |
| 39 | Configure 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 Keishing | b98036a | 2022-01-31 12:39:47 -0600 | [diff] [blame] | 48 | Configure SNMP Manager On BMC With Non Default Port And Verify |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 49 | [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 | |
| 57 | Configure SNMP Manager On BMC With Out Of Range Port And Verify |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 58 | [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 Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 60 | [Template] Configure SNMP Manager On BMC |
| 61 | |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 62 | # SNMP manager IP Port Scenario |
| 63 | ${SNMP_MGR1_IP} ${out_of_range_port} error |
| 64 | |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 65 | Configure SNMP Manager On BMC With Alpha Port And Verify |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 66 | [Documentation] Configure SNMP Manager On BMC with alpha port and verify. |
| 67 | [Tags] Configure_SNMP_Manager_On_BMC_With_Alpha_Port_And_Verify |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 68 | [Template] Configure SNMP Manager On BMC |
| 69 | |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 70 | # SNMP manager IP Port Scenario |
| 71 | ${SNMP_MGR1_IP} ${alpha_port} error |
| 72 | |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 73 | Configure SNMP Manager On BMC With Negative Port And Verify |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 74 | [Documentation] Configure SNMP Manager On BMC with negative port and verify. |
| 75 | [Tags] Configure_SNMP_Manager_On_BMC_With_Negative_Port_And_Verify |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 76 | [Template] Configure SNMP Manager On BMC |
| 77 | |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 78 | # SNMP manager IP Port Scenario |
| 79 | ${SNMP_MGR1_IP} ${negative_port} error |
| 80 | |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 81 | Configure SNMP Manager On BMC With Empty Port And Verify |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 82 | [Documentation] Configure SNMP Manager On BMC with empty port and verify. |
| 83 | [Tags] Configure_SNMP_Manager_On_BMC_With_Empty_Port_And_Verify |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 84 | [Template] Configure SNMP Manager On BMC |
| 85 | |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 86 | # SNMP manager IP Port Scenario |
| 87 | ${SNMP_MGR1_IP} ${empty_port} error |
| 88 | |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 89 | Configure SNMP Manager On BMC With Out Of Range IP And Verify |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 90 | [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 Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 92 | [Template] Configure SNMP Manager On BMC |
| 93 | |
George Keishing | 5abfe60 | 2018-07-05 11:54:37 -0500 | [diff] [blame] | 94 | # SNMP manager IP Port Scenario |
| 95 | ${out_of_range_ip} ${SNMP_DEFAULT_PORT} error |
| 96 | |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 97 | Configure 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 Keishing | b98036a | 2022-01-31 12:39:47 -0600 | [diff] [blame] | 109 | Configure Multiple SNMP Managers With Non Default Port And Verify |
Prashanth Katti | 081b3d9 | 2018-06-15 05:13:11 -0500 | [diff] [blame] | 110 | [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 | |
| 121 | Configure 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 Hegde | bf18133 | 2019-06-26 02:08:18 -0500 | [diff] [blame] | 137 | Generate 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 rayankula | 9d385de | 2021-03-09 23:25:28 -0600 | [diff] [blame] | 141 | [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 | |
| 146 | Generate 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 rayankula | bce13df | 2021-04-09 06:58:51 -0500 | [diff] [blame] | 156 | Configure 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 Katti | 04b9ab9 | 2021-06-03 08:54:35 -0500 | [diff] [blame] | 164 | Verify SNMP SysUpTime |
| 165 | [Documentation] Verify SNMP SysUpTime. |
| 166 | [Tags] Verify_SNMP_SysUpTime |
| 167 | |
| 168 | Generate Error And Verify System Up Time |
| 169 | |
| 170 | |
| 171 | Verify 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 rayankula | 9d385de | 2021-03-09 23:25:28 -0600 | [diff] [blame] | 184 | *** Keywords *** |
| 185 | |
| 186 | Create Error On BMC And Verify If Trap Is Sent |
Prashanth Katti | 04b9ab9 | 2021-06-03 08:54:35 -0500 | [diff] [blame] | 187 | [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 rayankula | 9d385de | 2021-03-09 23:25:28 -0600 | [diff] [blame] | 189 | |
| 190 | # Description of argument(s): |
| 191 | # event_log Event logs to be created. |
| 192 | # expected_error Expected error on SNMP. |
Naman Navin Hegde | bf18133 | 2019-06-26 02:08:18 -0500 | [diff] [blame] | 193 | |
| 194 | Configure SNMP Manager On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} Valid |
| 195 | |
| 196 | Start SNMP Manager |
Anves Kumar rayankula | 9d385de | 2021-03-09 23:25:28 -0600 | [diff] [blame] | 197 | BMC Execute Command ${event_log} |
Naman Navin Hegde | bf18133 | 2019-06-26 02:08:18 -0500 | [diff] [blame] | 198 | SSHLibrary.Switch Connection snmp_server |
| 199 | ${SNMP_LISTEN_OUT}= Read delay=1s |
Prashanth Katti | c6a0acf | 2019-08-09 04:16:41 -0500 | [diff] [blame] | 200 | Delete SNMP Manager And Object ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} |
Naman Navin Hegde | bf18133 | 2019-06-26 02:08:18 -0500 | [diff] [blame] | 201 | SSHLibrary.Execute Command sudo killall snmptrapd |
Anves Kumar rayankula | 9d385de | 2021-03-09 23:25:28 -0600 | [diff] [blame] | 202 | ${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 Hegde | bf18133 | 2019-06-26 02:08:18 -0500 | [diff] [blame] | 205 | |
Anves Kumar rayankula | 9d385de | 2021-03-09 23:25:28 -0600 | [diff] [blame] | 206 | 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 Katti | 04b9ab9 | 2021-06-03 08:54:35 -0500 | [diff] [blame] | 212 | |
George Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame^] | 213 | RETURN ${SNMP_TRAP} |
Prashanth Katti | 04b9ab9 | 2021-06-03 08:54:35 -0500 | [diff] [blame] | 214 | |
| 215 | |
| 216 | Generate 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 Keishing | 409df05 | 2024-01-17 22:36:14 +0530 | [diff] [blame^] | 250 | RETURN ${sysuptime_in_minutes} |