1*** Settings ***
2
3Documentation    Module to stress-test REST upload stability.
4...              Upload a test file to the BMC.  The
5...              test file is approximately the size of
6...              a BMC flash image file.
7
8# Test Parameters:
9# OPENBMC_HOST        The BMC host name or IP address.
10# LOOPS               The number of times to loop the test.
11#                     Defaule value for LOOPS is 1.
12
13
14Library            OperatingSystem
15Resource           ../lib/utils.robot
16Resource           ../lib/openbmc_ffdc.robot
17
18
19Test Teardown   FFDC On Test Case Fail
20
21
22*** Variables ****
23
24${LOOPS}         ${1}
25${iteration}     ${0}
26
27
28*** Test Cases ***
29
30
31REST Upload Stability Test
32    [Documentation]  Execute upload stress testing.
33    [Tags]  REST_Upload_Stability_Test
34
35    Repeat Keyword  ${LOOPS} times  Upload Test Image File To BMC
36
37
38*** Keywords ***
39
40
41Upload Test Image File To BMC
42    [Documentation]  Upload a file to BMC via REST.  The uploaded file
43    ...              is 32MB, approximately the same size as a downloadable
44    ...              BMC image.
45    [Timeout]  2m
46
47    Set Test Variable  ${iteration}  ${iteration + 1}
48    ${loop_count}=  Catenate  Starting iteration: ${iteration}
49    Rprintn
50    Rpvars  loop_count
51
52    # Generate data file.
53    Run  dd if=/dev/zero of=dummyfile bs=1 count=0 seek=32MB
54
55    ${image_data}=  OperatingSystem.Get Binary File  dummyfile
56
57    # Set up 'openbmc' used in POST request below.
58    Initialize OpenBMC
59
60    # Create the REST payload headers and data.
61    ${data}=  Create Dictionary  data=${image_data}
62    ${headers}=  Create Dictionary  Content-Type=application/octet-stream
63    ...  Accept=application/octet-stream
64    Set To Dictionary  ${data}  headers  ${headers}
65
66    # Upload to BMC and check for HTTP_BAD_REQUEST.
67    ${resp}=  Post Request  openbmc  /upload/image  &{data}
68    Should Be Equal As Strings  ${resp.status_code}  ${HTTP_BAD_REQUEST}
69
70    ${loop_count}=  Catenate  Ending iteration: ${iteration}
71    Rpvars  loop_count
72