Skip to content

Commit

Permalink
Refactor wifi test
Browse files Browse the repository at this point in the history
Signed-off-by: Mariia Azbeleva <[email protected]>
  • Loading branch information
azbeleva committed Oct 10, 2024
1 parent 7c682d3 commit f2e5711
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 50 deletions.
8 changes: 5 additions & 3 deletions Robot-Framework/config/variables.robot
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ Library OperatingSystem

*** Variables ***

${BUILD_ID} ${EMPTY}
${SWITCH_TOKEN} ${EMPTY}
${SWITCH_SECRET} ${EMPTY}
${BUILD_ID} ${EMPTY}
${SWITCH_TOKEN} ${EMPTY}
${SWITCH_SECRET} ${EMPTY}
${TEST_WIFI_SSID} ${EMPTY}
${TEST_WIFI_PSWD} ${EMPTY}


*** Keywords ***
Expand Down
4 changes: 3 additions & 1 deletion Robot-Framework/resources/ssh_keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ Check Network Availability
Read Until 1 received
Set Global Variable ${is_available} True
Log To Console ${host} is available
BREAK
IF ${expected_result} == True
BREAK
END
EXCEPT
IF ${expected_result} == False
Log To Console ${host} is unavailable
Expand Down
61 changes: 15 additions & 46 deletions Robot-Framework/test-suites/bat-tests/netvm.robot
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ Suite Teardown Close All Connections

*** Variables ***
${netvm_ip} 192.168.101.1
${SSID} test_network
${wifi_pswd} test1234
${netwotk_ip} 192.168.1.1
${netvm_state} ${EMPTY}
${ghaf_host_ssh} ${EMPTY}
${netvm_ssh} ${EMPTY}
Expand All @@ -32,35 +29,15 @@ Verify NetVM is started

Wifi passthrought into NetVM
[Documentation] Verify that wifi works inside netvm
[Tags] bat SP-T50
... test:retry(1)
[Setup] Run Keywords
... Connect to ghaf host AND Connect to netvm AND
... Verify service status service=wpa_supplicant.service
Configure wifi ${netvm_ssh} ${SSID} ${wifi_pswd}
Get wifi IP
Check Network Availability ${netwotk_ip} expected_result=True
Log To Console Switch connection to Ghaf Host
Switch Connection ${ghaf_host_ssh}
Check Network Availability ${netwotk_ip} expected_result=False
Remove Wifi configuration
Check Network Availability ${netwotk_ip} expected_result=False
[Teardown] Run Keywords Remove Wifi configuration AND Close All Connections

Wifi passthrought into NetVM on LenovoX1
[Documentation] Verify that wifi works inside netvm on LenovoX1 laptop
[Tags] bat SP-T108 lenovo-x1
... test:retry(1)
[Tags] bat SP-T50 SP-T108 nuc orin-agx lenovo-x1
[Setup] Run Keywords
... Connect to ghaf host AND Connect to netvm
Configure wifi ${netvm_ssh} ${SSID} ${wifi_pswd} lenovo=True
Check Network Availability ${netwotk_ip} expected_result=True
Log To Console Switch connection to Ghaf Host
Switch Connection ${ghaf_host_ssh}
Check Network Availability ${netwotk_ip} expected_result=False
Remove Wifi configuration lenovo=True
Check Network Availability ${netwotk_ip} expected_result=False
[Teardown] Run Keywords Remove Wifi configuration lenovo=True AND Close All Connections
Configure wifi ${netvm_ssh} ${TEST_WIFI_SSID} ${TEST_WIFI_PSWD}
Get wifi IP
Check Network Availability 8.8.8.8 expected_result=True
Remove Wifi configuration ${TEST_WIFI_SSID}
Check Network Availability 8.8.8.8 expected_result=False
[Teardown] Run Keywords Remove Wifi configuration ${TEST_WIFI_SSID} AND Close All Connections

NetVM stops and starts successfully
[Documentation] Verify that NetVM stops properly and starts after that
Expand Down Expand Up @@ -116,26 +93,18 @@ Restart NetVM
Check if ssh is ready on netvm

Configure wifi
[Arguments] ${netvm_ssh} ${SSID} ${passw} ${lenovo}=False
Switch Connection ${netvm_ssh}
Log To Console Configuring Wifi
IF ${lenovo}
Execute Command nmcli dev wifi connect ${SSID} password ${passw} sudo=True sudo_password=${PASSWORD}
ELSE
Execute Command sh -c "wpa_passphrase ${SSID} ${passw} > /etc/wpa_supplicant.conf" sudo=True sudo_password=${PASSWORD}
Execute Command systemctl restart wpa_supplicant.service sudo=True sudo_password=${PASSWORD}
END
[Arguments] ${netvm_ssh} ${SSID} ${passw} ${lenovo}=False
Switch Connection ${netvm_ssh}
Log To Console Configuring Wifi
Set Log Level NONE
Execute Command nmcli dev wifi connect ${SSID} password ${passw} sudo=True sudo_password=${PASSWORD}
Set Log Level INFO

Remove Wifi configuration
[Arguments] ${lenovo}=False
[Arguments] ${SSID}
Switch Connection ${netvm_ssh}
Log To Console Removing Wifi configuration
IF ${lenovo}
Execute Command nmcli con down id ${SSID} sudo=True sudo_password=${PASSWORD}
ELSE
Execute Command rm /etc/wpa_supplicant.conf sudo=True sudo_password=${PASSWORD}
Execute Command systemctl restart wpa_supplicant.service sudo=True sudo_password=${PASSWORD}
END
Execute Command nmcli con down id ${SSID} sudo=True sudo_password=${PASSWORD}

Stop NetVM
[Documentation] Ensure that NetVM is started, stop it and check the status.
Expand Down

0 comments on commit f2e5711

Please sign in to comment.