Skip to content

Commit e2505f2

Browse files
committed
Patch helps to overcome login issue.
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]>
1 parent f9e4dc0 commit e2505f2

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

testcases/InstallUpstreamKernel.py

+27-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,12 @@ def is_url(path):
133133
self.prompt = self.cv_SYSTEM.util.build_prompt()
134134
self.console_thread.console_terminate()
135135
con.close()
136-
time.sleep(10)
137-
raw_pty = self.cv_SYSTEM.console.get_console()
136+
for i in range(5):
137+
raw_pty = self.wait_for(self.cv_SYSTEM.console.get_console, timeout=20)
138+
time.sleep(10)
139+
if raw_pty is not None:
140+
raw_pty.sendline("uname -r")
141+
break
138142
raw_pty.sendline("reboot")
139143
raw_pty.expect("login:", timeout=600)
140144
raw_pty.close()
@@ -187,3 +191,24 @@ def is_url(path):
187191
finally:
188192
if self.console_thread.isAlive():
189193
self.console_thread.console_terminate()
194+
195+
def wait_for(self, func, timeout, first=0.0, step=1.0, text=None, args=None, kwargs=None):
196+
args = args or []
197+
kwargs = kwargs or {}
198+
199+
start_time = time.monotonic()
200+
end_time = start_time + timeout
201+
202+
time.sleep(first)
203+
204+
while time.monotonic() < end_time:
205+
if text:
206+
LOG.debug("%s (%.9f secs)", text, (time.monotonic() - start_time))
207+
208+
output = func(*args, **kwargs)
209+
if output:
210+
return output
211+
212+
time.sleep(step)
213+
214+
return None

0 commit comments

Comments
 (0)