Skip to content

Commit

Permalink
Add efibootmgr modification as a test-suite
Browse files Browse the repository at this point in the history
Incoming ghaf PR#585 Change internal installation approach
is going to change the installation method significantly.
After the merge of PR#585 ghaf-installer will create always a new
Linux Boot Manager entry to UEFI boot order list and thus set the
machine to boot from nvme regardless if USB SSD is connected.

Here introduced efiboot-mod test will automatically remove all
Linux entries from the UEFI boot order list. Wiping nvme
clear could do the same but it is not possible to automatically
clear nvme if boot is locked to nvme. Also it is good to not let
the UEFI boot order list be flooded endlessly with Linux Boot
Manager entries.

There is still a risk that the ghaf which the ghaf-installer
has installed is broken and unbootable and new Linux Boot Manager
entry is active. This would cause ci-test-automation not being
able to boot automatically from nvme nor from USB SSD, and the
system should be fixed manually (Linux Boot Manager removed). To
avoid this happening plain ghaf image test should be ran first
and only if the ghaf image is bootable then proceed to
ghaf-installer tests.

Signed-off-by: Samuli Leivo <[email protected]>
  • Loading branch information
leivos-unikie committed Aug 21, 2024
1 parent 1cb11f9 commit 7a780b7
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Jenkinsfiles/hw_test_set
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ zipImagePath = ''
bootSuite = 'boot-test/'
performanceSuite = 'performance-tests/'
batSuite = 'bat-tests/'
efibootSuite = 'efibootmgr/'
deviceName = ''
usbHubSerial = ''
sdMuxUsbPort = ''
Expand All @@ -30,6 +31,7 @@ pipeline {
bootJob = "${splitted[0]}/Testing/boot_test"
batJob = "${splitted[0]}/Testing/smoke_tests"
performanceJob = "${splitted[0]}/Testing/Performance_tests"
removebootmanagerJob = "${splitted[0]}/Testing/remove_efibootentries"
turnoffJob = "${splitted[0]}/Testing/turn_off_device"
turnonJob = "${splitted[0]}/Testing/turn_on_device"
configPath = "/home/${params.label}/Jenkins-agent/workspace/${splitted[0]}/Testing/test_config.json"
Expand Down Expand Up @@ -278,6 +280,22 @@ pipeline {
}
}
}
stage('Remove Linux Boot Manager') {
steps {
script {
if ("${params.job}" == "lenovo-x1-carbon-gen11-debug-installer"){
build = build(
job: "${batJob}", propagate: false,
parameters: [
[$class: 'StringParameterValue', name: 'RF_SUITE', value: "${efibootSuite}"],
[$class: 'StringParameterValue', name: 'DESCRIPTION', value: "${params.server} buildID: ${params.buildID}"],
[$class: 'StringParameterValue', name: 'DEVICE_NAME', value: "${deviceName}"],
[$class: 'StringParameterValue', name: 'INCLD_TAG', value: "efiboot-modAND${params.device}"]
]
)
}
}
}
stage('Turn off device') {
steps {
script {
Expand Down
18 changes: 18 additions & 0 deletions Robot-Framework/test-suites/efibootmgr/__init__.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# SPDX-FileCopyrightText: 2022-2024 Technology Innovation Institute (TII)
# SPDX-License-Identifier: Apache-2.0

*** Settings ***
Documentation Modify boot order
Resource ../../resources/ssh_keywords.resource
Resource ../../config/variables.robot
Suite Setup Common Setup
Suite Teardown Common Teardown


*** Keywords ***

Common Setup
Set Variables ${DEVICE}

Common Teardown
Close All Connections
4 changes: 4 additions & 0 deletions Robot-Framework/test-suites/efibootmgr/efiboot_mod_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
for f in $(efibootmgr | grep Linux | awk 'NR > 0 {print $1}' | cut -c 5-8)
do
sudo efibootmgr -q -b ${f} -B
done
91 changes: 91 additions & 0 deletions Robot-Framework/test-suites/efibootmgr/efibootmgr.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# SPDX-FileCopyrightText: 2022-2024 Technology Innovation Institute (TII)
# SPDX-License-Identifier: Apache-2.0

*** Settings ***
Documentation Removing Linux Boot Manager entries from UEFI boot order.
Force Tags efiboot-mod
Resource ../../resources/serial_keywords.resource
Resource ../../resources/ssh_keywords.resource
Resource ../../resources/device_control.resource
Resource ../../config/variables.robot


*** Variables ***
${CONNECTION_TYPE} ssh
${IS_AVAILABLE} False
${DEVICE_TYPE} ${EMPTY}
${ENTRIES}

*** Test Cases ***

Remove Linux Boot Manager entries
[Documentation] Remove all Linux Boot Manager entries from UEFI boot order list
[Tags] lenovo-x1 efiboot-mod
Check If Device Is Up
IF ${IS_AVAILABLE} == False
FAIL Cannot modify the UEFI boot order
ELSE
Log To Console Connecting to ghaf-host
END

Connect
Put File efibootmgr/efiboot_mod_script /home/ghaf
Execute Command chmod 777 efiboot_mod_script sudo=True sudo_password=${PASSWORD}
Log To Console Deleting all 'Linux' entries from UEFI boot order with efibootmgr
Execute Command ./efiboot_mod_script sudo=True sudo_password=${PASSWORD}
${ENTRIES} Execute Command efibootmgr | grep Linux
Log To Console efibootmgr check after removing Linux Boot Manager entries: \n${ENTRIES}
IF "${ENTRIES}" != ""
FAIL Failed in removing all Linux Boot Manager entries
ELSE
Log To Console All Linux Boot Manager entries cleared
END
[Teardown] Teardown


*** Keywords ***

Teardown
IF "${CONNECTION_TYPE}" == "ssh"
Run Keyword If Test Failed ssh_keywords.Save log
ELSE IF "${CONNECTION_TYPE}" == "serial"
Run Keyword If Test Failed serial_keywords.Save log
END
Close All Connections
Delete All Ports

Check If Device Is Up
[Arguments] ${range}=5
Set Global Variable ${IS_AVAILABLE} False
${start_time}= Get Time epoch
FOR ${i} IN RANGE ${range}
${ping}= Ping Host ${DEVICE_IP_ADDRESS}
IF ${ping}
Log To Console Ping ${DEVICE_IP_ADDRESS} successfull
BREAK
END
Sleep 1
END

IF ${ping}
${port_22_is_available} Check if ssh is ready on device
IF ${port_22_is_available}
Set Global Variable ${IS_AVAILABLE} True
ELSE
Set Global Variable ${IS_AVAILABLE} False
END
END

${diff}= Evaluate int(time.time()) - int(${start_time})

IF ${IS_AVAILABLE} Log To Console Device ssh port available.

IF ${IS_AVAILABLE} == False
Log To Console Device is not available!
IF "${SERIAL_PORT}" == "NONE"
Log To Console There is no address for serial connection
ELSE
Check Serial Connection
END
END

0 comments on commit 7a780b7

Please sign in to comment.