| Steven Sombar | f3a1995 | 2017-10-11 14:18:26 -0500 | [diff] [blame] | 1 | *** Settings *** | 
|  | 2 |  | 
|  | 3 | Documentation    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. | 
| George Keishing | 4d4ef99 | 2021-01-28 09:56:53 -0600 | [diff] [blame] | 11 | #                     Default value for LOOPS is 1. | 
| Steven Sombar | f3a1995 | 2017-10-11 14:18:26 -0500 | [diff] [blame] | 12 |  | 
|  | 13 |  | 
|  | 14 | Library            OperatingSystem | 
|  | 15 | Resource           ../lib/utils.robot | 
|  | 16 | Resource           ../lib/openbmc_ffdc.robot | 
|  | 17 |  | 
|  | 18 |  | 
|  | 19 | Test Teardown   FFDC On Test Case Fail | 
|  | 20 |  | 
|  | 21 |  | 
|  | 22 | *** Variables **** | 
|  | 23 |  | 
|  | 24 | ${LOOPS}         ${1} | 
|  | 25 | ${iteration}     ${0} | 
|  | 26 |  | 
|  | 27 |  | 
|  | 28 | *** Test Cases *** | 
|  | 29 |  | 
|  | 30 |  | 
|  | 31 | REST 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 |  | 
|  | 41 | Upload 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} | 
| Michael Walsh | c108e42 | 2019-03-28 12:27:18 -0500 | [diff] [blame] | 49 | Printn | 
| Steven Sombar | f3a1995 | 2017-10-11 14:18:26 -0500 | [diff] [blame] | 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 |  | 
| George Keishing | 6d9d4f6 | 2025-03-21 11:36:47 +0530 | [diff] [blame] | 57 | # Set up 'redfish' object used in POST request below. | 
| Steven Sombar | f3a1995 | 2017-10-11 14:18:26 -0500 | [diff] [blame] | 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 | 
| Sridevi Ramesh | eadeef0 | 2019-01-17 08:56:18 -0600 | [diff] [blame] | 63 | ...  X-Auth-Token=${XAUTH_TOKEN}  Accept=application/octet-stream | 
| Steven Sombar | f3a1995 | 2017-10-11 14:18:26 -0500 | [diff] [blame] | 64 | Set To Dictionary  ${data}  headers  ${headers} | 
|  | 65 |  | 
| George Keishing | a789aeb | 2018-04-14 12:17:42 -0500 | [diff] [blame] | 66 | # Upload to BMC and check for HTTP_BAD_REQUEST. | 
| George Keishing | 6d9d4f6 | 2025-03-21 11:36:47 +0530 | [diff] [blame] | 67 | ${resp}=  POST On Session  redfish  /upload/image  &{data} | 
| George Keishing | a789aeb | 2018-04-14 12:17:42 -0500 | [diff] [blame] | 68 | Should Be Equal As Strings  ${resp.status_code}  ${HTTP_BAD_REQUEST} | 
| Steven Sombar | f3a1995 | 2017-10-11 14:18:26 -0500 | [diff] [blame] | 69 |  | 
| Steven Sombar | f3a1995 | 2017-10-11 14:18:26 -0500 | [diff] [blame] | 70 | ${loop_count}=  Catenate  Ending iteration: ${iteration} | 
|  | 71 | Rpvars  loop_count |