openbmc / openbmc-test-automation

Apache License 2.0
100 stars 92 forks source link

refactoring of redfish/dmtf_tools/Redfish_Service_Validator.robot #2178

Closed generatz closed 2 years ago

generatz commented 2 years ago

Some of the command arguments are outdated or have changed, and there are other typos; before refactoring, when it fails, the robot test case does not return the desired test output information.

I also changed the Run DMTF Tool keyword in lib/dmtf_tools_utils.robot to return the command return code, rc. ${rc} is a simple and failsafe way to verify that the DMTF command does or does not fail, independent of correctly processing the output it generates.

Here is a patch:

diff --git a/lib/dmtf_tools_utils.robot b/lib/dmtf_tools_utils.robot
index 1fb538f2..9387c51a 100644
--- a/lib/dmtf_tools_utils.robot
+++ b/lib/dmtf_tools_utils.robot
@@ -36,7 +36,7 @@ Run DMTF Tool

     ${rc}  ${output}=  Shell Cmd  ${command_string}  ignore_err=${check_error}
     Log  ${output}
-    [Return]  ${output}
+    [Return]  ${rc}  ${output}

 Redfish Service Validator Result
diff --git a/redfish/dmtf_tools/Redfish_Service_Validator.robot b/redfish/dmtf_tools/Redfish_Service_Validator.robot
index da51e57c..416e75a2 100644
--- a/redfish/dmtf_tools/Redfish_Service_Validator.robot
+++ b/redfish/dmtf_tools/Redfish_Service_Validator.robot
@@ -1,3 +1,4 @@
+# -*- coding: robot -*-
 *** Settings ***
 Documentation      Test BMC using https://github.com/DMTF/Redfish-Service-Validator.
 ...                DMTF tool.
@@ -25,9 +26,10 @@ Test BMC Redfish Using Redfish Service Validator

     Download DMTF Tool  ${rsv_dir_path}  ${rsv_github_url}

-    ${output}=  Run DMTF Tool  ${rsv_dir_path}  ${cmd_str_master}
+    ${rc}  ${output}=  Run DMTF Tool  ${rsv_dir_path}  ${cmd_str_master}   check_error=1

     Redfish Service Validator Result  ${output}
+    Run Keyword If  ${rc} != 0  fail

 Run Redfish Service Validator With Additional Roles
@@ -63,14 +65,15 @@ Create User And Run Service Validator
     Download DMTF Tool  ${rsv_dir_path}  ${rsv_github_url}

     ${cmd}=  Catenate  ${DEFAULT_PYTHON} ${rsv_dir_path}${/}RedfishServiceValidator.py
-    ...  --ip https://${OPENBMC_HOST}:${HTTPS_PORT} --nochkcert --authtype=Session -u ${username}
-    ...  -p ${password} --logdir ${EXECDIR}${/}logs_${username}${/} --debug_logging
+    ...  --ip https://${OPENBMC_HOST}:${HTTPS_PORT} --authtype=Session -u ${username}
+    ...  -p ${password} --logdir ${EXECDIR}${/}logs_${username}${/} --debugging

-    Rprint Vars  cmd
+    Rprint Vars  ${cmd}

-    ${output}=  Run DMTF Tool  ${rsv_dir_path}  ${cmd}
+    ${rc}  ${output}=  Run DMTF Tool  ${rsv_dir_path}  ${cmd}   check_error=1

     Redfish Service Validator Result  ${output}
+    Run Keyword If  ${rc} != 0  fail

 Delete User Created
gkeishin commented 2 years ago

https://gerrit.openbmc-project.xyz/c/openbmc/openbmc-test-automation/+/52380