Skip to content

Commit

Permalink
Patch helps to overcome login issue.
Browse files Browse the repository at this point in the history
Sometimes the console via ssh is not connected and Login attempt fails,
This could be due to network issue.Attempting to login for 5 times if
the connection is not established in one go.

Signed-off-by: Abdul Haleem <[email protected]>
  • Loading branch information
abdhaleegit committed May 6, 2024
1 parent f9e4dc0 commit e2505f2
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions testcases/InstallUpstreamKernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,12 @@ def is_url(path):
self.prompt = self.cv_SYSTEM.util.build_prompt()
self.console_thread.console_terminate()
con.close()
time.sleep(10)
raw_pty = self.cv_SYSTEM.console.get_console()
for i in range(5):
raw_pty = self.wait_for(self.cv_SYSTEM.console.get_console, timeout=20)
time.sleep(10)
if raw_pty is not None:
raw_pty.sendline("uname -r")
break
raw_pty.sendline("reboot")
raw_pty.expect("login:", timeout=600)
raw_pty.close()
Expand Down Expand Up @@ -187,3 +191,24 @@ def is_url(path):
finally:
if self.console_thread.isAlive():
self.console_thread.console_terminate()

def wait_for(self, func, timeout, first=0.0, step=1.0, text=None, args=None, kwargs=None):
args = args or []
kwargs = kwargs or {}

start_time = time.monotonic()
end_time = start_time + timeout

time.sleep(first)

while time.monotonic() < end_time:
if text:
LOG.debug("%s (%.9f secs)", text, (time.monotonic() - start_time))

output = func(*args, **kwargs)
if output:
return output

time.sleep(step)

return None

0 comments on commit e2505f2

Please sign in to comment.