From 7d96bb64870ea888434a41b177d15786e9519348 Mon Sep 17 00:00:00 2001 From: Samuli Leivo Date: Tue, 11 Feb 2025 10:27:09 +0200 Subject: [PATCH] Add iterations to Connect keyword After ethernet interface was passed through to net-vm on lenovo-x1 iterative check of login to net-vm was first added to boot tests of lenovo-x1. Fails after gui reboot tests showed that connection iterations need be added also after gui reboot, namely every time the device boots or reboots. Decided to put the default number of iterations in Connect keyword to 1 (as before) and give more iterations only when it is used after boot or reboot. Signed-off-by: Samuli Leivo --- .../resources/common_keywords.resource | 13 ----------- .../resources/ssh_keywords.resource | 23 ++++++++++++++----- .../test-suites/boot-test/boot_test.robot | 5 ++-- .../boot-test/relay_boot_test.robot | 4 ++-- .../test-suites/gui-tests/__init__.robot | 1 - .../gui-tests/gui_power_options.robot | 2 +- 6 files changed, 22 insertions(+), 26 deletions(-) diff --git a/Robot-Framework/resources/common_keywords.resource b/Robot-Framework/resources/common_keywords.resource index ce722124..e07742bc 100644 --- a/Robot-Framework/resources/common_keywords.resource +++ b/Robot-Framework/resources/common_keywords.resource @@ -82,19 +82,6 @@ Check If Device Is Up END END -Check if netvm has started on Lenovo-X1 - [Arguments] ${iterations}=10 - FOR ${i} IN RANGE ${iterations} - ${pass_status} ${connection} Run Keyword And Ignore Error Connect target_output=ghaf@net-vm - IF $pass_status=='PASS' - RETURN - ELSE - Close All Connections - END - Sleep 1 - END - FAIL Failed to connect net-vm - Log versions ${ghaf_version} Execute Command ghaf-version Log to console Ghaf version: ${ghaf_version} diff --git a/Robot-Framework/resources/ssh_keywords.resource b/Robot-Framework/resources/ssh_keywords.resource index a532aeb4..c44c62ff 100644 --- a/Robot-Framework/resources/ssh_keywords.resource +++ b/Robot-Framework/resources/ssh_keywords.resource @@ -47,18 +47,29 @@ Check Network Availability Connect [Documentation] Set up the SSH connection to the device - [Arguments] ${IP}=${DEVICE_IP_ADDRESS} ${PORT}=22 ${target_output}=None + [Arguments] ${IP}=${DEVICE_IP_ADDRESS} ${PORT}=22 ${target_output}=None ${iterations}=1 IF '${target_output}' != 'None' Log To Console Expecting ${target_output} target output - ELSE IF "Lenovo" in "${DEVICE}" + ELSE IF "Lenovo" in "${DEVICE}" or "NX" in "${DEVICE}" ${target_output} Set Variable ghaf@net-vm ELSE ${target_output} Set Variable ghaf@ghaf-host END - ${connection}= Open Connection ${IP} port=${PORT} prompt=\$ timeout=30 - ${output}= Login username=${LOGIN} password=${PASSWORD} - Should Contain ${output} ${target_output} - RETURN ${connection} + # Iterations are necessary (at least for lenovo-x1 target) because for a short period of time at boot ethernet interface passthrough to net-vm may not yet be ready. + Log Trying to connect to ${target_output} console=True + FOR ${i} IN RANGE ${iterations} + ${connection}= Open Connection ${IP} port=${PORT} prompt=\$ timeout=30 + ${output}= Login username=${LOGIN} password=${PASSWORD} + ${pass_status} ${output} Run Keyword And Ignore Error Should Contain ${output} ${target_output} + IF $pass_status=='PASS' + RETURN ${connection} + ELSE + Close All Connections + Log To Console Failed to connect. + END + Sleep 5 + END + FAIL Failed to connect Connect to ghaf host [Documentation] Open SSH connection to Ghaf Host diff --git a/Robot-Framework/test-suites/boot-test/boot_test.robot b/Robot-Framework/test-suites/boot-test/boot_test.robot index 926fe3d6..1f82e410 100644 --- a/Robot-Framework/test-suites/boot-test/boot_test.robot +++ b/Robot-Framework/test-suites/boot-test/boot_test.robot @@ -30,7 +30,7 @@ Verify booting after restart by power Log To Console The device started END IF "${CONNECTION_TYPE}" == "ssh" - Connect + Connect iterations=15 Verify service status service=init.scope ELSE IF "${CONNECTION_TYPE}" == "serial" Verify init.scope status via serial @@ -47,9 +47,8 @@ Verify booting LenovoX1 ELSE Log To Console The device started END - Check if netvm has started on Lenovo-X1 + Connect iterations=15 Verify service status service=init.scope - [Teardown] Teardown Verify booting RiscV Polarfire diff --git a/Robot-Framework/test-suites/boot-test/relay_boot_test.robot b/Robot-Framework/test-suites/boot-test/relay_boot_test.robot index d7c1a994..73fa61e4 100644 --- a/Robot-Framework/test-suites/boot-test/relay_boot_test.robot +++ b/Robot-Framework/test-suites/boot-test/relay_boot_test.robot @@ -31,7 +31,7 @@ Verify booting after restart by power Log To Console The device started END IF "${CONNECTION_TYPE}" == "ssh" - Connect + Connect iterations=15 Verify service status service=init.scope ELSE IF "${CONNECTION_TYPE}" == "serial" Verify init.scope status via serial @@ -48,7 +48,7 @@ Verify booting LenovoX1 ELSE Log To Console The device started END - Check if netvm has started on Lenovo-X1 + Connect iterations=15 Verify service status service=init.scope [Teardown] Test Teardown diff --git a/Robot-Framework/test-suites/gui-tests/__init__.robot b/Robot-Framework/test-suites/gui-tests/__init__.robot index 4883b4ea..5e4d8f92 100644 --- a/Robot-Framework/test-suites/gui-tests/__init__.robot +++ b/Robot-Framework/test-suites/gui-tests/__init__.robot @@ -4,7 +4,6 @@ *** Settings *** Documentation GUI tests Resource ../../resources/ssh_keywords.resource -Resource ../../resources/serial_keywords.resource Resource ../../resources/gui_keywords.resource Resource ../../resources/common_keywords.resource Resource ../../resources/connection_keywords.resource diff --git a/Robot-Framework/test-suites/gui-tests/gui_power_options.robot b/Robot-Framework/test-suites/gui-tests/gui_power_options.robot index 8da4d8e0..983b4c75 100644 --- a/Robot-Framework/test-suites/gui-tests/gui_power_options.robot +++ b/Robot-Framework/test-suites/gui-tests/gui_power_options.robot @@ -91,7 +91,7 @@ GUI Reboot Log To Console Device started END IF "Lenovo" in "${DEVICE}" - Connect to netvm + ${NETVM_SSH} Connect iterations=15 Connect to VM ${GUI_VM} ELSE Connect to ghaf host