Skip to content

Commit

Permalink
Change connection keywords
Browse files Browse the repository at this point in the history
Signed-off-by: Mariia Azbeleva <[email protected]>
  • Loading branch information
azbeleva committed Oct 18, 2024
1 parent f579d79 commit 81ffb53
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 12 deletions.
42 changes: 34 additions & 8 deletions Robot-Framework/resources/ssh_keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,23 @@ Connect to netvm
[Documentation] Connect to netvm directly from test run machine, using
... jumphost, this allows using standard SSHLibrary
... commands, like 'Execute Command'
[Arguments] ${timeout}=60
Connect to ghaf host
Log To Console Connecting to NetVM
${failed_connection} Set variable True
FOR ${i} IN RANGE 3
${start_time} Get Time epoch
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}
EXCEPT ChannelException: ChannelException(2, 'Connect failed') type=LITERAL
Sleep 1
CONTINUE
${diff}= Evaluate int(time.time()) - int(${start_time})
IF ${diff} < ${timeout}
Sleep 1
CONTINUE
ELSE
BREAK
END
END
${failed_connection} Set variable False
BREAK
Expand Down Expand Up @@ -292,28 +299,41 @@ Save log
Close All Connections

Check if ssh is ready on netvm
[Arguments] ${timeout}=30
[Arguments] ${timeout}=60
${start_time} Get Time epoch
FOR ${i} IN RANGE ${timeout}
${output} ${rc} Execute Command nc -zvw3 192.168.101.1 22 return_rc=True
${status} Run Keyword And Return Status
... Should Be Equal As Integers ${rc} 0
IF ${status}
BREAK
END
Sleep 1
${diff}= Evaluate int(time.time()) - int(${start_time})
IF ${diff} < ${timeout}
Sleep 1
CONTINUE
ELSE
BREAK
END
END
IF ${status} == False FAIL Port 22 of NetVM is not ready after ${timeout}

Check if ssh is ready on vm
[Arguments] ${vm} ${timeout}=30
${start_time} Get Time epoch
FOR ${i} IN RANGE ${timeout}
${output} ${rc} Execute Command nc -zvw3 ${vm} 22 return_rc=True
${status} Run Keyword And Return Status
... Should Be Equal As Integers ${rc} 0
IF ${status}
BREAK
END
Sleep 1
${diff}= Evaluate int(time.time()) - int(${start_time})
IF ${diff} < ${timeout}
Sleep 1
ELSE
BREAK
END
END
IF ${status} == False FAIL Port 22 of ${vm} is not ready after ${timeout}

Expand Down Expand Up @@ -367,7 +387,8 @@ Get wifi IP

Check if ssh is ready on device
[Arguments] ${timeout}=30
${is_ready} = Set Variable False
${is_ready} Set Variable False
${start_time} Get Time epoch
FOR ${i} IN RANGE ${timeout}
${rc} ${output} Run And Return Rc And Output nc -zvw3 ${DEVICE_IP_ADDRESS} 22
${status} Run Keyword And Return Status
Expand All @@ -377,7 +398,12 @@ Check if ssh is ready on device
${is_ready} = Set Variable True
BREAK
END
Sleep 1
${diff}= Evaluate int(time.time()) - int(${start_time})
IF ${diff} < ${timeout}
Sleep 1
ELSE
BREAK
END
END
IF ${is_ready} == False
Log to console Port 22 (ssh) of ${DEVICE} is not ready after ${timeout}
Expand Down
14 changes: 10 additions & 4 deletions Robot-Framework/test-suites/bat-tests/__init__.robot
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,29 @@ Resource ../../resources/serial_keywords.resource
Suite Setup Common Setup
Suite Teardown Common Teardown

*** Variables ***

${connection} ${NONE}

*** 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
${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
Connect
${connection} Connect
Set Suite Variable ${connection}
Log versions
Run journalctl recording

Common Teardown
Connect
Log journctl
IF ${connection}
Connect
Log journctl
END
Close All Connections

Run journalctl recording
Expand Down

0 comments on commit 81ffb53

Please sign in to comment.