-
-
Notifications
You must be signed in to change notification settings - Fork 6
OpenWRT automation #1128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
matmacieje
wants to merge
7
commits into
develop
Choose a base branch
from
openwrt_automation0000
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
OpenWRT automation #1128
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5046ec9
OpenWRT automation, WiP
matmacieje 90e64eb
dasharo-compatibility/os-openwrt.robot: Network testing fixes.
matmacieje c89bd86
OWR*.206: OpenWrt wifi scanning improved, tests added to JSON.
matmacieje a8f9f96
os-config/openwrt/: protectli build config for openwrt-zarhus.
matmacieje 053080e
os-config/openwrt/openwrt-zarhus_protectli.config: copyright notice
matmacieje 8feebcb
OWR*.206: Variable checks, improved cold-boot, other fixes
matmacieje d1a468a
OWR*.206: OpenWrt image stored in osfv-test-data
matmacieje File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
*** Settings *** | ||
Library Collections | ||
Library DateTime | ||
Library Dialogs | ||
Library OperatingSystem | ||
Library Process | ||
Library String | ||
Library Telnet timeout=20 seconds connection_timeout=120 seconds | ||
Resource ../variables.robot | ||
Resource ../keywords.robot | ||
Resource ../keys.robot | ||
|
||
# Log Out And Close Connection - elementary teardown keyword for all tests. | ||
Suite Setup Run Keywords | ||
... Prepare Test Suite | ||
Suite Teardown Run Keywords | ||
... Log Out And Close Connection | ||
Test Setup Run Keyword | ||
... Restore Initial DUT Connection Method | ||
|
||
Default Tags semiauto | ||
|
||
|
||
*** Test Cases *** | ||
OWR001.206 Install operating system on disk (OpenWrt) | ||
macpijan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[Documentation] This test installs OpenWrt on NVMe drive using dd program. | ||
... DTS is boot via iPXE and OpenWrt image is downloaded using wget. | ||
... OPENWRT_IMAGE_FILE - core of file name | ||
... OPENWRT_TARGET_DEVICE - target drive to be wiped out using dd (!) | ||
macpijan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[Tags] semiauto | ||
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR001.206 not supported | ||
Variable Should Exist ${OPENWRT_TARGET_DEVICE} | ||
Variable Should Exist ${OPENWRT_IMAGE_FILE} | ||
${selection}= Get Selection From User | ||
... Caution! You are about to install OpenWrt on ${OPENWRT_TARGET_DEVICE} device. Are you sure? | ||
... Yes, I'd like to wipe all the data existing on ${OPENWRT_TARGET_DEVICE} device. | ||
... No, let's skip OpenWrt installation. | ||
${contains_yes}= Run Keyword And Return Status Should Contain ${selection} Yes, I'd like to | ||
Skip If not(${contains_yes}) OpenWrt installation on ${OPENWRT_TARGET_DEVICE} device skipped. | ||
Power On | ||
Make Sure That Network Boot Is Enabled | ||
Boot Dasharo Tools Suite iPXE | ||
# Starting SSH server | ||
Write Bare Into Terminal K | ||
Read From Terminal Until Press Enter to continue. | ||
Press Enter | ||
Enter Shell In DTS | ||
VAR ${openwrt_image_gz}= ${OPENWRT_IMAGE_FILE} .gz separator=${EMPTY} | ||
Remove File ${openwrt_image_gz} | ||
macpijan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Remove File ${OPENWRT_IMAGE_FILE} | ||
VAR ${DEVICE_OS_USERNAME}= root scope=TEST | ||
VAR ${DEVICE_OS_PASSWORD}= ${EMPTY} scope=TEST | ||
Send File To DUT osfv-test-data/openwrt/${openwrt_image_gz} /${openwrt_image_gz} | ||
Execute Linux Command gzip -cdk ${openwrt_image_gz} | dd of=/dev/${OPENWRT_TARGET_DEVICE} bs=1M | ||
Execute Linux Command sync | ||
Execute Reboot Command | ||
Boot OpenWrt | ||
# Disabling DHCP server of OpenWrt | ||
Execute Command In Terminal /etc/init.d/odhcpd disable | ||
Execute Command In Terminal /etc/init.d/odhcpd stop | ||
# Enabling DHCP client for all LAN interfaces | ||
Execute Command In Terminal uci set network.lan.proto="dhcp" | ||
Execute Command In Terminal uci commit network | ||
Execute Command In Terminal service network restart | ||
|
||
OWR002.206 Boot operating system from disk (OpenWrt) | ||
[Documentation] Boot installed OpenWrt from NVMe drive, check identity. | ||
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR002.206 not supported | ||
Power On | ||
Boot OpenWrt | ||
${out}= Execute Command In Terminal uname -a | ||
Should Contain ${out} OpenWrt | ||
|
||
OWR003.206 Boot operating system from disk after cold-boot (OpenWrt) | ||
[Documentation] Boot OpenWrt from hard disk after cold-boot. | ||
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR003.206 not supported | ||
Power On | ||
Boot OpenWrt | ||
Execute Cold Boot | ||
${start_date}= Get Current Date | ||
Boot OpenWrt | ||
${end_date}= Get Current Date | ||
${delta_time}= Subtract Date From Date ${end_date} ${start_date} | ||
Log To Console Cold boot duration in seconds: ${delta_time} | ||
|
||
OWR004.206 Boot operating system from disk after warm-boot (OpenWrt) | ||
[Documentation] Boot OpenWrt from hard disk after warm-boot. | ||
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR004.206 not supported | ||
Power On | ||
Boot OpenWrt | ||
Download File OpenWrt https://cloud.3mdeb.com/public.php/dav/files/Aqe5Xj24pkoYLwX /bin/rtcwake | ||
Execute Command In Terminal chmod +x /bin/rtcwake | ||
Perform Warmboot Using Rtcwake | ||
${start_date}= Get Current Date | ||
Boot OpenWrt | ||
${end_date}= Get Current Date | ||
${delta_time}= Subtract Date From Date ${end_date} ${start_date} | ||
Log To Console Warm boot duration in seconds: ${delta_time} | ||
|
||
OWR005.206 Boot operating system from disk after reboot (OpenWrt) | ||
[Documentation] Boot OpenWrt from hard disk after reboot. | ||
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR005.206 not supported | ||
Power On | ||
Boot OpenWrt | ||
Execute Command In Terminal reboot | ||
${start_date}= Get Current Date | ||
Boot OpenWrt | ||
${end_date}= Get Current Date | ||
${delta_time}= Subtract Date From Date ${end_date} ${start_date} | ||
Log To Console Reboot duration in seconds: ${delta_time} | ||
|
||
OWR006.206 Scan WiFi networks (OpenWrt) | ||
[Documentation] Enable WiFi and scan for 3mdeb lab network. | ||
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR006.206 not supported | ||
Power On | ||
Boot OpenWrt | ||
Enable WiFi OpenWrt | ||
Scan WiFi For Network OpenWrt ${3_MDEB_WIFI_NETWORK} | ||
|
||
OWR007.206 Ethernet controller detection (OpenWrt) | ||
[Documentation] Check presence of ethernet controller using lspci. | ||
... Install pciutils if missing. Controller name defined in OPENWRT_ETHERNET_CONTROLLER. | ||
Skip If not ${TESTS_IN_OPENWRT_SUPPORT} OWR007.206 not supported | ||
Variable Should Exist ${OPENWRT_ETHERNET_CONTROLLER} | ||
Power On | ||
Boot OpenWrt | ||
Detect Or Install Package OpenWrt pciutils | ||
${lspci_out}= Execute Command In Terminal lspci | ||
Should Contain ${lspci_out} ${OPENWRT_ETHERNET_CONTROLLER} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
*** Settings *** | ||
Library Collections | ||
Resource ../keywords.robot | ||
Resource ../lib/platform/power.robot | ||
|
||
|
||
*** Keywords *** | ||
Boot OpenWrt | ||
[Documentation] Boot OpenWrt using Boot From File, kernel -> /efi/boot/bootx64.efi | ||
Enter Boot From File | ||
Enter Volume In File Explorer kernel | ||
Execute File In File Explorer efi | ||
Execute File In File Explorer boot | ||
Execute File In File Explorer bootx64.efi | ||
Read From Terminal Until Link is Up | ||
Sleep 2 | ||
Press Enter | ||
VAR ${BOOTED_OS_ID}= ${ENV_ID_OPENWRT} scope=GLOBAL | ||
Import Variables ${CURDIR}/../os-config/${BOOTED_OS_ID}-credentials.py | ||
Telnet.Set Prompt ${DEVICE_OS_ROOT_PROMPT} prompt_is_regexp=False | ||
|
||
Detect Or Install Package OpenWrt | ||
[Documentation] Check if package is installed using apk, attempt to install | ||
... otherwise. Requires working internet connection. | ||
[Arguments] ${package} | ||
${apk_info_grep}= Execute Command In Terminal apk info | grep ${package} | ||
# This double filtering is dirty fix for random 'apk' errors on output. | ||
${apk_info_grep_second}= Get Lines Containing String ${apk_info_grep} ${package} | ||
IF $apk_info_grep_second != $package | ||
${apk_add_package}= Execute Command In Terminal apk add ${package} | ||
Should Contain ${apk_add_package} OK | ||
END | ||
|
||
Enable WiFi OpenWrt | ||
[Documentation] Enabling WiFi in OpenWrt with uci. Setting it up and | ||
... waiting for wifi status output to be "up". | ||
... Number of attempts defined in OPENWRT_WIFI_UP_ATTEMPTS. | ||
Variable Should Exist ${OPENWRT_WIFI_UP_ATTEMPTS} | ||
${out_show}= Execute Command In Terminal uci show wireless | ||
Should Contain ${out_show} wireless.radio0=wifi-device | ||
Execute Command In Terminal uci set wireless.radio0.country='PL' | ||
Execute Command In Terminal uci set wireless.radio0.disabled='0' | ||
Execute Command In Terminal uci commit wireless | ||
Execute Command In Terminal wifi reload | ||
Execute Command In Terminal wifi up | ||
Press Enter | ||
FOR ${index} IN RANGE 0 ${OPENWRT_WIFI_UP_ATTEMPTS} | ||
TRY | ||
${up_out}= Execute Command In Terminal wifi status | grep '"up":' | ||
EXCEPT | ||
Log To Console No prompt, sending Enter. | ||
Press Enter | ||
END | ||
${contains}= Run Keyword And Return Status Should Contain ${up_out} "up": true, | ||
IF ${contains} == ${TRUE} BREAK | ||
END | ||
|
||
Scan WiFi For Network OpenWrt | ||
[Documentation] Sanning for WiFi network named by ESSID. Interface name extracted | ||
... from wifi status command output. Number of attempts defined in OPENWRT_WIFI_SCAN_ATTEMPTS. | ||
[Arguments] ${essid} | ||
Variable Should Exist ${OPENWRT_WIFI_SCAN_ATTEMPTS} | ||
VAR @{empty_list}= @{EMPTY} | ||
${ifname_grep}= Execute Command In Terminal wifi status | grep "ifname" | ||
${re_search}= Get Regexp Matches ${ifname_grep} (\\s*)(\"ifname\":\\s*)\"([^"]*)\", 3 | ||
Should Not Be Equal ${re_search} ${empty_list} | ||
FOR ${index} IN RANGE 0 ${OPENWRT_WIFI_SCAN_ATTEMPTS} | ||
${iwinfo_scan_out}= Execute Command In Terminal iwinfo ${re_search}[0] scanning | grep ${essid} | ||
${contains}= Run Keyword And Return Status Should Contain ${iwinfo_scan_out} ${essid} | ||
Pass Execution If ${contains} == ${TRUE} ${essid} network found in ${index} attempt(s). | ||
END | ||
Fail Searching for ${essid} network failed in ${OPENWRT_WIFI_SCAN_ATTEMPTS} attempts. | ||
|
||
Download File OpenWrt | ||
[Documentation] Download file from the given URL. | ||
[Arguments] ${remote_url} ${local_path} ${timeout}=30 | ||
Wait Until Keyword Succeeds 5x 1s | ||
... Check Internet Connection On Linux | ||
${out}= Execute Linux Command | ||
... wget --no-check-certificate -O ${local_path} ${remote_url} | ||
... ${timeout} | ||
Should Contain ${out} ${local_path} | ||
Should Not Contain ${out} failed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SPDX-FileCopyrightText: 2025 3mdeb <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
DEVICE_OS_ROOT_PROMPT = f"root@OpenWrt:~#" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.