From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: Re: [PATCH v2] testsuite: cleanup qemu machines left running
Date: Thu, 29 Aug 2024 08:53:33 +0300 [thread overview]
Message-ID: <240adbc842d8c0d32fecab15c7c3c31b3cfc61fa.camel@ilbers.de> (raw)
In-Reply-To: <20240826051741.624-1-ubely@ilbers.de>
On Mon, 2024-08-26 at 08:15 +0300, Uladzimir Bely wrote:
> Parameter "keep=True" in `vm_start` function allows to share the same
> qemu process between different tests.
>
> In case the machine is forgotten to be closed by the last test or in
> case avocado skips some tests (due to internal error or other reason)
> such qemu processes stay running after the testsuite completed.
>
> This change allows to terminate these processes.
>
> Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
> ---
> scripts/ci_build.sh | 9 ++++++++-
> testsuite/cleanup.py | 26 ++++++++++++++++++++++++++
> 2 files changed, 34 insertions(+), 1 deletion(-)
> create mode 100755 testsuite/cleanup.py
>
> Changes since v1:
> - Preserve avocado return code on exiting ci_build.sh.
>
> diff --git a/scripts/ci_build.sh b/scripts/ci_build.sh
> index 0aa2403d..338557ad 100755
> --- a/scripts/ci_build.sh
> +++ b/scripts/ci_build.sh
> @@ -142,9 +142,16 @@ logs_dir = $(realpath "${BASE_DIR}")/job-results
> EOF
> export VIRTUAL_ENV="./"
>
> +ret=0
> +
> # the real stuff starts here, trace commands from now on
> set -x
>
> avocado ${VERBOSE} run "${TESTSUITE_DIR}/citest.py" \
> -t "${TAGS}" --max-parallel-tasks=1 --disable-sysinfo \
> - ${SSTATE} ${TIMEOUT}
> + ${SSTATE} ${TIMEOUT} \
> + || ret=$?
> +
> +python3 ${TESTSUITE_DIR}/cleanup.py
> +
> +exit ${ret}
> diff --git a/testsuite/cleanup.py b/testsuite/cleanup.py
> new file mode 100755
> index 00000000..c81397d2
> --- /dev/null
> +++ b/testsuite/cleanup.py
> @@ -0,0 +1,26 @@
> +#!/usr/bin/env python3
> +
> +import os
> +import pickle
> +import signal
> +
> +build_dir = os.path.join(os.path.dirname(__file__), '..', 'build')
> +
> +vm_dict_file = f"{build_dir}/vm_dict_file"
> +vm_dict = {}
> +
> +if os.path.isfile(vm_dict_file):
> + with open(vm_dict_file, 'rb') as f:
> + data = f.read()
> + if data:
> + vm_dict = pickle.loads(data)
> +
> +for vm in vm_dict:
> + pid = vm_dict[vm][0]
> + name = vm_dict[vm][1][0]
> + print(f"Killing {name} process with pid {pid}", end ="... ")
> + try:
> + os.kill(pid, signal.SIGKILL)
> + print("OK")
> + except ProcessLookupError:
> + print("Not found")
> --
> 2.44.2
>
Applied to next.
--
Best regards,
Uladzimir.
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/isar-users/240adbc842d8c0d32fecab15c7c3c31b3cfc61fa.camel%40ilbers.de.
prev parent reply other threads:[~2024-08-29 5:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 5:15 Uladzimir Bely
2024-08-29 5:53 ` Uladzimir Bely [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=240adbc842d8c0d32fecab15c7c3c31b3cfc61fa.camel@ilbers.de \
--to=ubely@ilbers.de \
--cc=isar-users@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox