BMC upload stability test.

Add extended test that uploads a test image file to BMC via REST.

Resolves  openbmc/openbmc-test-automation#1025
Change-Id: I6143d78a23250f89ac87be4b785d481fdef5007a
Signed-off-by: Steven Sombar <ssombar@us.ibm.com>
diff --git a/extended/test_bmc_upload_stability.robot b/extended/test_bmc_upload_stability.robot
new file mode 100755
index 0000000..4decba4
--- /dev/null
+++ b/extended/test_bmc_upload_stability.robot
@@ -0,0 +1,73 @@
+*** Settings ***
+
+Documentation    Module to stress-test REST upload stability.
+...              Upload a test file to the BMC.  The
+...              test file is approximately the size of
+...              a BMC flash image file.
+
+# Test Parameters:
+# OPENBMC_HOST        The BMC host name or IP address.
+# LOOPS               The number of times to loop the test.
+#                     Defaule value for LOOPS is 1.
+
+
+Library            OperatingSystem
+Resource           ../lib/utils.robot
+Resource           ../lib/openbmc_ffdc.robot
+
+
+Test Teardown   FFDC On Test Case Fail
+
+
+*** Variables ****
+
+${LOOPS}         ${1}
+${iteration}     ${0}
+
+
+*** Test Cases ***
+
+
+REST Upload Stability Test
+    [Documentation]  Execute upload stress testing.
+    [Tags]  REST_Upload_Stability_Test
+
+    Repeat Keyword  ${LOOPS} times  Upload Test Image File To BMC
+
+
+*** Keywords ***
+
+
+Upload Test Image File To BMC
+    [Documentation]  Upload a file to BMC via REST.  The uploaded file
+    ...              is 32MB, approximately the same size as a downloadable
+    ...              BMC image.
+    [Timeout]  2m
+
+    Set Test Variable  ${iteration}  ${iteration + 1}
+    ${loop_count}=  Catenate  Starting iteration: ${iteration}
+    Rprintn
+    Rpvars  loop_count
+
+    # Generate data file.
+    Run  dd if=/dev/zero of=dummyfile bs=1 count=0 seek=32MB
+
+    ${image_data}=  OperatingSystem.Get Binary File  dummyfile
+
+    # Set up 'openbmc' used in POST request below.
+    Initialize OpenBMC
+
+    # Create the REST payload headers and data.
+    ${data}=  Create Dictionary  data=${image_data}
+    ${headers}=  Create Dictionary  Content-Type=application/octet-stream
+    ...  Accept=application/octet-stream
+    Set To Dictionary  ${data}  headers  ${headers}
+
+    # Upload to BMC and check for HTTP_OK.
+    ${resp}=  Post Request  openbmc  /upload/image  &{data}
+    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
+
+    BMC Execute Command  rm -f /tmp/images/*  quiet=${1}
+
+    ${loop_count}=  Catenate  Ending iteration: ${iteration}
+    Rpvars  loop_count