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

Support Fedora Image Mode #3229

Merged
merged 17 commits into from
Oct 21, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
exclude-path: |
tests/**
examples/**/test.sh
tmt/steps/execute/scripts/*.sh.j2
tmt/templates/**
token: ${{ secrets.GITHUB_TOKEN }}

Expand Down
11 changes: 11 additions & 0 deletions docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,17 @@ TMT_REBOOT_TIMEOUT
How many seconds to wait for a connection to succeed after
guest reboot. By default, it is 10 minutes.

TMT_SCRIPTS_DIR
Destination directory for storing ``tmt`` scripts on the guest.
By default ``/usr/local/bin`` is used, except for guests using
``rpm-ostree``, where ``/var/lib/tmt/scripts`` is used. See the
`tmt internal test executor`__ documentation for more details
on the scripts installed on the guest.

.. versionadded:: 1.38

__ https://tmt.readthedocs.io/en/stable/spec/plans.html#tmt

TMT_SSH_*
Every environment variable in this format would be treated as an SSH
option, and passed to the ``-o`` option of ``ssh`` command. See
Expand Down
9 changes: 9 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ A race condition in the
thus multihost tests using this provision method should now work
reliably without unexpected connection failures.

Support for RHEL-like operating systems in `Image Mode`__ has been
added. The destination directory of the scripts added by ``tmt``
on these operating systems is ``/var/lib/tmt/scripts``. For
all others the ``/usr/local/bin`` destination directory is used.
A new environment variable ``TMT_SCRIPTS_DIR`` is available
to override the default locations.

__ https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux/image-mode


tmt-1.37.0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
15 changes: 15 additions & 0 deletions spec/plans/execute.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,21 @@ description: |
For more information see the
:ref:`/stories/features/abort` feature documentation.

The scripts are hosted by default in the ``/usr/local/bin``
directory, except for guests using ``rpm-ostree``, where
``/var/lib/tmt/scripts`` is used. The directory can be forced
using the ``TMT_SCRIPTS_DIR`` environment variable.
Note that for guests using ``rpm-ostree``, the directory is added
to executable paths using the system-wide ``/etc/profile.d/tmt.sh``
profile script.

.. warning::

Please be aware that for guests using ``rpm-ostree``
the provided scripts will only be available in a shell that
loads the profile scripts. This is the default for
``bash``-like shells, but might not work for others.

example: |
execute:
how: tmt
Expand Down
2 changes: 1 addition & 1 deletion tests/execute/nonroot/data/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
/command_found:
test: command -v tmt-file-submit
/full_path_exists:
test: test -e /usr/local/bin/tmt-file-submit
test: test -e /var/lib/tmt/scripts/tmt-file-submit
/command_works:
test: tmt-file-submit XXXX main.fmf
1 change: 1 addition & 0 deletions tests/execute/tmt-scripts/data/.fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
6 changes: 6 additions & 0 deletions tests/execute/tmt-scripts/data/plan.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
provision:
how: container
image: $IMAGE
execute:
how: tmt
script: ls $PATHS
146 changes: 146 additions & 0 deletions tests/execute/tmt-scripts/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
summary: Verify correct location of tmt scripts

/fedora:
environment:
IMAGE: registry.fedoraproject.org/fedora:rawhide
FOUND: |
/usr/local/bin/rhts-abort
/usr/local/bin/rhts-reboot
/usr/local/bin/rhts-report-result
/usr/local/bin/rhts-submit-log
/usr/local/bin/rhts_submit_log
/usr/local/bin/rstrnt-abort
/usr/local/bin/rstrnt-reboot
/usr/local/bin/rstrnt-report-log
/usr/local/bin/rstrnt-report-result
/usr/local/bin/tmt-abort
/usr/local/bin/tmt-file-submit
/usr/local/bin/tmt-reboot
/usr/local/bin/tmt-reboot-core
/usr/local/bin/tmt-report-result
NOT_FOUND:
/etc/profile.d/tmt.sh
/var/lib/tmt/scripts

/fedora-force:
environment:
IMAGE: registry.fedoraproject.org/fedora:rawhide
TMT_SCRIPTS_DIR: /usr/bin
FOUND: |
/usr/bin/rhts-abort
/usr/bin/rhts-reboot
/usr/bin/rhts-report-result
/usr/bin/rhts-submit-log
/usr/bin/rhts_submit_log
/usr/bin/rstrnt-abort
/usr/bin/rstrnt-reboot
/usr/bin/rstrnt-report-log
/usr/bin/rstrnt-report-result
/usr/bin/tmt-abort
/usr/bin/tmt-file-submit
/usr/bin/tmt-reboot
/usr/bin/tmt-reboot-core
/usr/bin/tmt-report-result
NOT_FOUND:
/etc/profile.d/tmt.sh
/usr/local/bin/rhts-abort
/usr/local/bin/rhts-reboot
/usr/local/bin/rhts-report-result
/usr/local/bin/rhts-submit-log
/usr/local/bin/rhts_submit_log
/usr/local/bin/rstrnt-abort
/usr/local/bin/rstrnt-reboot
/usr/local/bin/rstrnt-report-log
/usr/local/bin/rstrnt-report-result
/usr/local/bin/tmt-abort
/usr/local/bin/tmt-file-submit
/usr/local/bin/tmt-reboot
/usr/local/bin/tmt-reboot-core
/usr/local/bin/tmt-report-result
/var/lib/tmt/scripts

/fedora-bootc:
environment:
IMAGE: quay.io/fedora/fedora-bootc:rawhide
FOUND: |
/var/lib/tmt/scripts/rhts-abort
/var/lib/tmt/scripts/rhts-reboot
/var/lib/tmt/scripts/rhts-report-result
/var/lib/tmt/scripts/rhts-submit-log
/var/lib/tmt/scripts/rhts_submit_log
/var/lib/tmt/scripts/rstrnt-abort
/var/lib/tmt/scripts/rstrnt-reboot
/var/lib/tmt/scripts/rstrnt-report-log
/var/lib/tmt/scripts/rstrnt-report-result
/var/lib/tmt/scripts/tmt-abort
/var/lib/tmt/scripts/tmt-file-submit
/var/lib/tmt/scripts/tmt-reboot
/var/lib/tmt/scripts/tmt-reboot-core
/var/lib/tmt/scripts/tmt-report-result
/etc/profile.d/tmt.sh
NOT_FOUND: |
/usr/local/bin/rhts-abort
/usr/local/bin/rhts-reboot
/usr/local/bin/rhts-report-result
/usr/local/bin/rhts-submit-log
/usr/local/bin/rhts_submit_log
/usr/local/bin/rstrnt-abort
/usr/local/bin/rstrnt-reboot
/usr/local/bin/rstrnt-report-log
/usr/local/bin/rstrnt-report-result
/usr/local/bin/tmt-abort
/usr/local/bin/tmt-file-submit
/usr/local/bin/tmt-reboot
/usr/local/bin/tmt-reboot-core
/usr/local/bin/tmt-report-result


/fedora-bootc-force:
environment:
IMAGE: quay.io/fedora/fedora-bootc:rawhide
TMT_SCRIPTS_DIR: /var/tmp/tmt/bin
FOUND: |
/etc/profile.d/tmt.sh
/var/tmp/tmt/bin/rhts-abort
/var/tmp/tmt/bin/rhts-reboot
/var/tmp/tmt/bin/rhts-report-result
/var/tmp/tmt/bin/rhts-submit-log
/var/tmp/tmt/bin/rhts_submit_log
/var/tmp/tmt/bin/rstrnt-abort
/var/tmp/tmt/bin/rstrnt-reboot
/var/tmp/tmt/bin/rstrnt-report-log
/var/tmp/tmt/bin/rstrnt-report-result
/var/tmp/tmt/bin/tmt-abort
/var/tmp/tmt/bin/tmt-file-submit
/var/tmp/tmt/bin/tmt-reboot
/var/tmp/tmt/bin/tmt-reboot-core
/var/tmp/tmt/bin/tmt-report-result
NOT_FOUND: |
/usr/local/bin/rhts-abort
/usr/local/bin/rhts-reboot
/usr/local/bin/rhts-report-result
/usr/local/bin/rhts-submit-log
/usr/local/bin/rhts_submit_log
/usr/local/bin/rstrnt-abort
/usr/local/bin/rstrnt-reboot
/usr/local/bin/rstrnt-report-log
/usr/local/bin/rstrnt-report-result
/usr/local/bin/tmt-abort
/usr/local/bin/tmt-file-submit
/usr/local/bin/tmt-reboot
/usr/local/bin/tmt-reboot-core
/usr/local/bin/tmt-report-result
/var/lib/tmt/scripts/rhts-abort
/var/lib/tmt/scripts/rhts-reboot
/var/lib/tmt/scripts/rhts-report-result
/var/lib/tmt/scripts/rhts-submit-log
/var/lib/tmt/scripts/rhts_submit_log
/var/lib/tmt/scripts/rstrnt-abort
/var/lib/tmt/scripts/rstrnt-reboot
/var/lib/tmt/scripts/rstrnt-report-log
/var/lib/tmt/scripts/rstrnt-report-result
/var/lib/tmt/scripts/tmt-abort
/var/lib/tmt/scripts/tmt-file-submit
/var/lib/tmt/scripts/tmt-reboot
/var/lib/tmt/scripts/tmt-reboot-core
/var/lib/tmt/scripts/tmt-report-result
29 changes: 29 additions & 0 deletions tests/execute/tmt-scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
. /usr/share/beakerlib/beakerlib.sh || exit 1

rlJournalStart
rlPhaseStartSetup
rlRun "run=\$(mktemp -d)" 0 "Create run directory"
rlRun "pushd data"
rlPhaseEnd

rlPhaseStartTest
# List of paths to check, on a single line
PATHS=$(echo $FOUND $NOT_FOUND)

rlRun -s "tmt run -vvv -e IMAGE=$IMAGE -e \"PATHS='$PATHS'\" --id $run" 2 "Run the plan"

for FOUND_PATH in $FOUND; do
rlAssertGrep "out: $FOUND_PATH" $rlRun_LOG
done

for NOT_FOUND_PATH in $NOT_FOUND; do
rlAssertGrep "ls: cannot access '$NOT_FOUND_PATH': No such file or directory" $rlRun_LOG
done
rlPhaseEnd

rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -rf $run" 0 "Remove run directory"
rlPhaseEnd
rlJournalEnd
2 changes: 1 addition & 1 deletion tmt/frameworks/beakerlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_environment_variables(
return Environment({
'BEAKERLIB_DIR': EnvVarValue(invocation.path),
'BEAKERLIB_COMMAND_SUBMIT_LOG': EnvVarValue(
f'bash {tmt.steps.execute.TMT_FILE_SUBMIT_SCRIPT.path}')
f'bash {invocation.guest.scripts_path / tmt.steps.execute.TMT_FILE_SUBMIT_SCRIPT.source_filename}') # noqa: E501
})

@classmethod
Expand Down
Loading
Loading