Add a keyword to flush all sessions connected
Changes:
- This change is for open power code where all the sessions
created needed to be cleaned.
- Add a keyword to delete all session
- Restart bmcweb on test case failure
Tested:
- Ran test suite from sandbox clean
Change-Id: I3b2b050d840a70859f4971fc31550252c8a68b5c
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/openpower/ext_interfaces/test_lock_management.robot b/openpower/ext_interfaces/test_lock_management.robot
index 9b7017d..399a75f 100644
--- a/openpower/ext_interfaces/test_lock_management.robot
+++ b/openpower/ext_interfaces/test_lock_management.robot
@@ -10,10 +10,10 @@
Library ../../lib/bmc_network_utils.py
Library JSONLibrary
-Suite Setup Run Keyword And Ignore Error Delete All Redfish Sessions
-Suite Teardown Run Keyword And Ignore Error Delete All Redfish Sessions
-Test Setup Printn
-Test Teardown FFDC On Test Case Fail
+Suite Setup Run Keyword And Ignore Error Delete All Redfish And HMC Sessions
+Suite Teardown Run Keyword And Ignore Error Delete All Redfish And HMC Sessions
+Test Setup Delete All Redfish And HMC Sessions
+Test Teardown Run Keywords FFDC On Test Case Fail AND Restart Bmcweb On Failure
*** Variables ***
@@ -350,7 +350,7 @@
# (e.g. 12345, "HMCID").
${session_info}= Create Dictionary
- ${session}= Redfish Login kwargs= "Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
+ ${session}= Redfish Login kwargs="Oem":{"OpenBMC" : {"ClientID":"${client_id}"}}
Set To Dictionary ${session_info} SessionIDs ${session['Id']}
Set To Dictionary ${session_info} ClientID ${session["Oem"]["OpenBMC"]["ClientID"]}
@@ -1407,3 +1407,37 @@
Verify Lock On Resource ${session_info1}[0] ${trans_id_emptylist}
Redfish Delete Session ${session_info1}[0]
+
+
+Delete All Redfish and HMC Sessions
+ [Documentation] Delete all active redfish sessions.
+
+ ${saved_session_info}= Get Redfish Session Info
+
+ ${resp_list}= Redfish_Utils.Get Member List
+ ... /redfish/v1/SessionService/Sessions
+
+ # Remove the current login session from the list.
+ Remove Values From List ${resp_list} ${saved_session_info["location"]}
+
+ FOR ${session} IN @{resp_list}
+ Run Keyword And Ignore Error Redfish.Delete ${session}
+ END
+
+
+Restart Bmcweb On Failure
+ [Documentation] Restart bmcweb only if test failed.
+
+ Return From Keyword If "${TEST_STATUS}" == "PASS"
+
+ # This procedure is needs to be corrected or removed, when we figure out
+ # what is causing the real failure here.
+
+ Log To Console Likely ConnectionResetError: Restarting bmcweb
+
+ ${stdout} ${stderr} ${rc}= BMC Execute Command
+ ... systemctl restart bmcweb print_out=1
+
+ Should Be Empty ${stderr}
+
+ Sleep 10s reason=Wait for service to restart properly.