Added validation for power operation testcases using LDAP user.
Added code to check the host state after power operation and wait
until the host is up for power on.
Moved Redfish.Login to Test Teardown, to make the next testcase execute
with root user.
Added code to delete all redfish session in suite teardown.
Tested: Run robot redfish/account_service/test_ldap_configuration.robot
Signed-off-by: agarjun B <nagarjunb@ami.com>
Change-Id: Iaafe0657d41a82be067c1ea91fe02ef995567394
diff --git a/lib/utils.robot b/lib/utils.robot
index 5e82041..1032514 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -1085,3 +1085,22 @@
Redfish.login
${bmc_status}= Redfish.Get Attribute /redfish/v1/Managers/bmc Status
Should Be Equal ${bmc_status["State"]} Enabled
+
+
+Verify Host Power State
+ [Documentation] Get the Host Power state and compare it with the expected state.
+ [Arguments] ${expected_power_state}
+
+ # Description of argument(s):
+ # expected_power_state State of Host e.g. Off or On.
+
+ ${power_state} ${health_status}= Redfish Get Host State
+ Should Be Equal ${power_state} ${expected_power_state}
+
+
+Verify Host Is Up
+ [Documentation] Verify Host is Up.
+
+ Wait Until Keyword Succeeds 3 min 30 sec Verify Host Power State On
+ # Python module: os_execute(cmd)
+ Wait Until Keyword Succeeds 10 min 30 sec OS Execute Command uptime
diff --git a/redfish/account_service/test_ldap_configuration.robot b/redfish/account_service/test_ldap_configuration.robot
index 04ff9dc..bce906a 100644
--- a/redfish/account_service/test_ldap_configuration.robot
+++ b/redfish/account_service/test_ldap_configuration.robot
@@ -5,13 +5,14 @@
Resource ../../lib/resource.robot
Resource ../../lib/bmc_redfish_resource.robot
Resource ../../lib/openbmc_ffdc.robot
+Resource ../../lib/utils.robot
Library ../../lib/gen_robot_valid.py
Resource ../../lib/bmc_network_utils.robot
Resource ../../lib/bmc_ldap_utils.robot
Suite Setup Suite Setup Execution
-Suite Teardown Run Keywords Restore LDAP Privilege AND Redfish.Logout
-Test Teardown FFDC On Test Case Fail
+Suite Teardown LDAP Suite Teardown Execution
+Test Teardown Run Keywords Redfish.Login AND FFDC On Test Case Fail
Force Tags LDAP_Test
@@ -35,7 +36,6 @@
Sleep 10s
Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
Redfish.Logout
- Redfish.Login
Verify LDAP Service Disable
@@ -56,7 +56,6 @@
Redfish.Patch ${REDFISH_BASE_URI}AccountService
... body={'${LDAP_TYPE}': {'ServiceEnabled': ${True}}}
Redfish.Logout
- Redfish.Login
Verify LDAP Login With ServiceEnabled
@@ -71,7 +70,6 @@
# After update, LDAP login.
Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
Redfish.Logout
- Redfish.Login
Verify LDAP Login With Correct AuthenticationType
@@ -84,7 +82,6 @@
# After update, LDAP login.
Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
Redfish.Logout
- Redfish.Login
Verify LDAP Config Update With Incorrect AuthenticationType
@@ -127,7 +124,6 @@
Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
Redfish.Logout
- Redfish.Login
Verify LDAP Service Available
@@ -146,7 +142,6 @@
Redfish OBMC Reboot (off)
Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
Redfish.Logout
- Redfish.Login
Verify LDAP User With Admin Privilege Able To Do BMC Reboot
@@ -161,7 +156,6 @@
Redfish OBMC Reboot (off)
Redfish.Login ${LDAP_USER} ${LDAP_USER_PASSWORD}
Redfish.Logout
- Redfish.Login
Verify LDAP User With Operator Privilege Able To Do Host Poweroff
@@ -324,6 +318,7 @@
... right LDAP user fails.
[Tags] Verify_LDAP_Login_With_Invalid_Data
[Teardown] Run Keywords FFDC On Test Case Fail AND
+ ... Redfish.Login AND
... Create LDAP Configuration
Create LDAP Configuration ${LDAP_TYPE} Invalid_LDAP_Server_URI
@@ -338,6 +333,7 @@
... created without BASE_DN fails.
[Tags] Verify_LDAP_Config_Creation_Without_BASE_DN
[Teardown] Run Keywords FFDC On Test Case Fail AND
+ ... Redfish.Login AND
... Create LDAP Configuration
Create LDAP Configuration ${LDAP_TYPE} Invalid_LDAP_Server_URI
@@ -361,6 +357,7 @@
... valid LDAP user fails.
[Tags] Verify_LDAP_Login_With_Invalid_BASE_DN
[Teardown] Run Keywords FFDC On Test Case Fail AND
+ ... Redfish.Login AND
... Create LDAP Configuration
Create LDAP Configuration ${LDAP_TYPE} ${LDAP_SERVER_URI}
@@ -374,6 +371,7 @@
... valid LDAP user fails.
[Tags] Verify_LDAP_Login_With_Invalid_BIND_DN_PASSWORD
[Teardown] Run Keywords FFDC On Test Case Fail AND
+ ... Redfish.Login AND
... Create LDAP Configuration
Create LDAP Configuration ${LDAP_TYPE} ${LDAP_SERVER_URI}
@@ -387,6 +385,7 @@
... BIND_DN and valid LDAP user fails.
[Tags] Verify_LDAP_Login_With_Invalid_BASE_DN_And_Invalid_BIND_DN
[Teardown] Run Keywords FFDC On Test Case Fail AND
+ ... Redfish.Login AND
... Create LDAP Configuration
Create LDAP Configuration ${LDAP_TYPE} ${LDAP_SERVER_URI}
@@ -411,6 +410,7 @@
... valid LDAP user fails.
[Tags] Verify_LDAP_Login_With_Invalid_BIND_DN
[Teardown] Run Keywords FFDC On Test Case Fail AND
+ ... Redfish.Login AND
... Create LDAP Configuration
Create LDAP Configuration ${LDAP_TYPE} ${LDAP_SERVER_URI}
@@ -560,7 +560,7 @@
# valid_status_codes Expected return code(s) from patch
# operation (e.g. "200") used to update
# HostName. See prolog of rest_request
- # method in redfish_plut.py for details.
+ # method in redfish_plus.py for details.
Update LDAP Configuration with LDAP User Role And Group ${LDAP_TYPE}
... ${group_privilege} ${group_name}
@@ -648,6 +648,14 @@
${hostname}= Redfish.Get Attribute ${REDFISH_NW_PROTOCOL_URI} HostName
+LDAP Suite Teardown Execution
+ [Documentation] Restore ldap configuration, delete unused redfish session.
+
+ Restore LDAP Privilege
+ Redfish.Logout
+ Run Keyword And Ignore Error Delete All Redfish Sessions
+
+
Set Read Privilege And Check Firmware Inventory
[Documentation] Set read privilege and check firmware inventory.
[Arguments] ${read_privilege}
@@ -737,6 +745,9 @@
[Documentation] Verify the Host power status and do host power on/off respectively.
[Arguments] ${expected_power_status}
+ # Description of argument(s):
+ # expected_power_status State of Host e.g. Off or On.
+
${power_status}= Redfish.Get Attribute /redfish/v1/Chassis/${CHASSIS_ID} PowerState
Return From Keyword If '${power_status}' == '${expected_power_status}'
@@ -765,6 +776,10 @@
Redfish.Post ${REDFISH_POWER_URI}
... body={'ResetType': 'ForceOff'} valid_status_codes=[${valid_status_code}]
+ Return From Keyword If ${valid_status_code} == ${HTTP_FORBIDDEN}
+ Wait Until Keyword Succeeds 1 min 10 sec Verify Host Power State Off
+
+
Update LDAP User Role And Host Poweron
[Documentation] Update LDAP user role and do host poweron.
[Arguments] ${ldap_type} ${group_privilege} ${group_name} ${valid_status_code}
@@ -787,6 +802,9 @@
Redfish.Post ${REDFISH_POWER_URI}
... body={'ResetType': 'On'} valid_status_codes=[${valid_status_code}]
+ Return From Keyword If ${valid_status_code} == ${HTTP_FORBIDDEN}
+ Verify Host Is Up
+
Update LDAP User Role And Configure IP Address
[Documentation] Update LDAP user role and configure IP address.