Robert Foley <robert.fo...@linaro.org> writes:
> Allow wait_ssh to wait for root user to be ready. > This solves the issue where we perform a wait_ssh() > successfully, but the root user is not yet ready > to be logged in. So in the case it's the root user we care about... > Signed-off-by: Robert Foley <robert.fo...@linaro.org> > Reviewed-by: Peter Puhov <peter.pu...@linaro.org> > --- > tests/vm/basevm.py | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py > index 86908f58ec..3b4403ddcb 100755 > --- a/tests/vm/basevm.py > +++ b/tests/vm/basevm.py > @@ -310,12 +310,17 @@ class BaseVM(object): > def print_step(self, text): > sys.stderr.write("### %s ...\n" % text) > > - def wait_ssh(self, seconds=600): > + def wait_ssh(self, wait_root=False, seconds=600): > starttime = datetime.datetime.now() > endtime = starttime + datetime.timedelta(seconds=seconds) > guest_up = False > while datetime.datetime.now() < endtime: > - if self.ssh("exit 0") == 0: > + if wait_root: > + if self.ssh("exit 0") == 0 and\ > + self.ssh_root("exit 0") == 0: ...why do we need to test both here? > + guest_up = True > + break > + elif self.ssh("exit 0") == 0: Is this simpler? def wait_ssh(self, wait_root=False, seconds=600): starttime = datetime.datetime.now() endtime = starttime + datetime.timedelta(seconds=seconds) guest_up = False while datetime.datetime.now() < endtime: if wait_root and self.ssh_root("exit 0") == 0: guest_up = True break elif self.ssh("exit 0") == 0: guest_up = True break seconds = (endtime - datetime.datetime.now()).total_seconds() logging.debug("%ds before timeout", seconds) time.sleep(1) if not guest_up: raise Exception("Timeout while waiting for guest ssh") > guest_up = True > break > seconds = (endtime - datetime.datetime.now()).total_seconds() -- Alex Bennée