Add test cases for disconnecting network during code update
Resolves openbmc/openbmc-test-automation#992
Change-Id: I4af034974747c0b4ce1916dc563526dc2afc768c
Signed-off-by: Charles Paul Hofer <Charles.Hofer@ibm.com>
diff --git a/extended/code_update/bmc_recoverable_error_test.robot b/extended/code_update/bmc_recoverable_error_test.robot
new file mode 100644
index 0000000..10341b4
--- /dev/null
+++ b/extended/code_update/bmc_recoverable_error_test.robot
@@ -0,0 +1,38 @@
+*** Settings ***
+Documentation Test errors and changes in the environment that BMC code
+... update should recover from or not be effected by.
+
+Resource ../../lib/code_update_utils.robot
+Resource ../../lib/openbmc_ffdc.robot
+
+Suite Setup Suite Setup Execution
+
+Test Teardown FFDC On Test Case Fail
+
+*** Variables ***
+${QUIET} ${1}
+${IMAGE_FILE_PATH} ${EMPTY}
+
+*** Test Cases ***
+
+Reset Network During BMC Code Update
+ [Documentation] Disable and re-enable the network while doing a BMC
+ ... code update.
+ [Tags] Reset_Network_During_BMC_Code_Update
+ [Template] Reset Network During Code Update
+
+ # Image File Path Reboot
+ ${IMAGE_FILE_PATH} ${TRUE}
+
+
+*** Keywords ***
+
+Suite Setup Execution
+ [Documentation] Do setup tasks for recoverable errors.
+
+ Should Not Be Empty ${IMAGE_FILE_PATH}
+ ... msg=IMAGE_FILE_PATH should be set.
+ Should Not Be Empty ${OPENBMC_SERIAL_HOST}
+ ... msg=OPENBMC_SERIAL_HOST should be set.
+ Should Not Be Empty ${OPENBMC_SERIAL_PORT}
+ ... msg=OPENBMC_SERIAL_PORT should be set.
diff --git a/extended/code_update/host_recoverable_error_test.robot b/extended/code_update/host_recoverable_error_test.robot
new file mode 100644
index 0000000..cf63b6d
--- /dev/null
+++ b/extended/code_update/host_recoverable_error_test.robot
@@ -0,0 +1,38 @@
+*** Settings ***
+Documentation Test errors and changes in the environment that BMC code
+... update should recover from or not be effected by.
+
+Resource ../../lib/code_update_utils.robot
+Resource ../../lib/openbmc_ffdc.robot
+
+Suite Setup Suite Setup Execution
+
+Test Teardown FFDC On Test Case Fail
+
+*** Variables ***
+${QUIET} ${1}
+${IMAGE_FILE_PATH} ${EMPTY}
+
+*** Test Cases ***
+
+Reset Network During Host Code Update
+ [Documentation] Disable and re-enable the network while doing a PNOR
+ ... code update.
+ [Tags] Reset_Network_During_Host_Code_Update
+ [Template] Reset Network During Code Update
+
+ # Image File Path Reboot
+ ${IMAGE_FILE_PATH} ${FALSE}
+
+
+*** Keywords ***
+
+Suite Setup Execution
+ [Documentation] Do setup tasks for recoverable errors.
+
+ Should Not Be Empty ${IMAGE_FILE_PATH}
+ ... msg=IMAGE_FILE_PATH should be set.
+ Should Not Be Empty ${OPENBMC_SERIAL_HOST}
+ ... msg=OPENBMC_SERIAL_HOST should be set.
+ Should Not Be Empty ${OPENBMC_SERIAL_PORT}
+ ... msg=OPENBMC_SERIAL_PORT should be set.
diff --git a/lib/code_update_utils.robot b/lib/code_update_utils.robot
index d7cc3c8..dd5c7f6 100644
--- a/lib/code_update_utils.robot
+++ b/lib/code_update_utils.robot
@@ -5,6 +5,7 @@
Library OperatingSystem
Library String
Variables ../data/variables.py
+Resource boot_utils.robot
Resource rest_client.robot
Resource openbmc_ffdc.robot
@@ -190,13 +191,15 @@
... ${REQUESTED_ACTIVE}
# Does caller want to wait for activation to complete?
- Run Keyword If '${wait}' == '${0}' Return From Keyword
+ Return From Keyword If '${wait}' == '${0}' ${version_id}
# Verify code update was successful and Activation state is Active.
Wait For Activation State Change ${version_id} ${ACTIVATING}
${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
Should Be Equal As Strings &{software_state}[Activation] ${ACTIVE}
+ [Return] ${version_id}
+
Switch To Active Image And Pass
[Documentation] Make the given active image the image running on the BMC
@@ -327,3 +330,37 @@
${tar_version}= Get Version Tar ${image_file_path}
${pnor_version}= Get PNOR Version
Should Be Equal ${tar_version} ${pnor_version}
+
+
+Reset Network Interface During Code Update
+ [Documentation] Disable and re-enable the network while doing code update.
+ [Arguments] ${image_file_path} ${reboot}
+
+ # Reseting the network will be done via the serial console.
+ #
+ # Description of argument(s):
+ # image_file_path Path to the image file to update to.
+ # reboot If set to true, will reboot the BMC after the code
+ # update is finished.
+
+ ${version_id}= Upload And Activate Image ${image_file_path} wait=${0}
+ Reset Network Interface
+
+ # Verify code update was successful and 'Activation' state is 'Active'.
+ Wait For Activation State Change ${version_id} ${ACTIVATING}
+ ${software_state}= Read Properties ${SOFTWARE_VERSION_URI}${version_id}
+ Should Be Equal As Strings &{software_state}[Activation] ${ACTIVE}
+
+ Run Keyword If '${reboot}' OBMC Reboot (off) stack_mode=normal
+
+
+Reset Network Interface
+ [Documentation] Turn the ethernet network interface off and then on again
+ ... through the serial console.
+
+ Import Resource ${CURDIR}/oem/ibm/serial_console_client.robot
+ Set Library Search Order SSHLibrary Telnet
+ Execute Command On Serial Console ifconfig eth0 down
+ Sleep 30s
+ Execute Command On Serial Console ifconfig eth0 up
+ Read and Log BMC Serial Console Output
diff --git a/lib/oem/ibm/serial_console_client.robot b/lib/oem/ibm/serial_console_client.robot
index 00e7145..e840a73 100644
--- a/lib/oem/ibm/serial_console_client.robot
+++ b/lib/oem/ibm/serial_console_client.robot
@@ -4,42 +4,59 @@
Library Telnet newline=LF
Library OperatingSystem
Library Collections
+Library String
-*** Variables ***
*** Keywords ***
-Open Telnet Connection to BMC Serial Console
+Open Telnet Connection To BMC Serial Console
[Documentation] Open telnet connection session to BMC serial console
... The login prompt expected, for example, for barreleye
- ... is "barreleye login:"
+ ... is "barreleye login:".
[Arguments] ${i_host}=${OPENBMC_SERIAL_HOST}
... ${i_port}=${OPENBMC_SERIAL_PORT}
... ${i_model}=${OPENBMC_MODEL}
- Run Keyword If
- ... '${i_host}' != '${EMPTY}' and '${i_port}' != '${EMPTY}' and '${i_model}' != '${EMPTY}'
- ... Establish Telnet Session on BMC Serial Console
- ... ELSE Fail msg=One of the paramaters is EMPTY
+ # Description of argument(s):
+ # i_host The host name or IP of the serial console.
+ # i_port The port of the serial console.
+ # i_model The path to the system data, i.e. "./data/Witherspoon.py".
-
-Establish Telnet Session on BMC Serial Console
- [Documentation] Establish telnet session and set timeout to 30 mins
- ... 30 secs.
-
- ${prompt_string} Set Variable ${OPENBMC_MODEL} login:
+ ${prompt_string}= Remove String ${i_model} ./data/ .py
+ ${prompt_string}= Convert To Lowercase ${prompt_string} login:
Telnet.Open Connection
- ... ${OPENBMC_SERIAL_HOST} port=${OPENBMC_SERIAL_PORT} prompt=#
- Set Newline \n
- Set Newline CRLF
- Telnet.Write \n
- Telnet.Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
- ... login_prompt=${prompt_string} password_prompt=Password:
- Telnet.Set Timeout 30 minute 30 seconds
+ ... ${i_host} port=${i_port} prompt=#
+ Telnet.Set Newline \n
+ Telnet.Set Newline CRLF
+ Telnet.Write \n
+ Telnet.Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
+ ... login_prompt=${prompt_string} password_prompt=Password:
+ Telnet.Set Timeout 30 minute 30 seconds
Read and Log BMC Serial Console Output
[Documentation] Reads everything that is currently available
... in the output.
+
${bmc_serial_log}= Telnet.Read
Log ${bmc_serial_log}
+
+
+Execute Command On Serial Console
+ [Documentation] Execute a command on the BMC serial console.
+ [Arguments] ${command_string}
+
+ # Description of argument(s):
+ # command The command to execute on the BMC.
+
+ Open Telnet Connection To BMC Serial Console
+ Telnet.Write \n
+ Telnet.Execute Command ${command_string}
+ Close Serial Console Connection
+
+
+Close Serial Console Connection
+ [Documentation] Log out of the BMC and close telnet.
+
+ Execute Command On Serial Console exit
+ Telnet.Close Connection
\ No newline at end of file