Skip to content

Commit

Permalink
Collect setup keywords and uppercase variables
Browse files Browse the repository at this point in the history
Signed-off-by: Maarit Härkönen <[email protected]>
  • Loading branch information
maaharko authored and azbeleva committed Dec 27, 2024
1 parent eab6735 commit e07bb80
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 128 deletions.
3 changes: 3 additions & 0 deletions Robot-Framework/resources/connection_keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ Initialize Variables And Connect
END
${CONNECTION} Connect
Set Suite Variable ${CONNECTION}

Initialize Variables, Connect And Start Logging
Initialize Variables And Connect
Log versions
Run journalctl recording
4 changes: 2 additions & 2 deletions Robot-Framework/resources/gui_keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Library Collections

*** Variables ***

${start_menu} ./launcher.png
${START_MENU} ./launcher.png
${LOGGED_IN_STATUS} ${True}

*** Keywords ***
Expand Down Expand Up @@ -104,7 +104,7 @@ Move cursor to corner
Verify login
[Documentation] Check that launcher icon is available on desktop
Log To Console Verifying login by trying to detect the launcher icon
Locate image on screen ${start_menu} 0.95 15
Locate image on screen ${START_MENU} 0.95 15

Verify logout
[Documentation] Check that dekstop is not available by running 'grim' which should have return code 1 in this case
Expand Down
19 changes: 9 additions & 10 deletions Robot-Framework/resources/ssh_keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ Library ../lib/output_parser.py


*** Variables ***
${netvm_ip} 192.168.101.1
${failed_connection} True
${NETVM_IP} 192.168.101.1

*** Keywords ***

Expand All @@ -26,12 +25,12 @@ Ping Host
Check Network Availability
[Arguments] ${host} ${expected_result}=True ${range}=5
Log To Console Checking network ${host} availability, expected: ${expected_result}
Set Global Variable ${is_available} False
Set Global Variable ${IS_AVAILABLE} False
FOR ${i} IN RANGE ${range}
Write ping ${host} -c 1
TRY
Read Until 1 received
Set Global Variable ${is_available} True
Set Global Variable ${IS_AVAILABLE} True
Log To Console ${host} is available
IF ${expected_result} == True
BREAK
Expand All @@ -45,8 +44,8 @@ Check Network Availability
END
END
END
IF ${is_available} != ${expected_result}
FAIL Expected availability of ${host}: ${expected_result}, in fact: ${is_available}
IF ${IS_AVAILABLE} != ${expected_result}
FAIL Expected availability of ${host}: ${expected_result}, in fact: ${IS_AVAILABLE}
END

Connect
Expand All @@ -61,7 +60,7 @@ 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}
Set Global Variable ${GHAF_HOST_SSH} ${connection}
RETURN ${connection}

Connect to netvm
Expand All @@ -76,7 +75,7 @@ Connect to netvm
FOR ${i} IN RANGE 10
TRY
${connection}= Open Connection ${NETVM_IP} port=22 prompt=\$ timeout=30
${output}= Login username=${LOGIN} password=${PASSWORD} jumphost_index_or_alias=${ghaf_host_ssh}
${output}= Login username=${LOGIN} password=${PASSWORD} jumphost_index_or_alias=${GHAF_HOST_SSH}
EXCEPT ChannelException: ChannelException(2, 'Connect failed') type=LITERAL
${diff}= Evaluate int(time.time()) - int(${start_time})
IF ${diff} < ${timeout}
Expand Down Expand Up @@ -434,7 +433,7 @@ Stop VM
Sleep 3
${status} ${state}= Verify service status service=microvm@${vm_name}.service expected_status=inactive expected_state=dead
Verify service shutdown status service=microvm@${vm_name}.service
Set Global Variable ${vm_state} ${state}
Set Global Variable ${VM_STATE} ${state}
Log To Console ${vm_name} is ${state}

Start VM
Expand All @@ -444,7 +443,7 @@ Start VM
Log To Console Going to start ${vm_name}
Execute Command systemctl start microvm@${vm_name}.service sudo=True sudo_password=${PASSWORD}
${status} ${state}= Verify service status service=microvm@${vm_name}.service expected_status=active expected_state=running
Set Global Variable ${vm_state} ${state}
Set Global Variable ${VM_STATE} ${state}
Log To Console ${vm_name} is ${state}
Wait until NetVM service started

Expand Down
41 changes: 5 additions & 36 deletions Robot-Framework/test-suites/bat-tests/__init__.robot
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,15 @@ Documentation BAT tests
Resource ../../resources/ssh_keywords.resource
Resource ../../resources/serial_keywords.resource
Resource ../../resources/common_keywords.resource
Resource ../../resources/gui_keywords.resource
Suite Setup Common Setup
Suite Teardown Common Teardown
Resource ../../resources/connection_keywords.resource
Suite Setup Initialize Variables, Connect And Start Logging
Suite Teardown End Logging And Close Connections

*** Variables ***

${connection} ${NONE}

*** Keywords ***

Common Setup
Set Variables ${DEVICE}
Run Keyword If "${DEVICE_IP_ADDRESS}" == "NONE" Get ethernet IP address
${port_22_is_available} Check if ssh is ready on device timeout=60
IF ${port_22_is_available} == False
FAIL Failed because port 22 of device was not available, tests can not be run.
END
${connection} Connect
Set Suite Variable ${connection}
Log versions
Run journalctl recording

IF "Lenovo" in "${DEVICE}"
${first_boot} Detect first boot
Close All Connections
${connection} Connect
Connect to netvm
Connect to VM ${GUI_VM}
Save most common icons and paths to icons
IF ${first_boot}
Create test user
END
GUI Log in
GUI Log out
Close All Connections
${connection} Connect
END

Common Teardown
IF ${connection}
End Logging And Close Connections
IF ${CONNECTION}
Connect
Log journctl
END
Expand Down
4 changes: 2 additions & 2 deletions Robot-Framework/test-suites/bat-tests/apps.robot
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Suite Teardown Close All Connections


*** Variables ***
@{app_pids} ${EMPTY}
@{APP_PIDS} ${EMPTY}


*** Test Cases ***
Expand Down Expand Up @@ -102,4 +102,4 @@ Kill Process And Log journalctl
[Documentation] Kill all running process and log journalctl
${output} Execute Command journalctl
Log ${output}
Kill process @{app_pids}
Kill process @{APP_PIDS}
26 changes: 13 additions & 13 deletions Robot-Framework/test-suites/bat-tests/netvm.robot
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ Suite Teardown Close All Connections


*** Variables ***
${netvm_ip} 192.168.101.1
${netvm_state} ${EMPTY}
${ghaf_host_ssh} ${EMPTY}
${netvm_ssh} ${EMPTY}
${NETVM_IP} 192.168.101.1
${NETVM_STATE} ${EMPTY}
${GHAF_HOST_SSH} ${EMPTY}
${NETVM_SSH} ${EMPTY}


*** Test Cases ***
Expand All @@ -25,15 +25,15 @@ Verify NetVM is started
[Tags] bat pre-merge SP-T45 nuc orin-agx orin-nx lenovo-x1
[Setup] Connect to ghaf host
Verify service status service=${netvm_service}
Check Network Availability ${netvm_ip} expected_result=True range=5
Check Network Availability ${NETVM_IP} expected_result=True range=5
[Teardown] Close All Connections

Wifi passthrought into NetVM
[Documentation] Verify that wifi works inside netvm
[Tags] bat pre-merge SP-T101 SP-T111 orin-agx lenovo-x1
[Setup] Run Keywords
... Connect to ghaf host AND Connect to netvm
Configure wifi ${netvm_ssh} ${TEST_WIFI_SSID} ${TEST_WIFI_PSWD}
Configure wifi ${NETVM_SSH} ${TEST_WIFI_SSID} ${TEST_WIFI_PSWD}
Get wifi IP
Check Network Availability 8.8.8.8 expected_result=True
Turn OFF WiFi ${TEST_WIFI_SSID}
Expand Down Expand Up @@ -65,13 +65,13 @@ NetVM is wiped after restarting
[Tags] bat pre-merge SP-T48 nuc orin-nx lenovo-x1
[Setup] Run Keywords
... Connect to ghaf host AND Connect to netvm
Switch Connection ${netvm_ssh}
Switch Connection ${NETVM_SSH}
Create file /etc/test.txt
Switch Connection ${ghaf_host_ssh}
Switch Connection ${GHAF_HOST_SSH}
Restart NetVM
Close All Connections
Connect to ghaf host
Check Network Availability ${netvm_ip} expected_result=True range=5
Check Network Availability ${NETVM_IP} expected_result=True range=5
Connect to netvm
Log To Console Create if created file still exists
Check file doesn't exist /etc/test.txt
Expand All @@ -82,7 +82,7 @@ Verify NetVM PCI device passthrough
[Tags] bat pre-merge SP-T96 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_ssh} vm_connection=${netvm_ssh} 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


Expand All @@ -106,7 +106,7 @@ Stop NetVM
Sleep 3
${status} ${state}= Verify service status service=${netvm_service} expected_status=inactive expected_state=dead
Verify service shutdown status service=${netvm_service}
Set Global Variable ${netvm_state} ${state}
Set Global Variable ${NETVM_STATE} ${state}
Log To Console NetVM is ${state}

Start NetVM
Expand All @@ -115,12 +115,12 @@ Start NetVM
Log To Console Going to start NetVM
Execute Command systemctl start ${netvm_service} sudo=True sudo_password=${PASSWORD} timeout=120 output_during_execution=True
${status} ${state}= Verify service status service=${netvm_service} expected_status=active expected_state=running
Set Global Variable ${netvm_state} ${state}
Set Global Variable ${NETVM_STATE} ${state}
Log To Console NetVM is ${state}
Wait until NetVM service started

Start NetVM if dead
[Documentation] Teardown keyword. Check global variable ${netvm_state} and start NetVM if it's stopped.
[Documentation] Teardown keyword. Check global variable ${NETVM_STATE} and start NetVM if it's stopped.
... Pre-condition: requires active ssh connection to ghaf host.
Start NetVM

Expand Down
16 changes: 8 additions & 8 deletions Robot-Framework/test-suites/bat-tests/timesync.robot
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Suite Teardown Close All Connections


*** Variables ***
${wrong_time} 01/11/23 11:00:00 UTC
${change_time} ${EMPTY}
${WRONG_TIME} 01/11/23 11:00:00 UTC
${CHANGE_TIME} ${EMPTY}


*** Test Cases ***
Expand All @@ -25,7 +25,7 @@ Time synchronization
Check that time is correct timezone=UTC

Stop timesync daemon
Set time ${wrong_time}
Set time ${WRONG_TIME}
Check time was changed

Start timesync daemon
Expand Down Expand Up @@ -67,21 +67,21 @@ Check that time is correct
Compare local and universal time

Set time
[Arguments] ${time}=${wrong_time}
${change_time} Get Time epoch
${change_time} Set Global Variable ${change_time}
[Arguments] ${time}=${WRONG_TIME}
${epoch_time} Get Time epoch
${CHANGE_TIME} Set Global Variable ${epoch_time}
Log To Console Setting time ${time}
Execute Command hwclock --set --date="${time}" sudo=True sudo_password=${PASSWORD}
Execute Command hwclock -s sudo=True sudo_password=${PASSWORD}
${output} Execute Command timedatectl -a

Check time was changed
[Documentation] Check that current system time is equal to given (time tolerance = 10 sec)
[Arguments] ${time}=${wrong_time} ${timezone}=UTC
[Arguments] ${time}=${WRONG_TIME} ${timezone}=UTC
${output} Execute Command timedatectl -a
${local_time} ${universal_time} ${rtc_time} ${device_time_zone} ${is_synchronized} Parse time info ${output}
${now} Get Time epoch
${time_diff} Evaluate ${now} - ${change_time}
${time_diff} Evaluate ${now} - ${CHANGE_TIME}
${expected_time} Convert To UTC ${time}
Log To Console Comparing device time: ${universal_time} and time which was set ${expected_time}
${time_close} Is time close ${universal_time} ${expected_time} tolerance_seconds=${time_diff}
Expand Down
11 changes: 2 additions & 9 deletions Robot-Framework/test-suites/boot-test/__init__.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
Documentation Boot test
Resource ../../resources/ssh_keywords.resource
Resource ../../config/variables.robot
Suite Setup Common Setup
Suite Teardown Common Teardown
Suite Setup Set Variables ${DEVICE}
Suite Teardown Close All Connections


*** Keywords ***

Common Setup
Set Variables ${DEVICE}

Common Teardown
Close All Connections
22 changes: 11 additions & 11 deletions Robot-Framework/test-suites/gui-tests/__init__.robot
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@ 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
Library ../../lib/gui_testing.py
Suite Setup Common Setup
Suite Teardown Common Teardown
Suite Setup Run Keywords Initialize Variables, Connect And Start Logging AND Login To Gui
Suite Teardown End Gui-vm Logging And Close Connections


*** Keywords ***

Common Setup
Set Variables ${DEVICE}
Run Keyword If "${DEVICE_IP_ADDRESS}" == "" Get ethernet IP address
${port_22_is_available} Check if ssh is ready on device timeout=180
IF ${port_22_is_available} == False
FAIL Failed because port 22 of device was not available, tests can not be run.
END
Connect
Login To GUI
IF "Lenovo" in "${DEVICE}"
Verify service status range=15 [email protected] expected_status=active expected_state=running
Connect to netvm
Expand All @@ -48,5 +42,11 @@ Common Setup
Locate and click ${start_menu} 0.95 5
Move cursor to corner

Common Teardown
End Gui-vm Logging And Close Connections
Connect
IF "Lenovo" in "${DEVICE}"
Connect to netvm
Connect to VM ${GUI_VM}
END
Log journctl
Close All Connections
12 changes: 2 additions & 10 deletions Robot-Framework/test-suites/performance-tests/__init__.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
Documentation Performance tests
Resource ../../resources/ssh_keywords.resource
Resource ../../config/variables.robot
Suite Setup Common Setup
Suite Teardown Common Teardown
Suite Setup Set Variables ${DEVICE}
Suite Teardown Close All Connections


*** Keywords ***

Common Setup
Set Variables ${DEVICE}

Common Teardown
Close All Connections
8 changes: 2 additions & 6 deletions Robot-Framework/test-suites/performance-tests/network.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ Resource ../../resources/ssh_keywords.resource
Resource ../../resources/serial_keywords.resource
Resource ../../config/variables.robot
Resource ../../resources/performance_keywords.resource
Resource ../../resources/connection_keywords.resource
Library ../../lib/output_parser.py
Library Process
Library ../../lib/PerformanceDataProcessing.py ${DEVICE} ${BUILD_ID} ${JOB}
Library Collections
Library JSONLibrary
Suite Setup Common Setup
Suite Setup Initialize Variables And Connect
Suite Teardown Close All Connections


Expand Down Expand Up @@ -154,11 +155,6 @@ Measure UDP Bidir Throughput Big Packets


*** Keywords ***
Common Setup
Set Variables ${DEVICE}
Run Keyword If "${DEVICE_IP_ADDRESS}" == "NONE" Get ethernet IP address
Connect

Run iperf server on DUT
[Documentation] Run iperf on DUT in server mode
Clear iptables rules
Expand Down
Loading

0 comments on commit e07bb80

Please sign in to comment.