qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/8] tests/vm: change wait_ssh to optionally wait for root.


From: Robert Foley
Subject: Re: [PATCH 3/8] tests/vm: change wait_ssh to optionally wait for root.
Date: Mon, 27 Jan 2020 07:59:42 -0500

On Mon, 27 Jan 2020 at 06:06, Alex Bennée <address@hidden> wrote:
> > 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...
We care about both the root and guest users.  See below.
> >  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?
We want to make sure the root user is up in
addition to the normal/guest user.  We're trying to add on the root user
since the issue we saw is that the guest user was up, (wait_ssh() completed),
but then when the root user tries to do something we get an error,
since root is not ready yet.

> > +                    guest_up = True
> > +                    break
> > +            elif self.ssh("exit 0") == 0:
>
> Is this simpler?
Certainly simpler.  :)
And simpler seems like the right call here.  But we'll need to call
into wait_ssh() twice,
once with the wait_root option and once without.  But I think this is better
since it makes the code on the caller side more explicit and clear in
that we will
explicitly wait for the guest user and then wait for the root user.

Thanks,
-Rob Foley
>     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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]