Robustness enhancements to test_ipmi_user
- Includes refactoring code from test_ipmi_user to ipmi_client,
which will allow greater reuse.
- Ipmi_client changes:
- Enhancements to keyword: Create Random IPMI User
-- invokes Find Free User ID : to prevent clobbering pre-existing
IPMI userIDs;
-- invokes Wait And Confirm New User Entry : so that we have
confirmation before returning.
- In support of this:
- Add necessary Variables;
- Pull over keywords from test_ipmi_user :
-- Find Free User Id
-- Check Enabled User Count
-- Wait And Confirm New User Entry
-- Verify IPMI Username Visible.
- Test_ipmi_user changes:
- Remove unused variable (moved to ipmi_client);
- Verify IPMI User Summary : remove now redundant
Wait And Confirm New User Entry, since incorporated into
Create Random IPMI User;
- Test IPMI User Privilege : invoke the new and enhanced
Create Random IPMI User , to prevent clobbering pre-existing
IPMI userIDs and leverage the built-in confirmation;
- Remove the keywords that are being pulled over to ipmi_client.
Additional test_ipmi_user changes for robustness,
consistent with use already elsewhere in this suite:
- Verify Administrator And User Privilege For Different Channels :
Sleep 5s delay after Set Channel Access to allow privileges to set;
- Verify Operator And User Privilege For Different Channels :
Sleep 5s delay after Set Channel Access to allow privileges to set.
Tested: on x86 platforms.
Change-Id: I10548d5ad7f85542ab5b6b165dddb01089da0661
Signed-off-by: Ruud A. Haring <ruud@us.ibm.com>
diff --git a/ipmi/test_ipmi_user.robot b/ipmi/test_ipmi_user.robot
index 7d913e3..f356736 100644
--- a/ipmi/test_ipmi_user.robot
+++ b/ipmi/test_ipmi_user.robot
@@ -30,7 +30,6 @@
... 7=0penBmc 8=0penBmc0
${expected_max_ids} 15
${root_pattern} ^.*\\sroot\\s.*ADMINISTRATOR.*$
-${empty_name_pattern} ^User Name\\s.*\\s:\\s$
# User defined count.
${USER_LOOP_COUNT} 20
@@ -47,7 +46,6 @@
${initial_user_count} ${maximum_ids}= Get Enabled User Count
${random_userid} ${random_username}= Create Random IPMI User
- Wait And Confirm New User Entry ${random_username}
Set Test Variable ${random_userid}
Run IPMI Standard Command user enable ${random_userid}
@@ -378,6 +376,9 @@
# Set user privilege for newly created user with channel 2.
Set Channel Access ${random_userid} ipmi=on privilege=${user_priv} ${secondary_channel_number}
+ # Delay added for user privileges to get set.
+ Sleep 5s
+
Enable IPMI User And Verify ${random_userid}
# Verify that user is able to run administrator level IPMI command with channel 1.
@@ -406,6 +407,9 @@
# Set user privilege for newly created user with channel 2.
Set Channel Access ${random_userid} ipmi=on privilege=${user_priv} ${secondary_channel_number}
+ # Delay added for user privileges to get set.
+ Sleep 5s
+
Enable IPMI User And Verify ${random_userid}
# Verify that user is able to run operator level IPMI command with channel 1.
@@ -540,9 +544,7 @@
# privilege (i.e. "Passed" or "Failed").
# Create IPMI user and set valid password.
- ${random_username}= Generate Random String 8 [LETTERS]
- ${random_userid}= Evaluate random.randint(2, 15) modules=random
- IPMI Create User ${random_userid} ${random_username}
+ ${random_userid} ${random_username}= Create Random IPMI User
Set Test Variable ${random_userid}
Run IPMI Standard Command
... user set password ${random_userid} ${valid_password}
@@ -651,18 +653,6 @@
Run Keyword If '${IPMI_USERNAME}' == 'root' Determine Root User Id
-Check Enabled User Count
- [Documentation] Ensure that there are available user IDs.
-
- # Check for the enabled user count
- ${resp}= Run IPMI Standard Command user summary ${CHANNEL_NUMBER}
- ${enabled_user_count}=
- ... Get Lines Containing String ${resp} Enabled User Count
-
- Should not contain ${enabled_user_count} ${expected_max_ids}
- ... msg=IPMI have reached maximum user count
-
-
Determine Root User Id
[Documentation] Determines the user ID of the root user.
@@ -719,43 +709,3 @@
${int_maximum_ids_count}= Convert To Integer ${max_ids}
[Return] ${user_count} ${int_maximum_ids_count}
-
-
-Wait And Confirm New User Entry
- [Documentation] Wait in loop until new user appears with given username.
- [Arguments] ${username}
-
- # Description of argument(s):
- # username The user name (e.g. "root", "robert", etc.).
-
- Wait Until Keyword Succeeds 45 sec 1 sec Verify IPMI Username Visible
- ... ${username}
-
-
-Verify IPMI Username Visible
- [Documentation] Confirm that username is present in user list.
- [Arguments] ${username}
-
- # Description of argument(s):
- # username The user name (e.g. "root", "robert", etc.).
-
- ${resp}= Run IPMI Standard Command user list
- Should Contain ${resp} ${username}
-
-
-Find Free User Id
- [Documentation] Find a user ID that is not being used.
-
- Check Enabled User Count
- FOR ${num} IN RANGE 300
- ${random_userid}= Evaluate random.randint(1, ${expected_max_ids}) modules=random
- ${access}= Run IPMI Standard Command channel getaccess ${CHANNEL_NUMBER} ${random_userid}
-
- ${name_line}= Get Lines Containing String ${access} User Name
- Log To Console For ID ${random_userid}: ${name_line}
- ${is_empty}= Run Keyword And Return Status
- ... Should Match Regexp ${name_line} ${empty_name_pattern}
-
- Exit For Loop If ${is_empty} == ${True}
- END
- [Return] ${random_userid}
diff --git a/lib/ipmi_client.robot b/lib/ipmi_client.robot
index 984b187..2088df3 100755
--- a/lib/ipmi_client.robot
+++ b/lib/ipmi_client.robot
@@ -22,7 +22,9 @@
${IPMI_INBAND_CMD}= ipmitool -C ${IPMI_CIPHER_LEVEL} -N ${IPMI_TIMEOUT} -p ${IPMI_PORT}
${HOST}= -H
${RAW}= raw
-${IPMITOOL_PATH} /tmp/ipmitool
+${IPMITOOL_PATH} /tmp/ipmitool
+${expected_max_ids} 15
+${empty_name_pattern} ^User Name\\s.*\\s:\\s$
*** Keywords ***
@@ -430,11 +432,64 @@
[Documentation] Create IPMI user with random username and userid and return those fields.
${random_username}= Generate Random String 8 [LETTERS]
- ${random_userid}= Evaluate random.randint(2, 15) modules=random
+ ${random_userid}= Find Free User Id
IPMI Create User ${random_userid} ${random_username}
+ Wait And Confirm New User Entry ${random_username}
[Return] ${random_userid} ${random_username}
+Find Free User Id
+ [Documentation] Find a userid that is not being used.
+
+ Check Enabled User Count
+ FOR ${num} IN RANGE 300
+ ${random_userid}= Evaluate random.randint(1, ${expected_max_ids}) modules=random
+ ${access}= Run IPMI Standard Command channel getaccess ${CHANNEL_NUMBER} ${random_userid}
+
+ ${name_line}= Get Lines Containing String ${access} User Name
+ Log To Console For ID ${random_userid}: ${name_line}
+ ${is_empty}= Run Keyword And Return Status
+ ... Should Match Regexp ${name_line} ${empty_name_pattern}
+
+ Exit For Loop If ${is_empty} == ${True}
+ END
+ [Return] ${random_userid}
+
+
+Check Enabled User Count
+ [Documentation] Ensure that there are available user IDs.
+
+ # Check for the enabled user count
+ ${resp}= Run IPMI Standard Command user summary ${CHANNEL_NUMBER}
+ ${enabled_user_count}=
+ ... Get Lines Containing String ${resp} Enabled User Count
+
+ Should not contain ${enabled_user_count} ${expected_max_ids}
+ ... msg=IPMI has reached maximum user count
+
+
+Wait And Confirm New User Entry
+ [Documentation] Wait in loop until new user appears with given username.
+ [Arguments] ${username}
+
+ # Description of argument(s):
+ # username The user name (e.g. "root", "robert", etc.).
+
+ Wait Until Keyword Succeeds 45 sec 1 sec Verify IPMI Username Visible
+ ... ${username}
+
+
+Verify IPMI Username Visible
+ [Documentation] Confirm that username is present in user list.
+ [Arguments] ${username}
+
+ # Description of argument(s):
+ # username The user name (e.g. "root", "robert", etc.).
+
+ ${resp}= Run IPMI Standard Command user list
+ Should Contain ${resp} ${username}
+
+
Delete Created User
[Documentation] Delete created IPMI user.
[Arguments] ${userid}