Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SP-3152] Check the ability of ssh port before connecting #50

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Robot-Framework/resources/serial_keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Check Serial Connection
${output} = SerialLibrary.Read Until
${status} = Run Keyword And Return Status Should contain ${output} ghaf
IF ${status} BREAK
Log To Console ${output}
Sleep 1
END
Delete All Ports
Expand Down
20 changes: 20 additions & 0 deletions Robot-Framework/resources/ssh_keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,23 @@ Get wifi IP
Sleep 1
END
IF ${status} == False FAIL NetVM hasn't gotten an IP

Check if ssh is ready on device
[Arguments] ${timeout}=30
${is_ready} = Set Variable False
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
... Should Be Equal As Integers ${rc} 0
IF ${status}
Log to console ${output}
${is_ready} = Set Variable True
BREAK
END
Sleep 1
END
IF ${is_ready} == False
Log to console Port 22 (ssh) of ${DEVICE} is not ready after ${timeout}
END

[Return] ${is_ready}
15 changes: 13 additions & 2 deletions Robot-Framework/test-suites/boot_test.robot
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,30 @@ Teardown

Check If Device Is Up
[Arguments] ${range}=20
Set Global Variable ${IS_AVAILABLE} False
${start_time}= Get Time epoch
FOR ${i} IN RANGE ${range}
${ping}= Ping Host ${DEVICE_IP_ADDRESS}
IF ${ping}
Set Global Variable ${IS_AVAILABLE} True
Log To Console Ping ${DEVICE_IP_ADDRESS} successfull
BREAK
END
END

IF ${ping}
${port_22_is_available} Check if ssh is ready on device
IF ${port_22_is_available}
Set Global Variable ${IS_AVAILABLE} True
ELSE
Set Global Variable ${IS_AVAILABLE} False
END
END

${diff}= Evaluate int(time.time()) - int(${start_time})

IF ${IS_AVAILABLE} Log To Console Device woke up after ${diff} sec.

IF ${ping}==False
IF ${IS_AVAILABLE} == False
Log To Console Device is not available after reboot via SSH, waited for ${diff} sec!
IF "${SERIAL_PORT}" == "NONE"
Log To Console There is no address for serial connection
Expand Down