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 a66f561
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 31 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
30 changes: 21 additions & 9 deletions Robot-Framework/resources/ssh_keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,34 @@ 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 boot for those targets which should expose net-vm to ethernet interface.
# Ghaf-host is accessible on these targets for a short period of time at boot.
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
IF "Lenovo" in "${DEVICE}"
IF "Lenovo" in "${DEVICE}" or "NX" in "${DEVICE}"
${connection} Connect
Set Global Variable ${NETVM_SSH} ${connection}
${connection} Connect to VM ${HOST_IP}
Expand All @@ -77,7 +89,7 @@ Connect to netvm
[Documentation] Open ssh connection to net-vm
${connected} Check ssh connection status net-vm
IF not ${connected}
IF "Lenovo" in "${DEVICE}"
IF "Lenovo" in "${DEVICE}" or "NX" in "${DEVICE}"
${connection} Connect
ELSE
Connect to ghaf host
Expand All @@ -95,7 +107,7 @@ Connect to VM
Check if ssh is ready on vm ${vm_name}
${failed_connection} Set variable True
${start_time} Get Time epoch
IF "Lenovo" in "${DEVICE}"
IF "Lenovo" in "${DEVICE}" or "NX" in "${DEVICE}"
${jumphost} Set Variable ${NETVM_SSH}
ELSE
${jumphost} Set Variable ${GHAF_HOST_SSH}
Expand Down
4 changes: 2 additions & 2 deletions Robot-Framework/test-suites/bat-tests/netvm.robot
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ Wifi passthrought into NetVM (NUC)

NetVM stops and starts successfully
[Documentation] Verify that NetVM stops properly and starts after that
[Tags] bat SP-T47 SP-T90 nuc orin-nx
[Tags] bat SP-T47 SP-T90 nuc
[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-T48 nuc orin-nx
[Tags] bat SP-T48 nuc
[Setup] Connect to netvm
Create file /etc/test.txt
Switch Connection ${GHAF_HOST_SSH}
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=10
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=10
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=10
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=10
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=10
Connect to VM ${GUI_VM}
ELSE
Connect to ghaf host
Expand Down

0 comments on commit a66f561

Please sign in to comment.