Fix for redfishtool certificate, snmp and session management
Changes:
- Set cert_id as test variable
- Remove colon in snmp destination when the snmp port is empty
- Fix redfish_delete_sessions assign location
- Set REDFISH_DELETE_SESSIONS to 0 in suite setup
- Set REDFISH_DELETE_SESSIONS back to 1 in suite teardown
Tested:
- redfish/service_root/test_sessions_management.robot
- redfish/dmtf_tools/test_redfishtool_certificate.robot
- redfish/events/test_bmc_snmp_trap.robot
Change-Id: Ibb16d52b5874484f8cf169456e2feb4ba7593e71
Signed-off-by: Wilson Suen <wilsons@supermicro.com>
diff --git a/lib/bmc_redfish_utils.robot b/lib/bmc_redfish_utils.robot
index 6cb7526..fbac104 100644
--- a/lib/bmc_redfish_utils.robot
+++ b/lib/bmc_redfish_utils.robot
@@ -64,6 +64,16 @@
Redfish.Post ${target} valid_status_codes=[${HTTP_OK}]
+Set Redfish Delete Session Flag
+ [Documentation] Disable or enable delete redfish while performing the power operation keyword.
+ [Arguments] ${set_flag}
+
+ # Description of argument(s):
+ # set_flag Set user specified enable(1) or disable(0).
+
+ Set Suite Variable ${REDFISH_DELETE_SESSIONS} ${set_flag}
+
+
Redfish Delete Session
[Documentation] Redfish delete session.
[Arguments] ${session_info}
diff --git a/lib/obmc_boot_test.py b/lib/obmc_boot_test.py
index 8e0c17e..5b3d7de 100755
--- a/lib/obmc_boot_test.py
+++ b/lib/obmc_boot_test.py
@@ -1077,6 +1077,11 @@
global boot_success
global boot_end_time
+ # The flag can be enabled or disabled on the go
+ redfish_delete_sessions = int(
+ BuiltIn().get_variable_value("${REDFISH_DELETE_SESSIONS}", default=1)
+ )
+
gp.qprintn()
next_boot = select_boot()
diff --git a/lib/snmp/redfish_snmp_utils.robot b/lib/snmp/redfish_snmp_utils.robot
index 109a971..57424aa 100644
--- a/lib/snmp/redfish_snmp_utils.robot
+++ b/lib/snmp/redfish_snmp_utils.robot
@@ -72,7 +72,8 @@
# snmp_port SNMP manager port
# valid_status_code expected code
- ${snmp_mgr_data}= Create Dictionary Destination=snmp://${snmp_mgr_ip}:${snmp_port}
+ ${colon}= Set Variable If '${snmp_port}' == '${EMPTY}' ${EMPTY} :
+ ${snmp_mgr_data}= Create Dictionary Destination=snmp://${snmp_mgr_ip}${colon}${snmp_port}
... SubscriptionType=${snmp_function} Protocol=${snmp_version}
Redfish.Post ${subscription_uri} body=&{snmp_mgr_data}
diff --git a/redfish/dmtf_tools/test_redfishtool_certificate.robot b/redfish/dmtf_tools/test_redfishtool_certificate.robot
index c3a53a9..7930a96 100644
--- a/redfish/dmtf_tools/test_redfishtool_certificate.robot
+++ b/redfish/dmtf_tools/test_redfishtool_certificate.robot
@@ -273,6 +273,7 @@
${cert_id}= Redfishtool Install Certificate File On BMC
... ${certificate_uri} ${expected_status} data=${file_data}
Logging Installed certificate id: ${cert_id}
+ Set Test Variable ${cert_id}
# Adding delay after certificate installation.
Sleep 30s
diff --git a/redfish/service_root/test_sessions_connection.robot b/redfish/service_root/test_sessions_connection.robot
index d5f5303..e371ddc 100644
--- a/redfish/service_root/test_sessions_connection.robot
+++ b/redfish/service_root/test_sessions_connection.robot
@@ -5,8 +5,8 @@
Resource ../../lib/bmc_redfish_utils.robot
Resource ../../lib/openbmc_ffdc.robot
-Suite Setup Disable Redfish Delete Session
-Suite Teardown Run Keywords Enable Redfish Delete Session AND Redfish.Logout
+Suite Setup Set Redfish Delete Session Flag ${0}
+Suite Teardown Run Keywords Set Redfish Delete Session Flag ${1} AND Redfish.Logout
Test Setup Printn
Test Teardown FFDC On Test Case Fail
@@ -16,7 +16,6 @@
${duration} 6h
${interval} 30s
${reboot_interval} 30m
-${REDFISH_DELETE_SESSIONS} ${0}
*** Test Cases ***
@@ -60,15 +59,3 @@
# Verify session is still active and no issues on connection after reboot.
Repeat Keyword ${reboot_interval} Send Heartbeat
-
-Disable Redfish Delete Session
- [Documentation] Disable delete redfish while performing power operation keyword.
-
- ${REDFISH_DELETE_SESSIONS}= Set Variable ${0}
- Set Suite Variable ${REDFISH_DELETE_SESSIONS}
-
-Enable Redfish Delete Session
- [Documentation] Enable delete redfish while performing power operation keyword.
-
- ${REDFISH_DELETE_SESSIONS}= Set Variable ${1}
- Set Suite Variable ${REDFISH_DELETE_SESSIONS}
\ No newline at end of file
diff --git a/redfish/service_root/test_sessions_management.robot b/redfish/service_root/test_sessions_management.robot
index 31aa3b4..0bde4f9 100644
--- a/redfish/service_root/test_sessions_management.robot
+++ b/redfish/service_root/test_sessions_management.robot
@@ -18,6 +18,7 @@
# User-driven input parameter to skip operator user.
# -v SKIP_OPERATOR_USER:1 to skip from CLI.
${SKIP_OPERATOR_USER} ${0}
+${REDFISH_DELETE_SESSIONS} ${0}
*** Test Cases ***
@@ -293,11 +294,13 @@
Create Users With Different Roles users=${USERS} force=${True}
Get Default Timeout Value
+ Set Redfish Delete Session Flag ${0}
Suite Teardown Execution
[Documentation] Suite teardown execution.
Delete BMC Users Via Redfish users=${USERS}
+ Set Redfish Delete Session Flag ${1}
Run Keyword And Ignore Error Delete All Redfish Sessions
Redfish.Logout