python/machine: Change default timeout to 30 seconds

3 seconds is too short for some tests running inside busy VMs. Build it out to
a rather generous 30 seconds to find out conclusively if there are more severe
problems in the merge/CI tests.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Message-id: 20200720160252.104139-2-jsnow@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
John Snow 2020-07-20 12:02:52 -04:00 committed by Peter Maydell
parent e68808a797
commit 8226a4b88b

View file

@ -394,15 +394,15 @@ class QEMUMachine:
self._popen.kill() self._popen.kill()
self._popen.wait(timeout=60) self._popen.wait(timeout=60)
def _soft_shutdown(self, has_quit: bool = False, def _soft_shutdown(self, timeout: Optional[int],
timeout: Optional[int] = 3) -> None: has_quit: bool = False) -> None:
""" """
Perform early cleanup, attempt to gracefully shut down the VM, and wait Perform early cleanup, attempt to gracefully shut down the VM, and wait
for it to terminate. for it to terminate.
:param timeout: Timeout in seconds for graceful shutdown.
A value of None is an infinite wait.
:param has_quit: When True, don't attempt to issue 'quit' QMP command :param has_quit: When True, don't attempt to issue 'quit' QMP command
:param timeout: Optional timeout in seconds for graceful shutdown.
Default 3 seconds, A value of None is an infinite wait.
:raise ConnectionReset: On QMP communication errors :raise ConnectionReset: On QMP communication errors
:raise subprocess.TimeoutExpired: When timeout is exceeded waiting for :raise subprocess.TimeoutExpired: When timeout is exceeded waiting for
@ -418,14 +418,14 @@ class QEMUMachine:
# May raise subprocess.TimeoutExpired # May raise subprocess.TimeoutExpired
self._popen.wait(timeout=timeout) self._popen.wait(timeout=timeout)
def _do_shutdown(self, has_quit: bool = False, def _do_shutdown(self, timeout: Optional[int],
timeout: Optional[int] = 3) -> None: has_quit: bool = False) -> None:
""" """
Attempt to shutdown the VM gracefully; fallback to a hard shutdown. Attempt to shutdown the VM gracefully; fallback to a hard shutdown.
:param timeout: Timeout in seconds for graceful shutdown.
A value of None is an infinite wait.
:param has_quit: When True, don't attempt to issue 'quit' QMP command :param has_quit: When True, don't attempt to issue 'quit' QMP command
:param timeout: Optional timeout in seconds for graceful shutdown.
Default 3 seconds, A value of None is an infinite wait.
:raise AbnormalShutdown: When the VM could not be shut down gracefully. :raise AbnormalShutdown: When the VM could not be shut down gracefully.
The inner exception will likely be ConnectionReset or The inner exception will likely be ConnectionReset or
@ -433,7 +433,7 @@ class QEMUMachine:
may result in its own exceptions, likely subprocess.TimeoutExpired. may result in its own exceptions, likely subprocess.TimeoutExpired.
""" """
try: try:
self._soft_shutdown(has_quit, timeout) self._soft_shutdown(timeout, has_quit)
except Exception as exc: except Exception as exc:
self._hard_shutdown() self._hard_shutdown()
raise AbnormalShutdown("Could not perform graceful shutdown") \ raise AbnormalShutdown("Could not perform graceful shutdown") \
@ -441,7 +441,7 @@ class QEMUMachine:
def shutdown(self, has_quit: bool = False, def shutdown(self, has_quit: bool = False,
hard: bool = False, hard: bool = False,
timeout: Optional[int] = 3) -> None: timeout: Optional[int] = 30) -> None:
""" """
Terminate the VM (gracefully if possible) and perform cleanup. Terminate the VM (gracefully if possible) and perform cleanup.
Cleanup will always be performed. Cleanup will always be performed.
@ -453,7 +453,7 @@ class QEMUMachine:
:param hard: When true, do not attempt graceful shutdown, and :param hard: When true, do not attempt graceful shutdown, and
suppress the SIGKILL warning log message. suppress the SIGKILL warning log message.
:param timeout: Optional timeout in seconds for graceful shutdown. :param timeout: Optional timeout in seconds for graceful shutdown.
Default 3 seconds, A value of None is an infinite wait. Default 30 seconds, A `None` value is an infinite wait.
""" """
if not self._launched: if not self._launched:
return return
@ -463,7 +463,7 @@ class QEMUMachine:
self._user_killed = True self._user_killed = True
self._hard_shutdown() self._hard_shutdown()
else: else:
self._do_shutdown(has_quit, timeout=timeout) self._do_shutdown(timeout, has_quit)
finally: finally:
self._post_shutdown() self._post_shutdown()
@ -473,12 +473,12 @@ class QEMUMachine:
""" """
self.shutdown(hard=True) self.shutdown(hard=True)
def wait(self, timeout: Optional[int] = 3) -> None: def wait(self, timeout: Optional[int] = 30) -> None:
""" """
Wait for the VM to power off and perform post-shutdown cleanup. Wait for the VM to power off and perform post-shutdown cleanup.
:param timeout: Optional timeout in seconds. :param timeout: Optional timeout in seconds. Default 30 seconds.
Default 3 seconds, A value of None is an infinite wait. A value of `None` is an infinite wait.
""" """
self.shutdown(has_quit=True, timeout=timeout) self.shutdown(has_quit=True, timeout=timeout)