[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: |
Alex Bennée |
Subject: |
Re: [PATCH 3/8] tests/vm: change wait_ssh to optionally wait for root. |
Date: |
Mon, 27 Jan 2020 11:06:04 +0000 |
User-agent: |
mu4e 1.3.7; emacs 27.0.60 |
Robert Foley <address@hidden> 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 <address@hidden>
> Reviewed-by: Peter Puhov <address@hidden>
> ---
> 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
- [PATCH 0/8] tests/vm: Add support for aarch64 VMs, Robert Foley, 2020/01/24
- [PATCH 3/8] tests/vm: change wait_ssh to optionally wait for root., Robert Foley, 2020/01/24
- Re: [PATCH 3/8] tests/vm: change wait_ssh to optionally wait for root.,
Alex Bennée <=
- [PATCH 4/8] tests/vm: Add configuration to basevm.py, Robert Foley, 2020/01/24
- [PATCH 5/8] tests/vm: Added configuration file support, Robert Foley, 2020/01/24
- [PATCH 6/8] tests/vm: add --boot-console switch, Robert Foley, 2020/01/24