From 72ffc481327dbcad15de94c9d77c3e2bad91d136 Mon Sep 17 00:00:00 2001 From: Samuli Leivo Date: Sat, 14 Dec 2024 00:39:22 +0200 Subject: [PATCH] Adapt to changes introduced by ghaf PR827 Signed-off-by: Samuli Leivo --- Robot-Framework/config/variables.robot | 3 +++ .../resources/gui_keywords.resource | 1 - .../resources/ssh_keywords.resource | 24 +++++++++++++++---- .../test-suites/bat-tests/__init__.robot | 13 ++++++++++ .../test-suites/bat-tests/apps.robot | 12 +++++----- .../test-suites/bat-tests/business_vm.robot | 14 +++++------ .../test-suites/bat-tests/gui-vm.robot | 22 +++++++++++------ 7 files changed, 64 insertions(+), 25 deletions(-) diff --git a/Robot-Framework/config/variables.robot b/Robot-Framework/config/variables.robot index 6c006bf5..95313a10 100644 --- a/Robot-Framework/config/variables.robot +++ b/Robot-Framework/config/variables.robot @@ -62,6 +62,9 @@ Set Variables ${result} Run Process sh -c cat /run/secrets/wifi-password shell=true Set Global Variable ${TEST_WIFI_PSWD} ${result.stdout} + Set Global Variable ${USER_LOGIN} testuser + Set Global Variable ${USER_PASSWORD} testpw + Set Log Level INFO IF $BUILD_ID != '${EMPTY}' diff --git a/Robot-Framework/resources/gui_keywords.resource b/Robot-Framework/resources/gui_keywords.resource index 3e89c56b..8d2b0ef5 100644 --- a/Robot-Framework/resources/gui_keywords.resource +++ b/Robot-Framework/resources/gui_keywords.resource @@ -151,4 +151,3 @@ GUI Unlock Start ydotoold Log To Console Typing password to unlock Type string and press enter ${PASSWORD} - diff --git a/Robot-Framework/resources/ssh_keywords.resource b/Robot-Framework/resources/ssh_keywords.resource index 28b35ae1..42c07b9c 100644 --- a/Robot-Framework/resources/ssh_keywords.resource +++ b/Robot-Framework/resources/ssh_keywords.resource @@ -94,14 +94,14 @@ Connect to netvm RETURN ${netvm_ssh} Connect to VM - [Arguments] ${vm_name} + [Arguments] ${vm_name} ${user}=${LOGIN} ${pw}=${PASSWORD} Log To Console Connecting to ${vm_name} Check if ssh is ready on vm ${vm_name} ${failed_connection} Set variable True FOR ${i} IN RANGE 3 TRY ${connection}= Open Connection ${vm_name} port=22 prompt=\$ timeout=30 - ${output}= Login username=${LOGIN} password=${PASSWORD} jumphost_index_or_alias=${netvm_ssh} + ${output}= Login username=${user} password=${pw} jumphost_index_or_alias=${netvm_ssh} EXCEPT ChannelException: ChannelException(2, 'Connect failed') type=LITERAL Sleep 1 CONTINUE @@ -184,12 +184,12 @@ Find pid by name RETURN @{pids} Kill process - [Arguments] @{pids} ${sig}=15 + [Arguments] @{pids} ${sig}=9 FOR ${pid} IN @{pids} IF '${PID}' == '${EMPTY}' BREAK END - Execute Command kill -${sig} ${pid} + Execute Command kill -${sig} ${pid} sudo=True sudo_password=${password} timeout=15 FOR ${i} IN RANGE 5 ${ps_exists}= Is Process Started ${pid} IF ${ps_exists} @@ -489,3 +489,19 @@ Connect to VM if not already connected Connect to netvm Connect to VM ${vm_name} END + +Detect first boot + [Documentation] Determine desktop state after boot by attempting login to gui-vm as testuser + Log To Console Detecting if this is first boot by trying test user credentials + Verify service status range=15 service=microvm@gui-vm.service expected_status=active expected_state=running + Connect to netvm + ${status} ${output} Run Keyword And Ignore Error Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} + IF $status=='PASS' + Log To Console Test user exists + RETURN ${False} + END + RETURN ${True} + +Create test user + Log To Console Creating test user + Execute Command systemctl start setup-test-user.service sudo=True sudo_password=${password} diff --git a/Robot-Framework/test-suites/bat-tests/__init__.robot b/Robot-Framework/test-suites/bat-tests/__init__.robot index 332eb959..7047811e 100644 --- a/Robot-Framework/test-suites/bat-tests/__init__.robot +++ b/Robot-Framework/test-suites/bat-tests/__init__.robot @@ -27,6 +27,19 @@ Common Setup Log versions Run journalctl recording + IF "Lenovo" in "${DEVICE}" + ${first_boot} Detect first boot + IF ${first_boot} + Close All Connections + ${connection} Connect + Connect to netvm + Connect to VM ${GUI_VM} + Create test user + END + Close All Connections + ${connection} Connect + END + Common Teardown IF ${connection} Connect diff --git a/Robot-Framework/test-suites/bat-tests/apps.robot b/Robot-Framework/test-suites/bat-tests/apps.robot index 18b56e7f..e3f803f6 100644 --- a/Robot-Framework/test-suites/bat-tests/apps.robot +++ b/Robot-Framework/test-suites/bat-tests/apps.robot @@ -31,7 +31,7 @@ Start Chrome on LenovoX1 [Tags] bat pre-merge SP-T92 lenovo-x1 Verify service status range=15 service=microvm@chrome-vm.service expected_status=active expected_state=running Connect to netvm - Connect to VM ${GUI_VM} + Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} Check if ssh is ready on vm ${CHROME_VM} Start XDG application 'Google Chrome' Connect to VM ${CHROME_VM} @@ -42,7 +42,7 @@ Start Zathura on LenovoX1 [Documentation] Start Zathura in dedicated VM and verify process started [Tags] bat pre-merge SP-T105 lenovo-x1 [Setup] Connect to netvm - Connect to VM ${GUI_VM} + Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} Check if ssh is ready on vm ${ZATHURA_VM} Start XDG application 'PDF Viewer' Connect to VM ${ZATHURA_VM} @@ -55,7 +55,7 @@ Start Gala on LenovoX1 [Documentation] Start Gala in dedicated VM and verify process started [Tags] bat pre-merge SP-T104 lenovo-x1 [Setup] Connect to netvm - Connect to VM ${GUI_VM} + Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} Check if ssh is ready on vm ${GALA_VM} Start XDG application GALA Connect to VM ${GALA_VM} @@ -66,7 +66,7 @@ Start Element on LenovoX1 [Documentation] Start Element in dedicated VM and verify process started [Tags] bat pre-merge SP-T52 lenovo-x1 [Setup] Connect to netvm - Connect to VM ${GUI_VM} + Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} Check if ssh is ready on vm ${COMMS_VM} Start XDG application Element Connect to VM ${COMMS_VM} @@ -77,7 +77,7 @@ Start Slack on LenovoX1 [Documentation] Start Slack in dedicated VM and verify process started [Tags] bat pre-merge SP-T181 lenovo-x1 [Setup] Connect to netvm - Connect to VM ${GUI_VM} + Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} Check if ssh is ready on vm ${COMMS_VM} Start XDG application Slack Connect to VM ${COMMS_VM} @@ -88,7 +88,7 @@ Start Appflowy on LenovoX1 [Documentation] Start Appflowy in dedicated VM and verify process started [Tags] appflowy # Removed bat tag & lenovo-x1 tag until final decision of this app is made [Setup] Connect to netvm - Connect to VM ${GUI_VM} + Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} Check if ssh is ready on vm appflowy-vm Start XDG application AppFlowy Connect to VM ${APPFLOWY_VM} diff --git a/Robot-Framework/test-suites/bat-tests/business_vm.robot b/Robot-Framework/test-suites/bat-tests/business_vm.robot index 8548f91b..5b5c5f36 100644 --- a/Robot-Framework/test-suites/bat-tests/business_vm.robot +++ b/Robot-Framework/test-suites/bat-tests/business_vm.robot @@ -18,7 +18,7 @@ Start Microsoft Outlook on LenovoX1 [Documentation] Start Microsoft Outlook in Business-vm and verify process started [Tags] outlook SP-T176 Connect to netvm - Connect to VM ${GUI_VM} + Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} Start XDG application "Microsoft Outlook" Connect to VM ${BUSINESS_VM} Check that the application was started outlook @@ -28,7 +28,7 @@ Start Microsoft 365 on LenovoX1 [Documentation] Start Microsoft 365 in Business-vm and verify process started [Tags] microsoft365 SP-T178 Connect to netvm - Connect to VM ${GUI_VM} + Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} Start XDG application "Microsoft 365" Connect to VM ${BUSINESS_VM} Check that the application was started microsoft365 @@ -38,7 +38,7 @@ Start Microsoft Teams on LenovoX1 [Documentation] Start Microsoft Teams in Business-vm and verify process started [Tags] teams SP-T177 Connect to netvm - Connect to VM ${GUI_VM} + Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} Start XDG application Teams Connect to VM ${BUSINESS_VM} Check that the application was started teams @@ -48,7 +48,7 @@ Start Trusted Browser on LenovoX1 [Documentation] Start Trusted Browser in Business-vm and verify process started [Tags] trusted_browser SP-T179 Connect to netvm - Connect to VM ${GUI_VM} + Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} Start XDG application "Trusted Browser" Connect to VM ${BUSINESS_VM} Check that the application was started chrome @@ -58,7 +58,7 @@ Start Video Editor on LenovoX1 [Documentation] Start Video Editor in Business-vm and verify process started [Tags] video_editor SP-T244 Connect to netvm - Connect to VM ${GUI_VM} + Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} Start XDG application "Video Editor" Connect to VM ${BUSINESS_VM} Check that the application was started lossless @@ -68,7 +68,7 @@ Start Text Editor on LenovoX1 [Documentation] Start Text Editor in Business-vm and verify process started [Tags] text_editor SP-T243 Connect to netvm - Connect to VM ${GUI_VM} + Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} Start XDG application "Text Editor" Connect to VM ${BUSINESS_VM} Check that the application was started text-editor @@ -78,7 +78,7 @@ Start Xarchiver on LenovoX1 [Documentation] Start Xarchiver in Business-vm and verify process started [Tags] xarchiver SP-T242 Connect to netvm - Connect to VM ${GUI_VM} + Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} Start XDG application "Xarchiver" Connect to VM ${BUSINESS_VM} Check that the application was started xarchiver diff --git a/Robot-Framework/test-suites/bat-tests/gui-vm.robot b/Robot-Framework/test-suites/bat-tests/gui-vm.robot index bbb8aaea..13821d28 100644 --- a/Robot-Framework/test-suites/bat-tests/gui-vm.robot +++ b/Robot-Framework/test-suites/bat-tests/gui-vm.robot @@ -8,7 +8,7 @@ Resource ../../resources/ssh_keywords.resource Resource ../../config/variables.robot Resource ../../resources/common_keywords.resource Suite Teardown Close All Connections -Test Setup Run Keywords Connect to netvm AND Connect to VM ${GUI_VM} +Test Setup Run Keywords Connect to netvm AND Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD} *** Variables *** @@ -21,39 +21,47 @@ Start Calculator on LenovoX1 [Tags] calculator SP-T202 Start XDG application Calculator Check that the application was started calculator - [Teardown] Kill process @{app_pids} + [Teardown] Gui-vm apps teardown Start Sticky Notes on LenovoX1 [Documentation] Start Sticky Notes and verify process started [Tags] sticky_notes SP-T201 Start XDG application 'Sticky Notes' Check that the application was started sticky-wrapped - [Teardown] Kill process @{app_pids} + [Teardown] Gui-vm apps teardown Start Control Panel on LenovoX1 [Documentation] Start Control Panel and verify process started [Tags] control_panel SP-T205 Start XDG application 'Control Panel' Check that the application was started ctrl-panel - [Teardown] Kill process @{app_pids} + [Teardown] Gui-vm apps teardown Start Bluetooth Settings on LenovoX1 [Documentation] Start Bluetooth Settings and verify process started [Tags] bluetooth_settings SP-T204 Start XDG application 'Bluetooth Settings' Check that the application was started blueman - [Teardown] Kill process @{app_pids} + [Teardown] Gui-vm apps teardown Start Audio Control on LenovoX1 [Documentation] Start Audio Control and verify process started [Tags] audio_control SP-T203 Start XDG application 'Audio Control' Check that the application was started audio-control - [Teardown] Kill process @{app_pids} + [Teardown] Gui-vm apps teardown Start File Manager on LenovoX1 [Documentation] Start File Manager and verify process started [Tags] file_manager SP-T206 Start XDG application 'File Manager' Check that the application was started pcmanfm - [Teardown] Kill process @{app_pids} + [Teardown] Gui-vm apps teardown + + +*** Keywords *** + +Gui-vm apps teardown + Connect to VM ${GUI_VM} + Kill process @{app_pids} + Connect to VM ${GUI_VM} ${USER_LOGIN} ${USER_PASSWORD}