Add code upload test cases for valid BMC images.
Resolves openbmc/openbmc-test-automation#783
Change-Id: I6b2844cfcda247677faefec37d317db9fe98b5c6
Signed-off-by: Charles Paul Hofer <Charles.Hofer@ibm.com>
diff --git a/extended/test_uploadimage.py b/extended/test_uploadimage.py
index ddffe08..0b6bcd7 100644
--- a/extended/test_uploadimage.py
+++ b/extended/test_uploadimage.py
@@ -142,11 +142,16 @@
###############################################################################
-def verify_image_upload():
+def verify_image_upload(timeout=3):
r"""
Verify the image was uploaded correctly and that it created
- a valid d-bus object
+ a valid d-bus object. If the first check for the image
+ fails, try again until we reach the timeout.
+
+ Description of argument(s):
+ timeout How long, in minutes, to keep trying to find the
+ image on the BMC. Default is 3 minutes.
"""
image_version = BuiltIn().get_variable_value("${image_version}")
@@ -159,15 +164,20 @@
if (image_purpose == var.VERSION_PURPOSE_BMC or
image_purpose == var.VERSION_PURPOSE_HOST):
uri = var.SOFTWARE_VERSION_URI + image_version_id
- status, ret_values =\
- grk.run_key("Read Attribute " + uri + " Activation")
+ ret_values = ""
+ for itr in range(timeout * 2):
+ status, ret_values = \
+ grk.run_key("Read Attribute " + uri + " Activation")
- if ((ret_values == var.READY) or (ret_values == var.INVALID)
- or (ret_values == var.ACTIVE)):
- return True
- else:
- gp.print_var(ret_values)
- return False
+ if ((ret_values == var.READY) or (ret_values == var.INVALID)
+ or (ret_values == var.ACTIVE)):
+ return True
+ else:
+ time.sleep(30)
+
+ # If we exit the for loop, the timeout has been reached
+ gp.print_var(ret_values)
+ return False
else:
gp.print_var(image_purpose)
return False
@@ -176,20 +186,23 @@
###############################################################################
-def verify_image_not_in_bmc_uploads_dir(image_version):
+def verify_image_not_in_bmc_uploads_dir(image_version, timeout=3):
r"""
Check that an image with the given version is not unpacked inside of the
BMCs image uploads directory. If no image is found, retry every 30 seconds
- for 3 minutes in case the BMC takes time unpacking the image.
+ until the given timeout is hit, in case the BMC takes time
+ unpacking the image.
Description of argument(s):
image_version The version of the image to look for on the BMC.
+ timeout How long, in minutes, to try to find an image on the BMC.
+ Default is 3 minutes.
"""
grk.run_key('Open Connection And Log In')
upload_dir_path = BuiltIn().get_variable_value("${upload_dir_path}")
- for i in range(6):
+ for i in range(timeout * 2):
stat, grep_res = grk.run_key('Execute Command On BMC '
+ 'ls ' + upload_dir_path + '*/MANIFEST 2>/dev/null '
+ '| xargs grep -rl "version=' + image_version + '"')
diff --git a/extended/test_uploadimage.robot b/extended/test_uploadimage.robot
index a362e5c..1b536c6 100644
--- a/extended/test_uploadimage.robot
+++ b/extended/test_uploadimage.robot
@@ -7,8 +7,10 @@
... Execution Method :
... python -m robot -v OPENBMC_HOST:<hostname>
... -v TFTP_SERVER:<TFTP server IP>
-... -v TFTP_FILE_NAME:<filename.tar>
-... -v IMAGE_FILE_PATH:<path/*.tar>
+... -v PNOR_TFTP_FILE_NAME:<filename.tar>
+... -v BMC_TFTP_FILE_NAME:<filename.tar>
+... -v PNOR_IMAGE_FILE_PATH:<path/*.tar>
+... -v BMC_IMAGE_FILE_PATH:<path/*.tar>
... -v BAD_IMAGES_DIR_PATH:<path> test_uploadimage.robot
Resource ../lib/connection_client.robot
@@ -32,29 +34,43 @@
*** Test Cases ***
Upload PNOR Image Via REST
- [Documentation] Upload an image via REST.
+ # Image File Path
+
+ ${PNOR_IMAGE_FILE_PATH}
+
+ [Documentation] Upload a PNOR image via REST.
+ [Template] Upload Image Via REST And Verify Success
[Tags] Upload_PNOR_Image_Via_REST
- OperatingSystem.File Should Exist ${IMAGE_FILE_PATH}
- ${IMAGE_VERSION}= Get Version Tar ${IMAGE_FILE_PATH}
- ${image_data}= OperatingSystem.Get Binary File ${IMAGE_FILE_PATH}
- Upload Image To BMC /upload/image data=${image_data}
- ${ret}= Verify Image Upload
- Should Be True True == ${ret}
+
+Upload BMC Image Via REST
+ # Image File Path
+
+ ${BMC_IMAGE_FILE_PATH}
+
+ [Documentation] Upload a BMC image via REST.
+ [Template] Upload Image Via REST And Verify Success
+ [Tags] Upload_BMC_Image_Via_REST
+
Upload PNOR Image Via TFTP
- [Documentation] Upload an image via TFTP.
+ # Image File Path
+
+ ${PNOR_TFTP_FILE_NAME}
+
+ [Documentation] Upload a PNOR image via TFTP.
+ [Template] Upload Image Via TFTP And Verify Success
[Tags] Upload_PNOR_Image_Via_TFTP
- @{image}= Create List ${TFTP_FILE_NAME} ${TFTP_SERVER}
- ${data}= Create Dictionary data=@{image}
- ${resp}= OpenBMC Post Request
- ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data}
- Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
- Sleep 1 minute
- ${image_version}= Get Image Version From TFTP Server ${TFTP_FILE_NAME}
- ${ret}= Verify Image Upload
- Should Be True True == ${ret}
+
+Upload BMC Image Via TFTP
+ # Image File Path
+
+ ${BMC_TFTP_FILE_NAME}
+
+ [Documentation] Upload a BMC image via TFTP
+ [Template] Upload Image Via TFTP And Verify Success
+ [Tags] Upload_BMC_Image_Via_TFTP
Upload PNOR Image With Bad Manifest Via REST
@@ -194,6 +210,45 @@
OperatingSystem.Remove File tftp_image.tar
[Return] ${version}
+Upload Image Via REST And Verify Success
+ [Documentation] Upload an image to the BMC and check that it is unpacked.
+
+ # Upload the given good image to the BMC via REST, and check that the
+ # BMC has unpacked the image and created a valid D-Bus entry for it.
+
+ [Arguments] ${image_file_path}
+
+ # Description of argument(s):
+ # image_file_path The path to the image file to upload.
+
+ OperatingSystem.File Should Exist ${image_file_path}
+ ${image_version}= Get Version Tar ${image_file_path}
+ ${image_data}= OperatingSystem.Get Binary File ${image_file_path}
+ Upload Image To BMC /upload/image data=${image_data}
+ ${ret}= Verify Image Upload
+ Should Be True ${ret}
+
+Upload Image Via TFTP And Verify Success
+ [Documentation] Upload an image to the BMC and check that it was unpacked.
+
+ # Upload the given good image to the BMC via TFTP, and check that the
+ # BMC has unpacked the image and created a valid D-Bus entry for it.
+
+ [Arguments] ${image_file_name}
+
+ # Description of argument(s):
+ # image_file_name The name of the image file on the TFTP server.
+
+ @{image}= Create List ${image_file_name} ${TFTP_SERVER}
+ ${data}= Create Dictionary data=@{image}
+ ${resp}= OpenBMC Post Request
+ ... ${SOFTWARE_VERSION_URI}/action/DownloadViaTFTP data=${data}
+ Should Be Equal As Strings ${resp.status_code} ${HTTP_OK}
+ Sleep 1 minute
+ ${image_version}= Get Image Version From TFTP Server ${image_file_name}
+ ${ret}= Verify Image Upload
+ Should Be True ${ret}
+
Upload Bad Image Via REST And Verify Failure
[Documentation] Upload the given bad image to the BMC via REST and check
... that the BMC did not unpack the invalid image.
diff --git a/lib/resource.txt b/lib/resource.txt
index 3aef429..fa8f66e 100755
--- a/lib/resource.txt
+++ b/lib/resource.txt
@@ -48,10 +48,13 @@
${DEBUG_TARBALL_PATH} ${EMPTY}
# Upload Image parameters
-${TFTP_SERVER} ${EMPTY}
-${TFTP_FILE_NAME} ${EMPTY}
-${IMAGE_FILE_PATH} ${EMPTY}
-${BAD_IMAGES_DIR_PATH} ${EMPTY}
+${TFTP_SERVER} ${EMPTY}
+${PNOR_TFTP_FILE_NAME} ${EMPTY}
+${BMC_TFTP_FILE_NAME} ${EMPTY}
+${IMAGE_FILE_PATH} ${EMPTY}
+${PNOR_IMAGE_FILE_PATH} ${EMPTY}
+${BMC_IMAGE_FILE_PATH} ${EMPTY}
+${BAD_IMAGES_DIR_PATH} ${EMPTY}
# Caller can specify a value for LAST_KNOWN_GOOD_VERSION to indicate that if
# the machine already has that version on it, the update should be skipped.
diff --git a/tools/generate_argumentfile.sh b/tools/generate_argumentfile.sh
index f571971..7d41fa2 100755
--- a/tools/generate_argumentfile.sh
+++ b/tools/generate_argumentfile.sh
@@ -23,7 +23,10 @@
echo "--variable OS_PASSWORD:$OS_PASSWORD" >> $ARG_FILE
echo "--variable DEBUG_TARBALL_PATH:$DEBUG_TARBALL_PATH" >> $ARG_FILE
echo "--variable TFTP_SERVER:$TFTP_SERVER" >> $ARG_FILE
-echo "--variable TFTP_FILE_NAME:$TFTP_FILE_NAME" >> $ARG_FILE
+echo "--variable PNOR_TFTP_FILE_NAME:$PNOR_TFTP_FILE_NAME" >> $ARG_FILE
+echo "--variable BMC_TFTP_FILE_NAME:$BMC_TFTP_FILE_NAME" >> $ARG_FILE
echo "--variable IMAGE_FILE_PATH:$IMAGE_FILE_PATH" >> $ARG_FILE
+echo "--variable PNOR_IMAGE_FILE_PATH:$PNOR_IMAGE_FILE_PATH" >> $ARG_FILE
+echo "--variable BMC_IMAGE_FILE_PATH:$BMC_IMAGE_FILE_PATH" >> $ARG_FILE
echo "--variable BAD_IMAGES_DIR_PATH:$BAD_IMAGES_DIR_PATH" >> $ARG_FILE
echo "--variable LAST_KNOWN_GOOD_VERSION:$LAST_KNOWN_GOOD_VERSION" >> $ARG_FILE