Added vmi certificate stage2 testcases and supporting library functions
Changes-
added testcases:
-Get_Concurrent_Root_Certificate_Requests_From_Multiple_Admins
-Get_Concurrent_CSR_Requests_From_Multiple_Admins
-Get_Concurrent_Corrupted_CSR_Requests_From_Multiple_Admins
library functions:
-execute_keyword_args
-execute_process_multi_keyword
Change-Id: I9cd8266ba4213eb6a476b9666beb512872f87dde
Signed-off-by: shrsuman123 <shrsuman@in.ibm.com>
diff --git a/lib/jobs_processing.py b/lib/jobs_processing.py
index ea9bc67..3368bd7 100644
--- a/lib/jobs_processing.py
+++ b/lib/jobs_processing.py
@@ -9,6 +9,7 @@
from robot.libraries.BuiltIn import BuiltIn
from multiprocessing import Process, Manager
import os
+import datetime
import gen_print as gp
@@ -58,3 +59,60 @@
# Return function return codes.
return return_dict
+
+
+def execute_keyword_args(keyword_name, args, return_dict):
+ r"""
+ Execute a robot keyword with arguments.
+ In addition to running the caller's keyword, this function will:
+ - Add an entry to the return_dict
+ Description of argument(s):
+ keyword_name Keyword name to be executed.
+ args Arguments to keyword.
+ return_dict A dictionary consisting of pid/process status for the
+ keys/values. This function will append a new entry to
+ this dictionary.
+ """
+
+ execution_time = datetime.datetime.now()
+
+ status = BuiltIn().run_keyword_and_return_status(keyword_name, *args)
+
+ # Build execution time:<status> dictionary.
+ return_dict[str(execution_time)] = str(status)
+
+
+def execute_process_multi_keyword(number_args, *keyword_names):
+ r"""
+ Execute multiple robot keywords with arguments via multiprocessing process.
+
+ Description of argument(s):
+ number_args Number of argument in keywords.
+ keyword_names Keyword name to be executed.
+ """
+
+ manager = Manager()
+ return_dict = manager.dict()
+ process_list = []
+ # Append each keyword with its arguments in a process to execute.
+ for keywords_data in keyword_names:
+ keyword_args = tuple(keywords_data.split(" ")[-number_args:])
+ keyword_name = " ".join(keywords_data.split(" ")[:-number_args])
+ task = Process(target=execute_keyword_args,
+ args=(keyword_name, keyword_args, return_dict))
+ process_list.append(task)
+ task.start()
+
+ # Wait for process to complete.
+ for task in process_list:
+ task.join()
+ return return_dict
+
+
+def get_current_date_time():
+ r"""
+ Gets current time.
+ """
+
+ current_time = datetime.datetime.now().strftime("%H:%M:%S.%f")
+ return current_time
diff --git a/openpower/ext_interfaces/test_vmicert_management.robot b/openpower/ext_interfaces/test_vmicert_management.robot
index 88129be..ab4280a 100644
--- a/openpower/ext_interfaces/test_vmicert_management.robot
+++ b/openpower/ext_interfaces/test_vmicert_management.robot
@@ -2,6 +2,7 @@
Documentation VMI certificate exchange tests.
+Library ../../lib/jobs_processing.py
Resource ../../lib/resource.robot
Resource ../../lib/bmc_redfish_resource.robot
Resource ../../lib/openbmc_ffdc.robot
@@ -23,8 +24,7 @@
&{USERS} Administrator=${ADMIN} Operator=${OPERATOR} ReadOnly=${ReadOnly}
... NoAccess=${NoAccess}
${VMI_BASE_URI} /ibm/v1/
-${CSR_FILE} csr_server.csr
-${CSR_KEY} csr_server.key
+
*** Test Cases ***
@@ -140,12 +140,58 @@
# Request root certificate from NoAccess user.
noaccess_user TestPwd123 ${False} ${True} ${HTTP_FORBIDDEN}
+Get Concurrent Root Certificate Requests From Multiple Admin Users
+ [Documentation] Get multiple concurrent root certificate requests from multiple admins
+ ... and verify no errors.
+ [Tags] Get_Concurrent_Root_Certificate_Requests_From_Multiple_Admin_Users
+
+ FOR ${i} IN RANGE ${5}
+ ${dict}= Execute Process Multi Keyword ${5}
+ ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
+ ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
+ ... Get Root Certificate ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
+ Dictionary Should Not Contain Value ${dict} False
+ ... msg=One or more operations has failed.
+ END
+
+Get Concurrent CSR Requests From Multiple Admin Users
+ [Documentation] Get multiple concurrent csr requests from multiple admins and verify no errors.
+ [Tags] Get_Concurrent_CSR_Requests_From_Multiple_Admin_Users
+
+ FOR ${i} IN RANGE ${5}
+ ${dict}= Execute Process Multi Keyword ${5}
+ ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
+ ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
+ ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
+ ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${True} ${HTTP_OK}
+ Dictionary Should Not Contain Value ${dict} False
+ ... msg=One or more operations has failed.
+ END
+
+Get Concurrent Corrupted CSR Requests From Multiple Admin Users
+ [Documentation] Get multiple concurrent corrupted csr requests from multiple admins and verify no errors.
+ [Tags] Get_Concurrent_Corrupted_CSR_Requests_From_Multiple_Admin_Users
+
+ FOR ${i} IN RANGE ${5}
+ ${dict}= Execute Process Multi Keyword ${5}
+ ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_INTERNAL_SERVER_ERROR}
+ ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_INTERNAL_SERVER_ERROR}
+ ... Get Certificate Signed By VMI ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} ${True} ${False} ${HTTP_INTERNAL_SERVER_ERROR}
+ Dictionary Should Not Contain Value ${dict} False
+ ... msg=One or more operations has failed.
+ END
+
*** Keywords ***
Generate CSR String
[Documentation] Generate a csr string.
# Note: Generates and returns csr string.
+ ${csr_gen_time} = Get Current Date Time
+ ${CSR_FILE}= Catenate SEPARATOR=_ ${csr_gen_time} csr_server.csr
+ ${CSR_KEY}= Catenate SEPARATOR=_ ${csr_gen_time} csr_server.key
+ Set Test Variable ${CSR_FILE}
+ Set Test Variable ${CSR_KEY}
${ssl_cmd}= Set Variable openssl req -new -newkey rsa:2048 -nodes -keyout ${CSR_KEY} -out ${CSR_FILE}
${ssl_sub}= Set Variable
... -subj "/C=XY/ST=Abcd/L=Efgh/O=ABC/OU=Systems/CN=abc.com/emailAddress=xyz@xx.ABC.com"
@@ -181,6 +227,7 @@
Set To Dictionary ${data} data ${csr_data}
${resp}= Post Request openbmc ${cert_uri} &{data} headers=${headers}
+ Log to console ${resp.content}
[Return] ${resp}
@@ -285,10 +332,12 @@
# create a crt file with certificate string
${signed_cert}= Set Variable ${cert["Certificate"]}
+ ${testcert_gen_time} = Get Current Date Time
+ ${test_cert_file}= Catenate SEPARATOR=_ ${testcert_gen_time} test_certificate.cert
- Create File test_certificate.crt ${signed_cert}
- ${subject_signed_csr}= Get Subject test_certificate.crt False
- ${pubKey_signed_csr}= Get Public Key test_certificate.crt False
+ Create File ${test_cert_file} ${signed_cert}
+ ${subject_signed_csr}= Get Subject ${test_cert_file} False
+ ${pubKey_signed_csr}= Get Public Key ${test_cert_file} False
Should be equal as strings ${subject_signed_csr} ${subject_csr}
Should be equal as strings ${pubKey_signed_csr} ${pubKey_csr}
@@ -297,14 +346,17 @@
Suite Setup Execution
[Documentation] Suite setup execution.
+ Remove Files *.csr *.key *.cert
# Create different user accounts.
Redfish.Login
+ Redfish Power On
Create Users With Different Roles users=${USERS} force=${True}
Suite Teardown Execution
[Documentation] Suite teardown execution.
+ Remove Files *.csr *.key *.cert
Delete BMC Users Via Redfish users=${USERS}
Delete All Sessions
Redfish.Logout