blob: 19dc35a34abc96224d1c181f431f7bd556ceb444 [file] [log] [blame]
Saqib Khanfb1f6ae2017-04-26 13:24:41 -05001*** Settings ***
2Documentation Test Upload Image
3... Execution Method :
4... python -m robot -v OPENBMC_HOST:<hostname>
5... -v TFTP_SERVER:<TFTP server IP>
6... -v TFTP_FILE_NAME:<filename.tar>
7... -v IMAGE_FILE_PATH:<path/*.tar> test_uploadimage.robot
8
9Resource ../lib/connection_client.robot
10Resource ../lib/rest_client.robot
11Resource ../lib/openbmc_ffdc.robot
12Library Collections
13Library String
14Library OperatingSystem
15Library test_uploadimage.py
16
17Test Teardown Upload Image Teardown
18
19*** Variables ***
20${timeout} 10
21${UPLOAD_DIR_PATH} /tmp/images/
22${QUIET} ${1}
23${IMAGE_VERSION} ${EMPTY}
24
25*** Test Cases ***
26
27Upload Image Via REST
28 [Documentation] Upload an image via REST.
29 [Tags] Upload_Image_Via_REST
30
31 OperatingSystem.File Should Exist ${IMAGE_FILE_PATH}
32 ${IMAGE_VERSION}= Get Version Tar ${IMAGE_FILE_PATH}
33 ${image_data}= OperatingSystem.Get Binary File ${IMAGE_FILE_PATH}
34 Upload Post Request /upload/image data=${image_data}
35 ${ret}= Verify Image Upload
36 Should Be True True == ${ret}
37
38Upload Image Via TFTP
39 [Documentation] Upload an image via TFTP.
40 [Tags] Upload_Image_Via_TFTP
41
42 @{image}= Create List ${TFTP_FILE_NAME} ${TFTP_SERVER}
43 ${data}= Create Dictionary data=@{image}
44 ${resp}= OpenBMC Post Request
45 ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data}
46 Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
47 Sleep 1 minute
48 ${upload_file}= Get Latest File ${UPLOAD_DIR_PATH}
49 ${IMAGE_VERSION}= Get Image Version
50 ... ${UPLOAD_DIR_PATH}${upload_file}/MANIFEST
51 ${ret}= Verify Image Upload
52 Should Be True True == ${ret}
53
54*** Keywords ***
55
56Upload Image Teardown
57 [Documentation] Log FFDC if test suite fails and collect SOL log for
58 ... debugging purposes.
59
60 Close All Connections
61 FFDC On Test Case Fail
62
63Upload Post Request
64 [Arguments] ${uri} ${timeout}=10 ${quiet}=${QUIET} &{kwargs}
65
66 # Description of arguments:
67 # uri URI for uploading image via REST.
68 # timeout Time allocated for the REST command to return status.
69 # quiet If enabled turns off logging to console.
70 # kwargs A dictionary that maps each keyword to a value.
71
72 Initialize OpenBMC ${timeout} quiet=${quiet}
73 ${base_uri}= Catenate SEPARATOR= ${DBUS_PREFIX} ${uri}
74 ${headers}= Create Dictionary Content-Type=application/octet-stream
75 ... Accept=application/octet-stream
76 Set To Dictionary ${kwargs} headers ${headers}
77 Run Keyword If '${quiet}' == '${0}' Log Request method=Post
78 ... base_uri=${base_uri} args=&{kwargs}
79 ${ret}= Post Request openbmc ${base_uri} &{kwargs} timeout=${timeout}
80 Run Keyword If '${quiet}' == '${0}' Log Response ${ret}
81 Should Be Equal As Strings ${ret.status_code} ${HTTP_OK}