Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the default test pidfile directory to /var/tmp #2432

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,11 @@ TMT_TEST_PIDFILE, TMT_TEST_PIDFILE_LOCK
making any changes to the pid file.

TMT_TEST_PIDFILE_ROOT
By default, the test pidfile file is stored in the ``$TMT_WORKDIR_ROOT``
By default, the test pidfile file is stored in ``/var/tmp``
directory. If specified, the directory in this variable would be
used instead.
used instead. The directory permissions should follow the pattern
of temporary directory permissions, e.g. ``chmod 1777``, to
allow access to users with all privilege levels.

Plugin Variables
----------------
Expand Down
2 changes: 1 addition & 1 deletion tests/execute/reboot/out-of-session.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ rlJournalStart
# and use it to issue a `tmt-reboot` from outside the direct process tree of the test.
set -x

tmt_reboot_command="export TMT_TEST_PIDFILE=/var/tmp/tmt/tmt-test.pid; export TMT_TEST_PIDFILE_LOCK=/var/tmp/tmt/tmt-test.pid.lock; export TMT_DEBUG=1; tmt-reboot"
tmt_reboot_command="export TMT_TEST_PIDFILE=/var/tmp/tmt-test.pid; export TMT_TEST_PIDFILE_LOCK=/var/tmp/tmt-test.pid.lock; export TMT_DEBUG=1; tmt-reboot"

if [ "$method" = "container" ]; then
podman_exec="$(sed -nr 's/\s*Run command: (podman exec .*) \/bin\/bash.*cd.*/\1/p' tmt.output)"
Expand Down
7 changes: 5 additions & 2 deletions tmt/steps/execute/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,22 @@
TEST_PIDFILE_FILENAME = 'tmt-test.pid'
TEST_PIDFILE_LOCK_FILENAME = f'{TEST_PIDFILE_FILENAME}.lock'

#: The default directory for storing test pid file.
TEST_PIDFILE_ROOT = Path('/var/tmp')


def effective_pidfile_root() -> Path:
"""
Find out what the actual pidfile directory is.

If ``TMT_TEST_PIDFILE_ROOT`` variable is set, it is used. Otherwise,
the effective workdir root is picked.
:py:const:`TEST_PIDFILE_ROOT` is picked.
"""

if 'TMT_TEST_PIDFILE_ROOT' in os.environ:
return Path(os.environ['TMT_TEST_PIDFILE_ROOT'])

return tmt.utils.effective_workdir_root()
return TEST_PIDFILE_ROOT


TEST_WRAPPER_FILENAME = 'tmt-test-wrapper.sh'
Expand Down
2 changes: 1 addition & 1 deletion tmt/steps/execute/scripts/tmt-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[ -n "$TMT_DEBUG" ] && set -x

TMT_TEST_PIDFILE_LOCK="${TMT_TEST_PIDFILE_LOCK:-/var/tmp/tmt/tmt-test.pid}"
TMT_TEST_PIDFILE_LOCK="${TMT_TEST_PIDFILE_LOCK:-/var/tmp/tmt-test.pid}"

PATH=/sbin:/usr/sbin:$PATH

Expand Down
2 changes: 1 addition & 1 deletion tmt/steps/execute/scripts/tmt-reboot-core
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[ -n "$TMT_DEBUG" ] && set -x

TMT_TEST_PIDFILE="${TMT_TEST_PIDFILE:-/var/tmp/tmt/tmt-test.pid}"
TMT_TEST_PIDFILE="${TMT_TEST_PIDFILE:-/var/tmp/tmt-test.pid}"

if [ ! -e "$TMT_TEST_PIDFILE" ]; then
echo "There is no running test to signal the reboot to!"
Expand Down
Loading