blob: 1aca1ad5b770d45f3dd01744c64930646461c76d [file] [log] [blame]
meghagn62945e22021-10-04 02:33:17 -05001*** Settings ***
2
3Documentation Test OpenBMC GUI "SNMP Alerts" sub-menu of "Settings".
4
5Resource ../../lib/gui_resource.robot
Rahul Maheshwaric27708e2021-12-21 06:35:27 -06006Resource ../../../lib/snmp/resource.robot
7Resource ../../../lib/snmp/redfish_snmp_utils.robot
meghagn705c3642021-10-12 04:14:02 -05008
meghagn62945e22021-10-04 02:33:17 -05009Suite Setup Suite Setup Execution
10Suite Teardown Close Browser
11
12
13*** Variables ***
14
meghagn705c3642021-10-12 04:14:02 -050015${xpath_snmp_alerts_sub_menu} //*[@data-test-id='nav-item-snmp-alerts']
rramyasr-ine71ba072022-06-13 11:12:06 -050016${xpath_snmp_alerts_heading} //h1[text()="SNMP alerts"]
meghagn705c3642021-10-12 04:14:02 -050017${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')]
meghagn62945e22021-10-04 02:33:17 -050026
Megha GNc7bcf7c2022-08-04 05:30:58 -050027${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
meghagn62945e22021-10-04 02:33:17 -050031
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
meghagn705c3642021-10-12 04:14:02 -050045 Page Should Contain Checkbox ${xpath_select_all_snmp}
meghagn62945e22021-10-04 02:33:17 -050046
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.
George Keishingd6a77972022-01-31 12:50:29 -060057 [Tags] Verify_Existence_Of_All_Fields_In_Add_Destination
meghagn705c3642021-10-12 04:14:02 -050058 [Teardown] Run Keywords Click Button ${xpath_cancel_button} AND
59 ... Wait Until Keyword Succeeds 10 sec 5 sec
Megha GNc7bcf7c2022-08-04 05:30:58 -050060 ... Refresh GUI And Verify Element Value ${xpath_snmp_alerts_heading} ${snmp_page_heading}
meghagn62945e22021-10-04 02:33:17 -050061
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
George Keishingd6a77972022-01-31 12:50:29 -060070Configure SNMP Settings On BMC With Non Default Port Via GUI And Verify
meghagn705c3642021-10-12 04:14:02 -050071 [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
meghagnfe16be92022-01-28 05:50:19 -060073 [Teardown] Delete SNMP Manager Via GUI ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1}
meghagn705c3642021-10-12 04:14:02 -050074
75 Configure SNMP Manager Via GUI ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1}
76
meghagna80e4d42021-12-14 05:46:15 -060077 Wait Until Page Contains ${SNMP_MGR1_IP} timeout=45s
meghagn705c3642021-10-12 04:14:02 -050078
rramyasr-in5af784c2022-12-06 10:24:14 -060079 Redfish.Login
meghagn705c3642021-10-12 04:14:02 -050080 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1}
rramyasr-in5af784c2022-12-06 10:24:14 -060081 Redfish.Logout
meghagn705c3642021-10-12 04:14:02 -050082
meghagnc2436bc2021-10-11 03:49:21 -050083Configure SNMP Settings On BMC Via GUI And Verify
84 [Documentation] Configure SNMP settings on BMC via GUI and verify.
85 [Tags] Configure_SNMP_Settings_On_BMC_Via_GUI_And_Verify
meghagnfe16be92022-01-28 05:50:19 -060086 [Teardown] Delete SNMP Manager Via GUI ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
meghagnc2436bc2021-10-11 03:49:21 -050087
88 Configure SNMP Manager Via GUI ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
89
meghagna80e4d42021-12-14 05:46:15 -060090 Wait Until Page Contains ${SNMP_MGR1_IP} timeout=45s
meghagnc2436bc2021-10-11 03:49:21 -050091
92 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
93
94
meghagnd3b19ac2021-10-22 01:09:25 -050095Configure SNMP Settings On BMC With Empty Port Via GUI And Verify
96 [Documentation] Configure SNMP settings on BMC with empty port via GUI and verify.
97 [Tags] Configure_SNMP_Settings_On_BMC_With_Empty_Port_Via_GUI_And_Verify
meghagnfe16be92022-01-28 05:50:19 -060098 [Teardown] Delete SNMP Manager Via GUI ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
meghagnd3b19ac2021-10-22 01:09:25 -050099
100 Configure SNMP Manager Via GUI ${SNMP_MGR1_IP} ${empty_port}
101
meghagna80e4d42021-12-14 05:46:15 -0600102 Wait Until Page Contains ${SNMP_MGR1_IP} timeout=45s
meghagnd3b19ac2021-10-22 01:09:25 -0500103
104 # SNMP Manager IP is set with default port number when no port number is provided.
105 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
106
107
108Configure Invalid SNMP Settings On BMC Via GUI And Verify
109
110 [Documentation] Configure invalid SNMP settings on BMC via GUI and verify.
111 [Tags] Configure_Invalid_SNMP_Settings_On_BMC_Via_GUI_And_Verify
112 [Template] Configure SNMP Manager On BMC With Invalid Setting Via GUI And Verify
113
114 # snmp_manager_ip snmp_manager_port Expected status
Megha GNc7bcf7c2022-08-04 05:30:58 -0500115 ${SNMP_MGR1_IP} ${out_of_range_port} ${invalid_port_error}
116 ${SNMP_MGR1_IP} ${alpha_port} ${invalid_port_error}
117 ${SNMP_MGR1_IP} ${negative_port} ${invalid_port_error}
118 ${out_of_range_ip} ${NON_DEFAULT_PORT1} ${invalid_destination_error}
119 ${alpha_ip} ${NON_DEFAULT_PORT1} ${invalid_destination_error}
meghagnd3b19ac2021-10-22 01:09:25 -0500120
121
meghagn5a4ddb02021-11-09 01:49:23 -0600122Configure Multiple SNMP Managers On BMC Via GUI And Verify
123 [Documentation] Configure multiple SNMP managers on BMC via GUI and verify.
George Keishingd6a77972022-01-31 12:50:29 -0600124 [Tags] Configure_Multiple_SNMP_Managers_On_BMC_Via_GUI_And_Verify
meghagn5a4ddb02021-11-09 01:49:23 -0600125 [Template] Configure Multiple SNMP Managers On BMC With Valid Port Via GUI And Verify
126
127 # snmp_manager_ip snmp_port
128 ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
129 ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT}
130
131
132Configure Multiple SNMP Managers With Non Default Port Via GUI And Verify
133 [Documentation] Configure multiple SNMP managers with non-default port via GUI and verify.
134 [Tags] Configure_Multiple_SNMP_Managers_With_Non_Default_Port_Via_GUI_And_Verify
135 [Template] Configure Multiple SNMP Managers On BMC With Valid Port Via GUI And Verify
136
137 # snmp_manager_ip snmp_port
138 ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1}
139 ${SNMP_MGR2_IP} ${NON_DEFAULT_PORT1}
140
141
142Configure Multiple SNMP Managers With Different Ports Via GUI And Verify
143 [Documentation] Configure multiple SNMP managers with different ports via GUI and verify.
144 [Tags] Configure_Multiple_SNMP_Managers_With_Different_Ports_Via_GUI_And_Verify
145 [Template] Configure Multiple SNMP Managers On BMC With Valid Port Via GUI And Verify
146
147 # snmp_manager_ip snmp_port
148 ${SNMP_MGR1_IP} ${NON_DEFAULT_PORT1}
149 ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT}
150 ${SNMP_MGR3_IP} ${NON_DEFAULT_PORT2}
151
152
meghagnfe16be92022-01-28 05:50:19 -0600153Configure Multiple SNMP Managers On BMC Via GUI And Verify Persistency On BMC Reboot
154 [Documentation] Login GUI SNMP alerts page and
155 ... add multiple SNMP Managers on BMC via GUI and verify persistency on BMC reboot.
156 [Tags] Configure_Multiple_SNMP_Managers_On_BMC_Via_GUI_And_Verify_Persistency_On_BMC_Reboot
157 [Teardown] Run Keywords Delete SNMP Manager Via GUI ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
158 ... AND Delete SNMP Manager Via GUI ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT}
159
160 Configure SNMP Manager Via GUI ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
161 Wait Until Page Contains ${SNMP_MGR1_IP} timeout=45s
162
163 Configure SNMP Manager Via GUI ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT}
164 Wait Until Page Contains ${SNMP_MGR2_IP} timeout=45s
165
166 # Reboot BMC and check persistency SNMP manager.
167 Reboot BMC via GUI
168
169 Suite Setup Execution
Megha GNc7bcf7c2022-08-04 05:30:58 -0500170 Wait Until Page Contains ${snmp_page_heading} timeout=1min
meghagnfe16be92022-01-28 05:50:19 -0600171
172 Verify SNMP Manager Configured On BMC ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
173 Verify SNMP Manager Configured On BMC ${SNMP_MGR2_IP} ${SNMP_DEFAULT_PORT}
174
175
meghagn725ccdd2022-02-09 04:55:52 -0600176Configure SNMP Manager Via GUI And Verify SNMP Trap
177 [Documentation] Login GUI SNMP alerts page and add SNMP manager via GUI
178 ... and generate error on BMC and verify trap and its fields.
179 [Tags] Configure_SNMP_Manager_Via_GUI_And_Verify_SNMP_Trap
180 [Template] Create Error On BMC And Verify Trap On Default Port
181 [Teardown] Delete SNMP Manager Via GUI ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
182
183 # event_log expected_error
184
185 # Generate internal failure error.
186 ${CMD_INTERNAL_FAILURE} ${SNMP_TRAP_BMC_INTERNAL_FAILURE}
187
188 # Generate timeout error.
189 ${CMD_FRU_CALLOUT} ${SNMP_TRAP_BMC_CALLOUT_ERROR}
190
191 # Generate informational error.
192 ${CMD_INFORMATIONAL_ERROR} ${SNMP_TRAP_BMC_INFORMATIONAL_ERROR}
193
194
meghagn62945e22021-10-04 02:33:17 -0500195*** Keywords ***
196
197Suite Setup Execution
198 [Documentation] Do test case setup tasks.
199
200 Launch Browser And Login GUI
201
202 Click Element ${xpath_settings_menu}
203 Click Element ${xpath_snmp_alerts_sub_menu}
204 Wait Until Keyword Succeeds 30 sec 10 sec Location Should Contain snmp-alerts
meghagn705c3642021-10-12 04:14:02 -0500205
206
207Configure SNMP Manager Via GUI
208 [Documentation] Configure SNMP manager via GUI.
209 [Arguments] ${snmp_ip} ${port}
210
211 # Description of argument(s):
212 # snmp_ip SNMP manager IP address.
213 # port SNMP manager port.
214
215 Click Element ${xpath_add_destination}
216 Wait Until Page Contains Element ${xpath_snmp_alert_destination_heading}
217 Input Text ${xpath_ip_address_input_button} ${snmp_ip}
218 Wait Until Keyword Succeeds 30 sec 5 sec Get Value ${xpath_ip_address_input_button}
219 Input Text ${xpath_port_optional_input_button} ${port}
220 Click Element ${xpath_snmp_add_destination_button}
221
222
223Delete SNMP Manager Via GUI
224 [Documentation] Delete SNMP manager via GUI.
meghagnfe16be92022-01-28 05:50:19 -0600225 [Arguments] ${snmp_mgr_ip} ${snmp_mgr_port}
meghagn705c3642021-10-12 04:14:02 -0500226
meghagnfe16be92022-01-28 05:50:19 -0600227 # Description of argument(s):
228 # snmp_mgr_ip SNMP manager IP address.
229 # snmp_mgr_port SNMP manager port.
230
231 Wait Until Page Contains ${snmp_mgr_ip} ${snmp_mgr_port}
meghagn705c3642021-10-12 04:14:02 -0500232 Click Element At Coordinates ${xpath_select_all_snmp} 0 0
233 Wait Until Keyword Succeeds 30 sec 5 sec Click Element ${xpath_delete_button}
234 Wait Until Page Contains Delete SNMP alert destination
235 Click Element ${xpath_delete_destination}
meghagna80e4d42021-12-14 05:46:15 -0600236 Wait Until Page Contains Successfully deleted SNMP alert destination timeout=45s
meghagnc2436bc2021-10-11 03:49:21 -0500237 Wait Until Keyword Succeeds 30 sec 10 sec Refresh GUI And Verify Element Value
Megha GNc7bcf7c2022-08-04 05:30:58 -0500238 ... ${xpath_snmp_alerts_heading} ${snmp_page_heading}
meghagnd3b19ac2021-10-22 01:09:25 -0500239
240
241Configure SNMP Manager On BMC With Invalid Setting Via GUI And Verify
242
243 [Documentation] Configure SNMP manager on BMC with invalid setting via GUI and verify.
244 [Arguments] ${snmp_manager_ip} ${snmp_manager_port} ${expected_error}
Megha GNc7bcf7c2022-08-04 05:30:58 -0500245 [Teardown] Run Keyword If '${expected_error}' == '${invalid_port_error}'
246 ... Click Element ${xpath_cancel_button}
meghagnd3b19ac2021-10-22 01:09:25 -0500247
248 # Description of argument(s):
249 # snmp_manager_ip SNMP manager IP address.
250 # snmp_manager_port SNMP manager port.
251 # expected_error Expected error optionally provided in testcase
252 # .... (e.g. Invalid format / Value must be between 0 – 65535).
253
254 Configure SNMP Manager Via GUI ${snmp_manager_ip} ${snmp_manager_port}
255 Wait Until Page Contains ${expected_error}
256 ${status}= Run Keyword And Return Status
257 ... Verify SNMP Manager Configured On BMC ${snmp_manager_ip} ${snmp_manager_port}
258 Should Be Equal As Strings ${status} False
259 ... msg=BMC is allowing to configure with invalid SNMP settings.
meghagn5a4ddb02021-11-09 01:49:23 -0600260
261
262Configure Multiple SNMP Managers On BMC With Valid Port Via GUI And Verify
263 [Documentation] Configure multiple SNMP managers on BMC with valid port value via GUI and verify.
264 [Arguments] ${snmp_ip_value} ${snmp_port_value}
meghagnfe16be92022-01-28 05:50:19 -0600265 [Teardown] Delete SNMP Manager Via GUI ${snmp_ip_value} ${snmp_port_value}
meghagn5a4ddb02021-11-09 01:49:23 -0600266
267 # Description of argument(s):
268 # snmp_ip_value SNMP manager IP address.
269 # snmp_port_value SNMP manager port.
270
271 Configure SNMP Manager Via GUI ${snmp_ip_value} ${snmp_port_value}
272 Verify SNMP Manager Configured On BMC ${snmp_ip_value} ${snmp_port_value}
meghagn725ccdd2022-02-09 04:55:52 -0600273
274
275Create Error On BMC And Verify Trap On Default Port
276 [Documentation] Generate error on BMC and verify if trap is sent to default port.
277 [Arguments] ${event_log}=${CMD_INTERNAL_FAILURE} ${expected_error}=${SNMP_TRAP_BMC_INTERNAL_FAILURE}
278
279 # Description of argument(s):
280 # event_log Event logs to be created.
281 # expected_error Expected error on SNMP.
282
283 Configure SNMP Manager Via GUI ${SNMP_MGR1_IP} ${SNMP_DEFAULT_PORT}
284
285 Start SNMP Manager
286
287 # Generate error log.
288 BMC Execute Command ${event_log}
289
290 SSHLibrary.Switch Connection snmp_server
291 ${SNMP_LISTEN_OUT}= Read delay=1s
292
293 # Stop SNMP manager process.
294 SSHLibrary.Execute Command sudo killall snmptrapd
295
296 # Sample SNMP trap:
297 # 2021-06-16 07:05:29 xx.xx.xx.xx [UDP: [xx.xx.xx.xx]:58154->[xx.xx.xx.xx]:xxx]:
298 # DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (2100473) 5:50:04.73
299 # SNMPv2-MIB::snmpTrapOID.0 = OID: SNMPv2-SMI::enterprises.49871.1.0.0.1
300 # SNMPv2-SMI::enterprises.49871.1.0.1.1 = Gauge32: 369 SNMPv2-SMI::enterprises.49871.1.0.1.2 = Opaque:
301 # UInt64: 1397718405502468474 SNMPv2-SMI::enterprises.49871.1.0.1.3 = INTEGER: 3
302 # SNMPv2-SMI::enterprises.49871.1.0.1.4 = STRING: "xxx.xx.xx Failure"
303
304 ${lines}= Split To Lines ${SNMP_LISTEN_OUT}
305 ${trap_info}= Get From List ${lines} -1
306 ${snmp_trap}= Split String ${trap_info} \t
307
308 Verify SNMP Trap ${snmp_trap} ${expected_error}