Add support for host BIOS update testing
This change adds the following keywords to utils.robot:
Clear BMC Record Log
Copy PNOR to BMC
Flash PNOR
Get Flash BIOS Status
Is PNOR Flashing
Is PNOR Flash Done
Is System State Host Booted
This also adds test_bios_update.robot which implements a basic ipl test
using the above keywords.
Change-Id: Id544fd1cec755ef95eb7c7330751b3c2e2a2d9dc
Signed-off-by: Jay Azurin <jmazurin@us.ibm.com>
diff --git a/README.md b/README.md
index 956b9b7..5553796 100755
--- a/README.md
+++ b/README.md
@@ -47,6 +47,10 @@
$ export SSH_PORT=<ssh port number>
$ export HTTPS_PORT=<https port number>
+Use the following variables for BIOS update testing
+==========================================================
+ $ export PNOR_IMAGE_PATH=<path to>/<machine>.pnor
+
```
Run tests
diff --git a/lib/utils.robot b/lib/utils.robot
index ebe7980..190e4fc 100644
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -130,3 +130,49 @@
Should be equal as strings ${resp.status_code} ${HTTP_OK}
${content}= to json ${resp.content}
[return] ${content["data"]}
+
+Clear BMC Record Log
+ [Documentation] Clears all the event logs on the BMC. This would be
+ ... equivalent to ipmitool sel clear.
+ @{arglist}= Create List
+ ${args}= Create Dictionary data=@{arglist}
+ ${resp}= Call Method /org/openbmc/records/events/ clear data=${args}
+ should be equal as strings ${resp.status_code} ${HTTP_OK}
+
+Copy PNOR to BMC
+ Import Library SCPLibrary WITH NAME scp
+ Open Connection for SCP
+ Log Copying ${PNOR_IMAGE_PATH} to /tmp
+ scp.Put File ${PNOR_IMAGE_PATH} /tmp
+
+Flash PNOR
+ [Documentation] Calls flash bios update method to flash PNOR image
+ [arguments] ${pnor_image}
+ @{arglist}= Create List ${pnor_image}
+ ${args}= Create Dictionary data=@{arglist}
+ ${resp}= Call Method /org/openbmc/control/flash/bios/ update data=${args}
+ should be equal as strings ${resp.status_code} ${HTTP_OK}
+ Wait Until Keyword Succeeds 2 min 10 sec Is PNOR Flashing
+
+Get Flash BIOS Status
+ [Documentation] Returns the status of the flash BIOS API as a string. For
+ ... example 'Flashing', 'Flash Done', etc
+ ${data}= Read Properties /org/openbmc/control/flash/bios
+ [return] ${data['status']}
+
+Is PNOR Flashing
+ [Documentation] Get BIOS 'Flashing' status. This indicates that PNOR
+ ... flashing has started.
+ ${status}= Get Flash BIOS Status
+ should be equal as strings ${status} Flashing
+
+Is PNOR Flash Done
+ [Documentation] Get BIOS 'Flash Done' status. This indicates that the
+ ... PNOR flashing has completed.
+ ${status}= Get Flash BIOS Status
+ should be equal as strings ${status} Flash Done
+
+Is System State Host Booted
+ [Documentation] Checks whether system state is HOST_BOOTED.
+ ${state}= Get BMC State
+ should be equal as strings ${state} HOST_BOOTED
diff --git a/tests/test_bios_update.robot b/tests/test_bios_update.robot
new file mode 100644
index 0000000..5e95386
--- /dev/null
+++ b/tests/test_bios_update.robot
@@ -0,0 +1,41 @@
+*** Settings ***
+Documentation This testsuite updates the PNOR image on the host for
+... hostboot CI purposes.
+
+Resource ../lib/utils.robot
+Resource ../lib/connection_client.robot
+
+*** Variables ***
+
+*** Test Cases ***
+
+Host BIOS Update And Boot
+ [Tags] open-power
+ [Documentation] This test updates the PNOR image on the host (BIOS), and
+ ... validates that hosts boots normally.
+ Reach System Steady State
+ Update PNOR Image
+ Validate IPL
+
+*** Keywords ***
+
+Reach System Steady State
+ [Documentation] Reboot the BMC, power off the Host and clear any previous
+ ... events
+ Trigger Warm Reset
+ Initiate Power Off
+ Clear BMC Record Log
+
+Update PNOR Image
+ [Documentation] Copy the PNOR image to the BMC /tmp dir and flash it.
+ Copy PNOR to BMC
+ ${pnor_path} ${pnor_basename}= Split Path ${PNOR_IMAGE_PATH}
+ Flash PNOR /tmp/${pnor_basename}
+ Wait Until Keyword Succeeds 7 min 10 sec Is PNOR Flash Done
+
+Validate IPL
+ [Documentation] Power the host on, and validate the IPL
+ Initiate Power On
+ Wait Until Keyword Succeeds 10 min 30 sec Is System State Host Booted
+
+
diff --git a/tools/generate_argumentfile.sh b/tools/generate_argumentfile.sh
index e51d973..5387beb 100755
--- a/tools/generate_argumentfile.sh
+++ b/tools/generate_argumentfile.sh
@@ -14,3 +14,4 @@
echo "--variable SYSLOG_PORT:$SYSLOG_PORT" >> $ARG_FILE
echo "--variable SSH_PORT:$SSH_PORT" >> $ARG_FILE
echo "--variable HTTPS_PORT:$HTTPS_PORT" >> $ARG_FILE
+echo "--variable PNOR_IMAGE_PATH:$PNOR_IMAGE_PATH" >> $ARG_FILE