Added test to verify error while initiating BMC dump

Changes:

    - Added a new automation test case to verify errors while
      initiating BMC dump during the dumping state.
    - Added an argument to skip BMC dump completion in create
      dump keyword

Tested:

       - Ran Verify_Error_While_Initiating_BMC_Dump_During_Dumping_State
         the test case from the sandbox successfully.

Change-Id: Ifb487a5d299d870f51ddca270f86aea02597c179
Signed-off-by: manashsarma <manashsarma@in.ibm.com>
diff --git a/lib/dump_utils.robot b/lib/dump_utils.robot
index 62d1a72..bcd190e 100644
--- a/lib/dump_utils.robot
+++ b/lib/dump_utils.robot
@@ -276,6 +276,14 @@
 
 Create User Initiated BMC Dump Via Redfish
     [Documentation]  Generate user initiated BMC dump via Redfish and return the dump id number (e.g., "5").
+    [Arguments]  ${skip_dump_completion}=0
+
+    # Description of Argument(s):
+    # skip_dump_completion          If skip_dump_completion is set to 0, this
+    #                               keyword will waiting for BMC dump to
+    #                               complete and returns the dump id.
+    #                               Otherwise, the keyword is skipped after
+    #                               initiating BMC dump and returns dump task id.
 
     ${payload}=  Create Dictionary  DiagnosticDataType=Manager
     ${resp}=  Redfish.Post  /redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData
@@ -288,6 +296,7 @@
     # "TaskState": "Running",
     # "TaskStatus": "OK"
 
+    Run Keyword If  ${skip_dump_completion} != 0  Return From Keyword  ${resp.dict['Id']}
     Wait Until Keyword Succeeds  5 min  15 sec  Check Task Completion  ${resp.dict['Id']}
     ${task_id}=  Set Variable  ${resp.dict['Id']}
 
diff --git a/redfish/managers/test_bmc_dumps.robot b/redfish/managers/test_bmc_dumps.robot
index 616b872..7571f7c 100644
--- a/redfish/managers/test_bmc_dumps.robot
+++ b/redfish/managers/test_bmc_dumps.robot
@@ -239,6 +239,19 @@
     Should Be True  0 < ${resp["AdditionalDataSizeBytes"]} < 20971520
 
 
+Verify Error While Initiating BMC Dump During Dumping State
+    [Documentation]  Verify error while initiating BMC dump during dumping state.
+    [Tags]  Verify_Error_While_Initiating_BMC_Dump_During_Dumping_State
+
+    Create User Initiated BMC Dump Via Redfish  skip_dump_creation=1
+
+    # Check error while initiating BMC dump while dump in progress.
+    ${payload}=  Create Dictionary  DiagnosticDataType=Manager
+    Redfish.Post
+    ...  /redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData
+    ...  body=${payload}  valid_status_codes=[${HTTP_SERVICE_UNAVAILABLE}]
+
+
 *** Keywords ***
 
 Get BMC Dump Entries