Skip to content

Commit

Permalink
Add iterations to Connect keyword
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
leivos-unikie committed Feb 13, 2025
1 parent b849bfd commit 7d96bb6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 26 deletions.
13 changes: 0 additions & 13 deletions Robot-Framework/resources/common_keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
23 changes: 17 additions & 6 deletions Robot-Framework/resources/ssh_keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions Robot-Framework/test-suites/boot-test/boot_test.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Robot-Framework/test-suites/boot-test/relay_boot_test.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion Robot-Framework/test-suites/gui-tests/__init__.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7d96bb6

Please sign in to comment.