1*** Settings *** 2Documentation This testing requires special setup where SNMP trapd is 3... configured and installed. For download, installation and 4... configuration refer http://www.net-snmp.org/. 5 6 7Resource ../../lib/snmp/resource.robot 8Resource ../../lib/snmp/redfish_snmp_utils.robot 9Resource ../../lib/bmc_redfish_resource.robot 10Resource ../../lib/openbmc_ffdc.robot 11Resource ../../lib/logging_utils.robot 12 13 14Test Teardown FFDC On Test Case Fail 15Suite Setup Suite Setup Execution 16Suite Teardown Suite Teardown Execution 17 18 19*** Test Cases *** 20 21Configure SNMP Manager On BMC And Verify 22 [Documentation] Configure SNMP manager on BMC via Redfish and verify. 23 [Tags] Configure_SNMP_Manager_On_BMC_And_Verify 24 [Teardown] Delete SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 25 26 Configure SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} ${HTTP_CREATED} 27 28 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 29 30 31Configure SNMP Manager On BMC With Non Default Port And Verify 32 [Documentation] Configure SNMP Manager On BMC And Verify. 33 [Tags] Configure_SNMP_Manager_On_BMC_With_Non_Default_Port_And_Verify 34 [Teardown] Delete SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1} 35 36 Configure SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1} ${HTTP_CREATED} 37 38 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1} 39 40 41Configure SNMP Manager On BMC With Out Of Range Port And Verify 42 [Documentation] Configure SNMP Manager On BMC with out-of range port and verify. 43 [Tags] Configure_SNMP_Manager_On_BMC_With_Out_Of_Range_Port_And_Verify 44 [Teardown] Delete SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${out_of_range_port} 45 46 Configure SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${out_of_range_port} ${HTTP_BAD_REQUEST} 47 48 ${status}= Run Keyword And Return Status 49 ... Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${out_of_range_port} 50 51 Should Be Equal As Strings ${status} False 52 ... msg=BMC is allowing to configure out of range port. 53 54 55Generate Error On BMC And Verify SNMP Trap 56 [Documentation] Generate error on BMC and verify trap and its fields. 57 [Tags] Generate_Error_On_BMC_And_Verify_SNMP_Trap 58 [Template] Create Error On BMC And Verify Trap 59 60 # event_log expected_error 61 62 # Generate internal failure error. 63 ${CMD_INTERNAL_FAILURE} ${SNMP_TRAP_BMC_INTERNAL_FAILURE} 64 65 # Generate timeout error. 66 ${CMD_FRU_CALLOUT} ${SNMP_TRAP_BMC_CALLOUT_ERROR} 67 68 # Generate informational error. 69 ${CMD_INFORMATIONAL_ERROR} ${SNMP_TRAP_BMC_INFORMATIONAL_ERROR} 70 71 72Configure SNMP Manager On BMC With Alpha Port And Verify 73 [Documentation] Configure SNMP Manager On BMC with alpha port and verify. 74 [Tags] Configure_SNMP_Manager_On_BMC_With_Alpha_Port_And_Verify 75 [Teardown] Delete SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${alpha_port} 76 77 Configure SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${alpha_port} ${HTTP_BAD_REQUEST} 78 79 ${status}= Run Keyword And Return Status 80 ... Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${alpha_port} 81 82 Should Be Equal As Strings ${status} False 83 ... msg=BMC is allowing to configure invalid port. 84 85 86Configure SNMP Manager On BMC With Empty Port And Verify 87 [Documentation] Configure SNMP Manager On BMC with empty port and verify 88 ... SNMP manager gets configured with default port. 89 [Tags] Configure_SNMP_Manager_On_BMC_With_Empty_Port_And_Verify 90 [Teardown] Delete SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 91 92 Configure SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${empty_port} 93 94 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 95 96 97Configure Multiple SNMP Managers And Verify 98 [Documentation] Configure multiple SNMP managers and verify. 99 [Tags] Configure_Multiple_SNMP_Managers_And_Verify 100 [Teardown] Run Keywords 101 ... Delete SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 102 ... AND 103 ... Delete SNMP Manager Via Redfish ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT} 104 105 Configure SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 106 Configure SNMP Manager Via Redfish ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT} 107 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 108 Verify SNMP Manager Configured On BMC ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT} 109 110 111Generate Error On BMC And Verify SNMP Trap Is Sent To Non Default Port 112 [Documentation] Generate error on BMC and verify trap and its fields. 113 [Tags] Generate_Error_On_BMC_And_Verify_SNMP_Trap_Is_Sent_To_Non_Default_Port 114 [Template] Create Error On BMC And Verify Trap On Non Default Port 115 116 # event_log expected_error 117 118 # Generate internal failure error. 119 ${CMD_INTERNAL_FAILURE} ${SNMP_TRAP_BMC_INTERNAL_FAILURE} 120 121 # Generate timeout error. 122 ${CMD_FRU_CALLOUT} ${SNMP_TRAP_BMC_CALLOUT_ERROR} 123 124 # Generate informational error. 125 ${CMD_INFORMATIONAL_ERROR} ${SNMP_TRAP_BMC_INFORMATIONAL_ERROR} 126 127 128Verify SNMP SysUpTime 129 [Documentation] Verify SNMP SysUpTime. 130 [Tags] Verify_SNMP_SysUpTime 131 132 Generate Error And Verify System Up Time 133 134 135Verify SNMP SysUpTime On BMC Reboot 136 [Documentation] Verify SNMP SysUpTime on BMC reboot. 137 [Tags] Verify_SNMP_SysUpTime_On_BMC_Reboot 138 139 # Reboot BMC to reset system uptime. 140 OBMC Reboot (off) 141 142 ${uptime}= Generate Error And Verify System Up Time 143 144 # Check if uptime is reset after reboot. 145 Should Be True ${uptime} <= 1 msg=SNMP SysUpTime is not reset on reboot 146 147 148Configure Multiple SNMP Managers With Non Default Port And Verify 149 [Documentation] Configure multiple SNMP Managers with non-default port And Verify. 150 [Tags] Configure_Multiple_SNMP_Managers_With_Non_Default_Port_And_Verify 151 [Teardown] Run Keywords 152 ... Delete SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1} 153 ... AND 154 ... Delete SNMP Manager Via Redfish ${SNMP_MGR2_IP} ${NON_DEFAULT_PORT1} 155 156 # Configure multiple SNMP managers with non-default port. 157 Configure SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1} 158 Configure SNMP Manager Via Redfish ${SNMP_MGR2_IP} ${NON_DEFAULT_PORT1} 159 160 # Verify if SNMP managers are configured. 161 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1} 162 Verify SNMP Manager Configured On BMC ${SNMP_MGR2_IP} ${NON_DEFAULT_PORT1} 163 164 165Configure Multiple SNMP Managers With Different Ports And Verify 166 [Documentation] Configure multiple SNMP Managers with different ports And Verify. 167 [Tags] Configure_Multiple_SNMP_Managers_With_Different_Ports_And_Verify 168 [Teardown] Run Keywords 169 ... Delete SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 170 ... AND 171 ... Delete SNMP Manager Via Redfish ${SNMP_MGR2_IP} ${NON_DEFAULT_PORT1} 172 ... AND 173 ... Delete SNMP Manager Via Redfish ${SNMP_MGR3_IP} ${NON_DEFAULT_PORT2} 174 175 # Configure multiple SNMP managers with different ports. 176 Configure SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 177 Configure SNMP Manager Via Redfish ${SNMP_MGR2_IP} ${NON_DEFAULT_PORT1} 178 Configure SNMP Manager Via Redfish ${SNMP_MGR3_IP} ${NON_DEFAULT_PORT2} 179 180 # Verify if SNMP managers are configured. 181 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 182 Verify SNMP Manager Configured On BMC ${SNMP_MGR2_IP} ${NON_DEFAULT_PORT1} 183 Verify SNMP Manager Configured On BMC ${SNMP_MGR3_IP} ${NON_DEFAULT_PORT2} 184 185 186Configure SNMP Manager With Out Of Range IP On BMC And Verify 187 [Documentation] Configure SNMP Manager On BMC with out-of range IP and expect an error. 188 [Tags] Configure_SNMP_Manager_With_Out_Of_Range_IP_On_BMC_And_Verify 189 [Teardown] Delete SNMP Manager Via Redfish ${out_of_range_ip} ${SNMP_DEFAULT_PORT} 190 191 Configure SNMP Manager Via Redfish ${out_of_range_ip} ${SNMP_DEFAULT_PORT} ${HTTP_BAD_REQUEST} 192 193 ${status}= Run Keyword And Return Status 194 ... Verify SNMP Manager Configured On BMC ${out_of_range_ip} ${SNMP_DEFAULT_PORT} 195 196 Should Be Equal As Strings ${status} False 197 ... msg=BMC is allowing to configure out of range IP. 198 199 200Verify Persistency Of SNMP Manager And Trap On BMC Reboot 201 [Documentation] Verify persistency of SNMP manager configuration on BMC 202 ... and BMC is able to send trap after reboot. 203 [Tags] Verify_Persistency_Of_SNMP_Manager_And_Trap_On_BMC_Reboot 204 [Teardown] Delete SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 205 206 Configure SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} ${HTTP_CREATED} 207 208 # Reboot BMC and check persistency SNMP manager. 209 OBMC Reboot (off) 210 211 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 212 213 # Check if trap is generated and sent to SNMP manager after reboot. 214 Generate Error On BMC And Verify Trap 215 ... ${CMD_INTERNAL_FAILURE} ${SNMP_TRAP_BMC_INTERNAL_FAILURE} 216 217 218Configure SNMP Manager With Less Octet IP And Verify 219 [Documentation] Configure SNMP manager on BMC with less octet IP and expect an error. 220 [Tags] Configure_SNMP_Manager_With_Less_Octet_IP_And_Verify 221 [Teardown] Delete SNMP Manager Via Redfish ${less_octet_ip} ${SNMP_DEFAULT_PORT} 222 223 Configure SNMP Manager Via Redfish ${less_octet_ip} ${SNMP_DEFAULT_PORT} ${HTTP_BAD_REQUEST} 224 225 ${status}= Run Keyword And Return Status 226 ... Verify SNMP Manager Configured On BMC ${less_octet_ip} ${SNMP_DEFAULT_PORT} 227 228 Should Be Equal As Strings ${status} False 229 ... msg=BMC is allowing to configure less octet IP. 230 231 232Configure SNMP Manager On BMC With Negative Port And Verify 233 [Documentation] Configure SNMP Manager On BMC with negative port and verify. 234 [Tags] Configure_SNMP_Manager_On_BMC_With_Negative_Port_And_Verify 235 236 [Teardown] Delete SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${negative_port} 237 238 Configure SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${negative_port} ${HTTP_BAD_REQUEST} 239 240 ${status}= Run Keyword And Return Status 241 ... Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${negative_port} 242 243 Should Be Equal As Strings ${status} False 244 ... msg=BMC is allowing to configure negative port. 245 246 247Configure Multiple SNMP Managers On BMC And Verify Persistency On BMC Reboot 248 [Documentation] Configure multiple SNMP Managers on BMC and verify persistency on BMC reboot. 249 [Tags] Configure_Multiple_SNMP_Managers_On_BMC_And_Verify_Persistency_On_BMC_Reboot 250 [Teardown] Run Keywords 251 ... Delete SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 252 ... AND 253 ... Delete SNMP Manager Via Redfish ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT} 254 255 Configure SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 256 Configure SNMP Manager Via Redfish ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT} 257 258 # Reboot BMC and check persistency SNMP manager. 259 OBMC Reboot (off) 260 261 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 262 Verify SNMP Manager Configured On BMC ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT} 263 264 265Configure Multiple SNMP Managers On BMC And Check Trap On BMC Reboot 266 [Documentation] Configure multiple SNMP Managers on BMC and check trap on BMC reboot. 267 [Tags] Configure_Multiple_SNMP_Managers_On_BMC_And_Check_Trap_On_BMC_Reboot 268 [Teardown] Run Keywords 269 ... Delete SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 270 ... AND 271 ... Delete SNMP Manager Via Redfish ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT} 272 273 Configure SNMP Manager Via Redfish ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 274 Configure SNMP Manager Via Redfish ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT} 275 276 # Reboot BMC and check persistency SNMP manager. 277 OBMC Reboot (off) 278 279 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 280 Verify SNMP Manager Configured On BMC ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT} 281 282 # Check if trap is generated and sent to SNMP managers after reboot. 283 Generate Error On BMC And Verify Trap 284 ... ${CMD_INTERNAL_FAILURE} ${SNMP_TRAP_BMC_INTERNAL_FAILURE} 285 286 287*** Keywords *** 288 289Suite Setup Execution 290 [Documentation] Do suite setup execution. 291 292 Redfish.Login 293 294 # Check for SNMP configurations. 295 Valid Value SNMP_MGR1_IP 296 Valid Value SNMP_DEFAULT_PORT 297 298 299Suite Teardown Execution 300 [Documentation] Do suite Teardown execution. 301 302 Run Keyword And Ignore Error Redfish Purge Event Log 303 Run Keyword And Ignore Error Redfish Delete All BMC Dumps 304 305 306Generate Error And Verify System Up Time 307 [Documentation] Generate error and verify system up time. 308 309 # Get system uptime on BMC. 310 # Example output of uptime: 311 # (8055.79 15032.86) 312 313 ${cmd_output} ${stderr} ${rc}= BMC Execute Command cat /proc/uptime 314 @{times}= Split String ${cmd_output} 315 316 ${bmc_uptime_in_minutes}= Evaluate int(${times}[0])/60 317 318 ${trap}= Create Error On BMC And Verify Trap 319 320 # Extract System up time from SNMP trap. 321 # Example - SNMP trap: 322 # DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (252367) 0:42:03.67 323 # SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-SMI::enterprises.49871.1.0.0.1 324 # SNMPv2-SMI::enterprises.49871.1.0.1.1 = Gauge32: 54 325 # SNMPv2-SMI::enterprises.49871.1.0.1.2 = Opaque: UInt64: 4622921648578756984 326 # SNMPv2-SMI::enterprises.49871.1.0.1.3 = INTEGER: 3 327 # SNMPv2-SMI::enterprises.49871.1.0.1.4 = STRING: 328 329 @{words}= Split String ${trap}[0] = 330 331 ${timeticks}= Fetch From Right ${words}[1] ( 332 ${snmp_sysuptime}= Fetch From Left ${timeticks} ) 333 334 # SNMP SysUptime will be in milli seconds. 335 # Convert into minutes. 336 ${sysuptime_in_minutes}= Evaluate int(${snmp_sysuptime})/6000 337 338 Should Be Equal As Integers ${bmc_uptime_in_minutes} ${sysuptime_in_minutes} 339 340 [Return] ${sysuptime_in_minutes} 341