From dc87d8e61fac8b2c51cbd4c120adca49e6f46b77 Mon Sep 17 00:00:00 2001 From: Mariia_Azbeleva Date: Thu, 2 Nov 2023 11:25:41 +0200 Subject: [PATCH] Add LenovoX1 test set Signed-off-by: Mariia Azbeleva --- Robot-Framework/config/variables.robot | 6 +++ .../resources/ssh_keywords.resource | 46 ++++++++++++++---- .../test-suites/bat-tests/apps.robot | 31 +++++++----- .../test-suites/bat-tests/netvm.robot | 48 +++++++------------ .../test-suites/bat-tests/others.robot | 4 +- 5 files changed, 81 insertions(+), 54 deletions(-) diff --git a/Robot-Framework/config/variables.robot b/Robot-Framework/config/variables.robot index 9c0de7b..d8ad387 100644 --- a/Robot-Framework/config/variables.robot +++ b/Robot-Framework/config/variables.robot @@ -23,6 +23,12 @@ Set Variables Set Global Variable ${THREADS_NUMBER} ${config['addresses']['${DEVICE}']['threads']} Set Global Variable ${NETVM_NAME} net-vm Set Global Variable ${NETVM_SERVICE} microvm@${NETVM_NAME}.service + Set Global Variable ${NETVM_IP} 192.168.101.1 + Set Global Variable ${GUI_VM} gui-vm.ghaf + Set Global Variable ${CHROMIUM_VM} chromium-vm.ghaf + Set Global Variable ${GALA_VM} gala-vm.ghaf + Set Global Variable ${ZATHURA_VM} zathura-vm.ghaf + Read Config [Arguments] ${file_path}=../config/test_config.json diff --git a/Robot-Framework/resources/ssh_keywords.resource b/Robot-Framework/resources/ssh_keywords.resource index 70eb161..17ad23f 100644 --- a/Robot-Framework/resources/ssh_keywords.resource +++ b/Robot-Framework/resources/ssh_keywords.resource @@ -55,6 +55,38 @@ Connect Should Contain ${output} ${target_output} [Return] ${connection} +Connect to ghaf host + [Documentation] Open ssh connection to ghaf host + Log To Console Connecting to Ghaf Host + ${connection} Connect + Set Global Variable ${ghaf_host_ssh} ${connection} + [Return] ${connection} + +Connect to netvm + [Documentation] Connect to netvm directly from test run machine, using + ... jumphost, this allows using standard SSHLibrary + ... commands, like 'Execute Command' + Connect to ghaf host + Log To Console Connecting to NetVM + ${connection} Open Connection ${NETVM_IP} port=22 + ${output} Login username=${LOGIN} password=${PASSWORD} jumphost_index_or_alias=${ghaf_host_ssh} + Set Global Variable ${netvm_ssh} ${connection} + [Return] ${netvm_ssh} + +Connect to guivm + Log To Console Connecting to GuiVM + ${connection}= Open Connection ${GUI_VM} port=22 + ${output}= Login username=${LOGIN} password=${PASSWORD} jumphost_index_or_alias=${netvm_ssh} + Set Global Variable ${guivm_ssh} ${connection} + [Return] ${guivm_ssh} + +Connect to chromium vm + Log To Console Connecting to Chromium VM + ${connection}= Open Connection ${CHROMIUM_VM} port=22 + ${output}= Login username=${LOGIN} password=${PASSWORD} jumphost_index_or_alias=${netvm_ssh} + Set Global Variable ${chromium_vm} ${connection} + [Return] ${chromium_vm} + Verify Systemctl status [Arguments] ${range}=60 [Documentation] Check is systemctl running with given loop ${range} @@ -79,8 +111,9 @@ Verify Systemctl status Start Chromium Log To Console ${\n}Starting Chromium - ${command}= Set Variable chromium-browser --enable-features=UseOzonePlatform --ozone-platform=wayland - ${command_output}= Execute Command nohup ${command} > output.log 2>&1 & + Execute Command sh -c 'cat /etc/xdg/weston/weston.ini | grep chromium | cut -c 6- | sed '\''s/"/\\\"/g'\'' > chromium_launcher' + Execute Command chmod 755 chromium_launcher + Execute Command nohup sudo -u ${LOGIN} ./chromium_launcher > output.log 2>&1 & Start Firefox [Documentation] It's needed to set display variable manually because there is no real monitor connected to DUT @@ -91,11 +124,6 @@ Is process started [Arguments] ${pid} ${rc}= Execute Command ps -p ${pid} return_rc=True ${status}= Run Keyword And Return Status Should Be Equal As Integers ${rc[1]} 0 - IF ${status} - Log To Console Process ${pid} exists - ELSE - Log To Console Process ${pid} doesn't exist - END [Return] ${status} Find pid by name @@ -104,13 +132,12 @@ Find pid by name ${output}= Execute Command sh -c 'ps aux | grep "${proc_name}" | grep -v grep' Log ${output} @{pids}= Find Pid ${output} ${proc_name} - Log To Console Found PIDs: ${pids} + Log To Console Found PIDs for process '${proc_name}':\n${pids} [Return] @{pids} Kill process [Arguments] @{pids} ${sig}=15 FOR ${pid} IN @{pids} - Log To Console Send kill -${sig} to ${pid} Execute Command kill -${sig} ${pid} FOR ${i} IN RANGE 5 ${ps_exists}= Is Process Started ${pid} @@ -122,6 +149,7 @@ Kill process END IF ${ps_exists} FAIL Process ${pid} haven't stopped END + Log To Console Killed processes: @{pids} Verify service status [Documentation] Check if service is running with given loop ${range} diff --git a/Robot-Framework/test-suites/bat-tests/apps.robot b/Robot-Framework/test-suites/bat-tests/apps.robot index 5caeb25..6fad6a3 100644 --- a/Robot-Framework/test-suites/bat-tests/apps.robot +++ b/Robot-Framework/test-suites/bat-tests/apps.robot @@ -8,6 +8,7 @@ Resource ../../resources/ssh_keywords.resource Resource ../../config/variables.robot Suite Teardown Close All Connections + *** Test Cases *** Start Firefox @@ -15,17 +16,25 @@ Start Firefox [Tags] bat SP-T45 nuc orin-agx Connect Start Firefox - @{pid}= Find pid by name firefox - Should Not Be Empty ${pid} Firefox is not started - [Teardown] Kill process @{pid} - + Check that the application was started firefox + [Teardown] Kill process @{app_pids} -Start Chromium - [Documentation] Start Chromium and verify process started - [Tags] depricated - Connect +Start Chromium on LenovoX1 + [Documentation] Start Chromium in dedicated VM and verify process started + [Tags] bat SP-T97 lenovoX1 + [Setup] Connect to netvm + Connect to guivm Start Chromium - @{pid}= Find pid by name chromium - Should Not Be Empty ${pid} Chromium is not started - [Teardown] Kill process @{pid} + Connect to chromium vm + Check that the application was started chromium + [Teardown] Kill process @{app_pids} + + +*** Keywords *** +Check that the application was started + [Arguments] ${app_name} + @{found_pids} Find pid by name ${app_name} + Set Global Variable @{app_pids} @{found_pids} + Should Not Be Empty ${app_pids} ${app_name} is not started + Log To Console ${app_name} is started diff --git a/Robot-Framework/test-suites/bat-tests/netvm.robot b/Robot-Framework/test-suites/bat-tests/netvm.robot index 713bff8..6cd1d6b 100644 --- a/Robot-Framework/test-suites/bat-tests/netvm.robot +++ b/Robot-Framework/test-suites/bat-tests/netvm.robot @@ -16,15 +16,15 @@ ${SSID} test_network ${wifi_pswd} test1234 ${netwotk_ip} 192.168.1.1 ${netvm_state} ${EMPTY} -${ghaf_host} ${EMPTY} -${netvm} ${EMPTY} +${ghaf_host_ssh} ${EMPTY} +${netvm_ssh} ${EMPTY} *** Test Cases *** Verify NetVM is started [Documentation] Verify that NetVM is active and running - [Tags] bat SP-T49 nuc orin-agx orin-nx + [Tags] bat SP-T49 nuc orin-agx orin-nx lenovoX1 [Setup] Connect to ghaf host Verify service status service=${netvm_service} Check Network Availability ${netvm_ip} expected_result=True range=5 @@ -32,34 +32,34 @@ Verify NetVM is started Wifi passthrought into NetVM [Documentation] Verify that wifi works inside netvm - [Tags] bat SP-T50 nuc orin-agx + [Tags] bat SP-T50 nuc orin-agx lenovoX1 ... test:retry(1) [Setup] Run Keywords ... Connect to ghaf host AND Connect to netvm AND ... Verify service status service=wpa_supplicant.service - Configure wifi ${netvm} ${SSID} ${wifi_pswd} + Configure wifi ${netvm_ssh} ${SSID} ${wifi_pswd} Get wifi IP Check Network Availability ${netwotk_ip} expected_result=True Log To Console Switch connection to Ghaf Host - Switch Connection ${ghaf_host} + Switch Connection ${ghaf_host_ssh} Check Network Availability ${netwotk_ip} expected_result=False [Teardown] Run Keywords Remove Wifi configuration AND Close All Connections NetVM stops and starts successfully [Documentation] Verify that NetVM stops properly and starts after that - [Tags] bat SP-T52 nuc orin-agx orin-nx + [Tags] bat SP-T52 nuc orin-agx orin-nx lenovoX1 [Setup] Connect to ghaf host Restart NetVM [Teardown] Run Keywords Start NetVM if dead AND Close All Connections NetVM is wiped after restarting [Documentation] Verify that created file will be removed after restarting VM - [Tags] bat SP-T53 nuc orin-agx orin-nx + [Tags] bat SP-T53 nuc orin-agx orin-nx lenovoX1 [Setup] Run Keywords ... Connect to ghaf host AND Connect to netvm - Switch Connection ${netvm} + Switch Connection ${netvm_ssh} Create file /etc/test.txt - Switch Connection ${ghaf_host} + Switch Connection ${ghaf_host_ssh} Restart NetVM Close All Connections Connect to ghaf host @@ -71,10 +71,10 @@ NetVM is wiped after restarting Verify wpa_supplicant.service is running [Documentation] Verify that wpa_supplicant.service exists and is running - [Tags] bat SP-T82 nuc orin-agx + [Tags] bat SP-T82 nuc orin-agx lenovoX1 [Setup] Run Keywords ... Connect to ghaf host AND Connect to netvm - Switch Connection ${netvm} + Switch Connection ${netvm_ssh} Verify service status service=wpa_supplicant.service [Teardown] Run Keywords Close All Connections @@ -83,7 +83,7 @@ Verify NetVM PCI device passthrough [Tags] bat SP-T101 nuc orin-agx orin-nx [Setup] Run Keywords ... Connect to ghaf host AND Connect to netvm - Verify microvm PCI device passthrough host_connection=${ghaf_host} vm_connection=${netvm} vmname=${NETVM_NAME} + Verify microvm PCI device passthrough host_connection=${ghaf_host_ssh} vm_connection=${netvm_ssh} vmname=${NETVM_NAME} [Teardown] Run Keywords Close All Connections @@ -98,31 +98,15 @@ Restart NetVM Start NetVM Check if ssh is ready on netvm -Connect to ghaf host - [Documentation] Open ssh connection to ghaf host - ${connection}= Connect - Set Global Variable ${ghaf_host} ${connection} - [Return] ${connection} - -Connect to netvm - [Documentation] Connect to netvm directly from test run machine, using - ... jumphost, this allows using standard SSHLibrary - ... commands, like 'Execute Command' - Log To Console Connecting to NetVM - ${connection}= Open Connection ${NETVM_IP} port=22 - ${output}= Login username=${LOGIN} password=${PASSWORD} jumphost_index_or_alias=${ghaf_host} - Set Global Variable ${netvm} ${connection} - [Return] ${netvm} - Configure wifi - [Arguments] ${netvm} ${SSID} ${passw} - Switch Connection ${netvm} + [Arguments] ${netvm_ssh} ${SSID} ${passw} + Switch Connection ${netvm_ssh} Log To Console Configuring Wifi Execute Command sh -c "wpa_passphrase ${SSID} ${passw} > /etc/wpa_supplicant.conf" sudo=True sudo_password=${PASSWORD} Execute Command systemctl restart wpa_supplicant.service sudo=True sudo_password=${PASSWORD} Remove Wifi configuration - Switch Connection ${netvm} + Switch Connection ${netvm_ssh} Log To Console Removing Wifi configuration Execute Command rm /etc/wpa_supplicant.conf sudo=True sudo_password=${PASSWORD} Execute Command systemctl restart wpa_supplicant.service sudo=True sudo_password=${PASSWORD} diff --git a/Robot-Framework/test-suites/bat-tests/others.robot b/Robot-Framework/test-suites/bat-tests/others.robot index 8d43553..5a12b2d 100644 --- a/Robot-Framework/test-suites/bat-tests/others.robot +++ b/Robot-Framework/test-suites/bat-tests/others.robot @@ -10,7 +10,7 @@ Resource ../../resources/ssh_keywords.resource Test ghaf version format [Documentation] Test getting Ghaf version and verify its format: ... Expected format: major.minor.yyyymmdd.commit_hash - [Tags] bat SP-T59 nuc orin-agx orin-nx riscv + [Tags] bat SP-T59 nuc orin-agx orin-nx riscv lenovoX1 [Setup] Connect Verify Ghaf Version Format [Teardown] Close All Connections @@ -18,7 +18,7 @@ Test ghaf version format Test nixos version format [Documentation] Test getting Nixos version and verify its format: ... Expected format: major.minor.yyyymmdd.commit_hash (name) - [Tags] bat SP-T60 nuc orin-agx orin-nx riscv + [Tags] bat SP-T60 nuc orin-agx orin-nx riscv lenovoX1 [Setup] Connect Verify Nixos Version Format [Teardown] Close All Connections