1*** Settings *** 2 3Documentation Test OpenBMC GUI "SNMP Alerts" sub-menu of "Settings". 4 5Resource ../../lib/gui_resource.robot 6Resource ../../../lib/snmp/resource.robot 7Resource ../../../lib/snmp/redfish_snmp_utils.robot 8 9Suite Setup Suite Setup Execution 10Suite Teardown Close Browser 11 12 13*** Variables *** 14 15${xpath_snmp_alerts_sub_menu} //*[@data-test-id='nav-item-snmp-alerts'] 16${xpath_snmp_alerts_heading} //h1[text()="SNMP alerts"] 17${xpath_select_all_snmp} //*[@data-test-id='snmpAlerts-checkbox-selectAll'] 18${xpath_add_destination} //button[contains(text(),'Add destination')] 19${xpath_snmp_alert_destination_heading} //h5[contains(text(),'Add SNMP alert destination')] 20${xpath_ip_address_input_button} //*[@data-test-id='snmpAlerts-input-ipAddress'] 21${xpath_port_optional_input_button} //*[@data-test-id='snmpAlerts-input-port'] 22${xpath_snmp_add_destination_button} //*[@data-test-id='snmpAlerts-button-ok'] 23${xpath_cancel_button} //button[contains(text(),'Cancel')] 24${xpath_delete_button} //*[@data-test-id='snmpAlerts-button-deleteRow-undefined'] 25${xpath_delete_destination} //button[contains(text(),'Delete destination')] 26 27${snmp_page_heading} SNMP alerts 28${invalid_port_error} Value must be between 0 – 65535 29${invalid_destination_error} Error in adding SNMP alert destination 30 31 32*** Test Cases *** 33 34Verify Navigation To SNMP Alerts Page 35 [Documentation] Verify navigation to SNMP alerts page. 36 [Tags] Verify_Navigation_To_SNMP_Alerts_Page 37 38 Page Should Contain Element ${xpath_snmp_alerts_heading} 39 40 41Verify Existence Of All Input Boxes In SNMP Alerts Page 42 [Documentation] Verify existence of all sections in SNMP alerts page. 43 [Tags] Verify_Existence_Of_All_Input_Boxes_In_SNMP_Alerts_Page 44 45 Page Should Contain Checkbox ${xpath_select_all_snmp} 46 47 48Verify Existence Of All Buttons In SNMP Alerts Page 49 [Documentation] Verify existence of all buttons in SNMP alerts page. 50 [Tags] Verify_Existence_Of_All_Buttons_In_SNMP_Alerts_Page 51 52 Page should Contain Button ${xpath_add_destination} 53 54 55Verify Existence Of All Fields In Add Destination 56 [Documentation] Verify existence of all buttons and fields in add destination page. 57 [Tags] Verify_Existence_Of_All_Fields_In_Add_Destination 58 [Teardown] Run Keywords Click Button ${xpath_cancel_button} AND 59 ... Wait Until Keyword Succeeds 10 sec 5 sec 60 ... Refresh GUI And Verify Element Value ${xpath_snmp_alerts_heading} ${snmp_page_heading} 61 62 Click Element ${xpath_add_destination} 63 Wait Until Page Contains Element ${xpath_snmp_alert_destination_heading} 64 Page Should Contain Element ${xpath_ip_address_input_button} 65 Page Should Contain Element ${xpath_port_optional_input_button} 66 Page Should Contain Element ${xpath_cancel_button} 67 Page Should Contain Element ${xpath_snmp_add_destination_button} 68 69 70Configure SNMP Settings On BMC With Non Default Port Via GUI And Verify 71 [Documentation] Configure SNMP settings on BMC with non default port via GUI and verify. 72 [Tags] Configure_SNMP_Settings_On_BMC_With_Non_Default_Port_Via_GUI_And_Verify 73 [Teardown] Delete SNMP Manager Via GUI ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1} 74 75 Configure SNMP Manager Via GUI ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1} 76 77 Wait Until Page Contains ${SNMP_MGR1_IP} timeout=45s 78 79 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1} 80 81 82Configure SNMP Settings On BMC Via GUI And Verify 83 [Documentation] Configure SNMP settings on BMC via GUI and verify. 84 [Tags] Configure_SNMP_Settings_On_BMC_Via_GUI_And_Verify 85 [Teardown] Delete SNMP Manager Via GUI ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 86 87 Configure SNMP Manager Via GUI ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 88 89 Wait Until Page Contains ${SNMP_MGR1_IP} timeout=45s 90 91 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 92 93 94Configure SNMP Settings On BMC With Empty Port Via GUI And Verify 95 [Documentation] Configure SNMP settings on BMC with empty port via GUI and verify. 96 [Tags] Configure_SNMP_Settings_On_BMC_With_Empty_Port_Via_GUI_And_Verify 97 [Teardown] Delete SNMP Manager Via GUI ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 98 99 Configure SNMP Manager Via GUI ${SNMP_MGR1_IP} ${empty_port} 100 101 Wait Until Page Contains ${SNMP_MGR1_IP} timeout=45s 102 103 # SNMP Manager IP is set with default port number when no port number is provided. 104 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 105 106 107Configure Invalid SNMP Settings On BMC Via GUI And Verify 108 109 [Documentation] Configure invalid SNMP settings on BMC via GUI and verify. 110 [Tags] Configure_Invalid_SNMP_Settings_On_BMC_Via_GUI_And_Verify 111 [Template] Configure SNMP Manager On BMC With Invalid Setting Via GUI And Verify 112 113 # snmp_manager_ip snmp_manager_port Expected status 114 ${SNMP_MGR1_IP} ${out_of_range_port} ${invalid_port_error} 115 ${SNMP_MGR1_IP} ${alpha_port} ${invalid_port_error} 116 ${SNMP_MGR1_IP} ${negative_port} ${invalid_port_error} 117 ${out_of_range_ip} ${NON_DEFAULT_PORT1} ${invalid_destination_error} 118 ${alpha_ip} ${NON_DEFAULT_PORT1} ${invalid_destination_error} 119 120 121Configure Multiple SNMP Managers On BMC Via GUI And Verify 122 [Documentation] Configure multiple SNMP managers on BMC via GUI and verify. 123 [Tags] Configure_Multiple_SNMP_Managers_On_BMC_Via_GUI_And_Verify 124 [Template] Configure Multiple SNMP Managers On BMC With Valid Port Via GUI And Verify 125 126 # snmp_manager_ip snmp_port 127 ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 128 ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT} 129 130 131Configure Multiple SNMP Managers With Non Default Port Via GUI And Verify 132 [Documentation] Configure multiple SNMP managers with non-default port via GUI and verify. 133 [Tags] Configure_Multiple_SNMP_Managers_With_Non_Default_Port_Via_GUI_And_Verify 134 [Template] Configure Multiple SNMP Managers On BMC With Valid Port Via GUI And Verify 135 136 # snmp_manager_ip snmp_port 137 ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1} 138 ${SNMP_MGR2_IP} ${NON_DEFAULT_PORT1} 139 140 141Configure Multiple SNMP Managers With Different Ports Via GUI And Verify 142 [Documentation] Configure multiple SNMP managers with different ports via GUI and verify. 143 [Tags] Configure_Multiple_SNMP_Managers_With_Different_Ports_Via_GUI_And_Verify 144 [Template] Configure Multiple SNMP Managers On BMC With Valid Port Via GUI And Verify 145 146 # snmp_manager_ip snmp_port 147 ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1} 148 ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT} 149 ${SNMP_MGR3_IP} ${NON_DEFAULT_PORT2} 150 151 152Configure Multiple SNMP Managers On BMC Via GUI And Verify Persistency On BMC Reboot 153 [Documentation] Login GUI SNMP alerts page and 154 ... add multiple SNMP Managers on BMC via GUI and verify persistency on BMC reboot. 155 [Tags] Configure_Multiple_SNMP_Managers_On_BMC_Via_GUI_And_Verify_Persistency_On_BMC_Reboot 156 [Teardown] Run Keywords Delete SNMP Manager Via GUI ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 157 ... AND Delete SNMP Manager Via GUI ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT} 158 159 Configure SNMP Manager Via GUI ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 160 Wait Until Page Contains ${SNMP_MGR1_IP} timeout=45s 161 162 Configure SNMP Manager Via GUI ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT} 163 Wait Until Page Contains ${SNMP_MGR2_IP} timeout=45s 164 165 # Reboot BMC and check persistency SNMP manager. 166 Reboot BMC via GUI 167 168 Suite Setup Execution 169 Wait Until Page Contains ${snmp_page_heading} timeout=1min 170 171 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 172 Verify SNMP Manager Configured On BMC ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT} 173 174 175Configure SNMP Manager Via GUI And Verify SNMP Trap 176 [Documentation] Login GUI SNMP alerts page and add SNMP manager via GUI 177 ... and generate error on BMC and verify trap and its fields. 178 [Tags] Configure_SNMP_Manager_Via_GUI_And_Verify_SNMP_Trap 179 [Template] Create Error On BMC And Verify Trap On Default Port 180 [Teardown] Delete SNMP Manager Via GUI ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 181 182 # event_log expected_error 183 184 # Generate internal failure error. 185 ${CMD_INTERNAL_FAILURE} ${SNMP_TRAP_BMC_INTERNAL_FAILURE} 186 187 # Generate timeout error. 188 ${CMD_FRU_CALLOUT} ${SNMP_TRAP_BMC_CALLOUT_ERROR} 189 190 # Generate informational error. 191 ${CMD_INFORMATIONAL_ERROR} ${SNMP_TRAP_BMC_INFORMATIONAL_ERROR} 192 193 194*** Keywords *** 195 196Suite Setup Execution 197 [Documentation] Do test case setup tasks. 198 199 Launch Browser And Login GUI 200 201 Click Element ${xpath_settings_menu} 202 Click Element ${xpath_snmp_alerts_sub_menu} 203 Wait Until Keyword Succeeds 30 sec 10 sec Location Should Contain snmp-alerts 204 205 206Configure SNMP Manager Via GUI 207 [Documentation] Configure SNMP manager via GUI. 208 [Arguments] ${snmp_ip} ${port} 209 210 # Description of argument(s): 211 # snmp_ip SNMP manager IP address. 212 # port SNMP manager port. 213 214 Click Element ${xpath_add_destination} 215 Wait Until Page Contains Element ${xpath_snmp_alert_destination_heading} 216 Input Text ${xpath_ip_address_input_button} ${snmp_ip} 217 Wait Until Keyword Succeeds 30 sec 5 sec Get Value ${xpath_ip_address_input_button} 218 Input Text ${xpath_port_optional_input_button} ${port} 219 Click Element ${xpath_snmp_add_destination_button} 220 221 222Delete SNMP Manager Via GUI 223 [Documentation] Delete SNMP manager via GUI. 224 [Arguments] ${snmp_mgr_ip} ${snmp_mgr_port} 225 226 # Description of argument(s): 227 # snmp_mgr_ip SNMP manager IP address. 228 # snmp_mgr_port SNMP manager port. 229 230 Wait Until Page Contains ${snmp_mgr_ip} ${snmp_mgr_port} 231 Click Element At Coordinates ${xpath_select_all_snmp} 0 0 232 Wait Until Keyword Succeeds 30 sec 5 sec Click Element ${xpath_delete_button} 233 Wait Until Page Contains Delete SNMP alert destination 234 Click Element ${xpath_delete_destination} 235 Wait Until Page Contains Successfully deleted SNMP alert destination timeout=45s 236 Wait Until Keyword Succeeds 30 sec 10 sec Refresh GUI And Verify Element Value 237 ... ${xpath_snmp_alerts_heading} ${snmp_page_heading} 238 239 240Configure SNMP Manager On BMC With Invalid Setting Via GUI And Verify 241 242 [Documentation] Configure SNMP manager on BMC with invalid setting via GUI and verify. 243 [Arguments] ${snmp_manager_ip} ${snmp_manager_port} ${expected_error} 244 [Teardown] Run Keyword If '${expected_error}' == '${invalid_port_error}' 245 ... Click Element ${xpath_cancel_button} 246 247 # Description of argument(s): 248 # snmp_manager_ip SNMP manager IP address. 249 # snmp_manager_port SNMP manager port. 250 # expected_error Expected error optionally provided in testcase 251 # .... (e.g. Invalid format / Value must be between 0 – 65535). 252 253 Configure SNMP Manager Via GUI ${snmp_manager_ip} ${snmp_manager_port} 254 Wait Until Page Contains ${expected_error} 255 ${status}= Run Keyword And Return Status 256 ... Verify SNMP Manager Configured On BMC ${snmp_manager_ip} ${snmp_manager_port} 257 Should Be Equal As Strings ${status} False 258 ... msg=BMC is allowing to configure with invalid SNMP settings. 259 260 261Configure Multiple SNMP Managers On BMC With Valid Port Via GUI And Verify 262 [Documentation] Configure multiple SNMP managers on BMC with valid port value via GUI and verify. 263 [Arguments] ${snmp_ip_value} ${snmp_port_value} 264 [Teardown] Delete SNMP Manager Via GUI ${snmp_ip_value} ${snmp_port_value} 265 266 # Description of argument(s): 267 # snmp_ip_value SNMP manager IP address. 268 # snmp_port_value SNMP manager port. 269 270 Configure SNMP Manager Via GUI ${snmp_ip_value} ${snmp_port_value} 271 Verify SNMP Manager Configured On BMC ${snmp_ip_value} ${snmp_port_value} 272 273 274Create Error On BMC And Verify Trap On Default Port 275 [Documentation] Generate error on BMC and verify if trap is sent to default port. 276 [Arguments] ${event_log}=${CMD_INTERNAL_FAILURE} ${expected_error}=${SNMP_TRAP_BMC_INTERNAL_FAILURE} 277 278 # Description of argument(s): 279 # event_log Event logs to be created. 280 # expected_error Expected error on SNMP. 281 282 Configure SNMP Manager Via GUI ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT} 283 284 Start SNMP Manager 285 286 # Generate error log. 287 BMC Execute Command ${event_log} 288 289 SSHLibrary.Switch Connection snmp_server 290 ${SNMP_LISTEN_OUT}= Read delay=1s 291 292 # Stop SNMP manager process. 293 SSHLibrary.Execute Command sudo killall snmptrapd 294 295 # Sample SNMP trap: 296 # 2021-06-16 07:05:29 xx.xx.xx.xx [UDP: [xx.xx.xx.xx]:58154->[xx.xx.xx.xx]:xxx]: 297 # DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (2100473) 5:50:04.73 298 # SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-SMI::enterprises.49871.1.0.0.1 299 # SNMPv2-SMI::enterprises.49871.1.0.1.1 = Gauge32: 369 SNMPv2-SMI::enterprises.49871.1.0.1.2 = Opaque: 300 # UInt64: 1397718405502468474 SNMPv2-SMI::enterprises.49871.1.0.1.3 = INTEGER: 3 301 # SNMPv2-SMI::enterprises.49871.1.0.1.4 = STRING: "xxx.xx.xx Failure" 302 303 ${lines}= Split To Lines ${SNMP_LISTEN_OUT} 304 ${trap_info}= Get From List ${lines} -1 305 ${snmp_trap}= Split String ${trap_info} \t 306 307 Verify SNMP Trap ${snmp_trap} ${expected_error} 308