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

Enable /plans/provision/virtual for pull requests #2558

Merged
merged 2 commits into from
Jan 31, 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
17 changes: 17 additions & 0 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ jobs:
- fedora-all
- epel-9

# Test pull requests (provision)
- job: tests
identifier: provision
trigger: pull_request
manual_trigger: true
use_internal_tf: True
targets:
- fedora-latest-stable
tf_extra_params:
test:
tmt:
name: /plans/provision/virtual
environments:
- tmt:
context:
how: provision

# Test internal plugins
- job: tests
trigger: pull_request
Expand Down
61 changes: 56 additions & 5 deletions docs/contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ Run selected tests or plans in verbose mode:
tmt run --verbose plan --name basic
tmt run -v test -n smoke


Full Test
------------------------------------------------------------------

.. warning::

This full test approach is being obsoleted.
See the :ref:`provision-methods` section for details.

Build the rpms and execute the whole test coverage, including
tests which need the full virtualization support:

Expand Down Expand Up @@ -162,6 +171,10 @@ Similar as above but run only tests which don't run for merge requests:
cd tests/full
make test-complement


Unit Tests
------------------------------------------------------------------

To run unit tests in hatch environment using pytest and generate coverage report:

.. code-block:: shell
Expand Down Expand Up @@ -197,12 +210,50 @@ versions. For example:
fixtures, see https://docs.pytest.org/en/7.1.x/how-to/unittest.html for
details.

.. note::
.. _provision-methods:

Provision Methods
------------------------------------------------------------------

Tests which exercise various provision methods should use the
``PROVISION_METHODS`` environment variable to select which
provision methods they can utilize during their execution. This
variable is likely to have ``local`` set as the default value to
execute directly on the test runner as the default scenario.

The following tags can be used to enable given test under the
respective provision method plan:

provision-artemis
For tests checking the :ref:`/spec/plans/provision/artemis`
plugin functionality.

provision-beaker
For tests checking the :ref:`/spec/plans/provision/beaker`
plugin functionality using the ``mrack`` plugin.

provision-connect
For tests checking the :ref:`/spec/plans/provision/connect`
plugin functionality.

provision-container
For tests checking the :ref:`/spec/plans/provision/container`
provision method using the ``podman`` plugin.

provision-virtual
For tests checking the :ref:`/spec/plans/provision/virtual`
provision method using the ``testcloud`` plugin.

provision-ssh
Tests which are not tied to a specific provision method but
should be executed for all provision methods which are using
``ssh`` to connect to guests.

provision-only
Used to mark tests which are suitable to be run only under
specific provision methods. These will be excluded from
regular plans.

Tests which try various provision methods should use ``PROVISION_METHODS``
environment variable to select which provision methods they can utilize
during their execution. This variable is likely to have default ``container``
or ``local`` and use ``adjust`` rule for ``how=full`` to add ``virtual`` method.

Docs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
18 changes: 0 additions & 18 deletions plans/features/main.fmf
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
prepare+:
# Install jq and yq for cleaner tests
- how: install
package:
- jq
- python3-pip

- how: shell
script:
# Try to install into .local first, if that fails, try without --user.
# In the sane world, tmt would be running in a virtualenv, and we'd
# install yq there. Otherwise, we'd change system packages, but we'd
# have to run as root to do that, and who's running tmt test suite
# as root?
#
- pip3 install --user yq || pip3 install yq
- yq --help

adjust+:
- when: distro == centos-stream-8 and trigger == commit
environment+:
Expand Down
2 changes: 1 addition & 1 deletion plans/features/steps.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description:
individual steps.
discover:
how: fmf
filter: "tier: 3"
filter: "tier: 3 & tag:-provision-only"

/discover:
discover+:
Expand Down
18 changes: 18 additions & 0 deletions plans/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
provision:
how: local

prepare+:
# Install jq and yq for cleaner tests
- how: install
package:
- jq
- python3-pip

- how: shell
script:
# Try to install into .local first, if that fails, try without --user.
# In the sane world, tmt would be running in a virtualenv, and we'd
# install yq there. Otherwise, we'd change system packages, but we'd
# have to run as root to do that, and who's running tmt test suite
# as root?
#
- pip3 install --user yq || pip3 install yq
- yq --help

# Use the internal executor
execute:
how: tmt
Expand Down
50 changes: 44 additions & 6 deletions plans/provision/virtual.fmf
Original file line number Diff line number Diff line change
@@ -1,9 +1,47 @@
summary: Virtual machine via testcloud

description: |
Verify functionality of the virtual provision plugin. Run
tests which exercise various features of the testcloud plugin
even if not directly related to the provision implementation.

The plan takes care of fetching the image to speed up the
execution. Each test should set the `provision-virtual` tag to
get picked by the plan, consume the `PROVISION_METHODS`
variable and use `provision --how virtual` on their own.

discover:
how: fmf
filter: 'tag:virtual & tier:1 | tag:provision-virtual-only'
provision:
how: virtual
# image: fedora
# memory: 2048
# disk: 10
filter: 'tag:provision-virtual'

prepare+:
- name: required-packages
how: install
package: guestfs-tools

- name: start-libvirtd
script: |
sudo systemctl start libvirtd
sudo systemctl status libvirtd

- name: prepare-image
summary: Fetch the image, refresh dnf cache, install beakerlib
script: |
tmt run --remove plan --default provision --how virtual finish
for image in /var/tmp/tmt/testcloud/images/*qcow2; do
virt-customize --add $image --run-command 'dnf --refresh install -y beakerlib'
done

environment:
PROVISION_METHODS: virtual

adjust+:
- enabled: true
when: how == provision

- provision:
hardware:
virtualization:
is-supported: true
memory: ">= 4 GB"
when: trigger == commit
6 changes: 1 addition & 5 deletions tests/core/escaping/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ description:
test: ./test.sh
framework: beakerlib
tag-: [container, virtual]
tag+: [provision-virtual]

environment:
PROVISION_METHODS: local container
adjust:
psss marked this conversation as resolved.
Show resolved Hide resolved
- when: how == full
environment:
PROVISION_METHODS: container virtual local
tag+: [additional_coverage]
6 changes: 1 addition & 5 deletions tests/core/spaces/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ description:
test: ./test.sh
framework: beakerlib
tag-: [container, virtual]
tag+: [provision-virtual]

environment:
PROVISION_METHODS: local container
adjust:
- when: how == full
environment:
PROVISION_METHODS: container virtual local
tag+: [additional_coverage]
14 changes: 0 additions & 14 deletions tests/discover/filtering.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,6 @@ rlJournalStart
rlAssertGrep "path:" output
rlPhaseEnd

# If plan or test weren't explicitly specified then fmf-ids for all tests
# in all plans should be shown
rlPhaseStartTest "fmf-id (w/o url): plans were executed if plan/test -n=."
ids_amount=$(tmt run -r discover -h fmf --fmf-id finish 2>&1 >/dev/null |
grep "name:" |
wc -l)
tests_amount=$(tmt run -r discover -h fmf finish 2>&1 >/dev/null |
grep "summary:" |
awk '{print $2}' |
awk '{s+=$1} END {print s}')
rlAssertEquals "Check that number of fmf-ids equals to tests number" \
"$ids_amount" "$tests_amount"
rlPhaseEnd

# Checking the case when fmf_root = git_root
rlPhaseStartTest "fmf-id (w/o url): path doesn't shown up"
path="$(git rev-parse --show-toplevel)"
Expand Down
4 changes: 2 additions & 2 deletions tests/discover/libraries/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ require+:
- tmt+provision-container
- tmt+provision-virtual

adjust:
enabled: True
adjust+:
- enabled: True
when: how == full
because: this can be run only with a full virtualization
tag+: [additional_coverage]
2 changes: 1 addition & 1 deletion tests/discover/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tier: 3
summary: Get tests from the source tarball from dist-git lookaside
test: ./distgit.sh
enabled: false
adjust:
adjust+:
- enabled: true
when: how == full or trigger == commit
tag+: [additional_coverage]
Expand Down
9 changes: 1 addition & 8 deletions tests/execute/duration/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,4 @@ summary: Verify that the test duration is correctly handled
environment:
PROVISION_METHODS: "local container"
duration: 20m

adjust:
when: how == full
environment:
PROVISION_METHODS: "local container virtual"
duration: 30m
because: with full virtualization more methods can be tested
tag+: [additional_coverage]
tag+: [provision-virtual]
9 changes: 2 additions & 7 deletions tests/execute/nonroot/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ summary: Scripts used in execute are pushed via sudo
tag:
- additional_coverage
- virtual
- provision-virtual
- provision-only
require:
- tmt
- tmt+provision-virtual
tier: "3"

enabled: false
adjust:
- when: how == full
enabled: true
because: virtual provision needs full virtualization
14 changes: 5 additions & 9 deletions tests/execute/reboot/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ tier: 4
/out-of-session:
summary: Verify that reboot induced from outside of test session works
test: ./out-of-session.sh
tag+: [provision-virtual]

environment+:
PROVISION_METHODS: container

adjust+:
- when: how==full
environment+:
PROVISION_METHODS: container virtual

# Disabled until the testing environment 'hardware specification' can be set.
# https://tmt.readthedocs.io/en/stable/spec/plans.html#hardware
/efi:
Expand All @@ -35,8 +31,8 @@ tier: 4
test: ./shorten-timeout.sh
enabled: false

adjust:
enabled: true
adjust+:
- enabled: true
when: how == full
because: this can be run only with full virtualization
tag+: [additional_coverage]
Expand All @@ -47,8 +43,8 @@ tier: 4
test: ./reuse.sh
enabled: false

adjust:
enabled: true
adjust+:
- enabled: true
when: how == full
because: this can be run only with full virtualization
tag+: [additional_coverage]
12 changes: 4 additions & 8 deletions tests/execute/rsync/main.fmf
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
summary: Correctly handle rsync removed during test
enabled: false

adjust:
enabled: true
duration: 10m
when: how == full
because: this can be run only with a full virtualization
tag+: [additional_coverage]
duration: 10m
tag:
- provision-virtual
- provision-only
7 changes: 2 additions & 5 deletions tests/execute/tty/main.fmf
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
summary: Verify TTY handling in test environment
tag+: [provision-virtual]
duration: 10m

environment:
PROVISION_METHODS: local container
adjust:
- when: how == full
environment:
PROVISION_METHODS: local container virtual
tag+: [additional_coverage]
8 changes: 4 additions & 4 deletions tests/execute/upgrade/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ tier: 4
duration: 1h
# requires nested virtualization (runs in VM)
enabled: false
adjust:
- enabled: true
when: how == full
tag+: [additional_coverage]
adjust+:
- enabled: true
when: how == full
tag+: [additional_coverage]

/simple:
summary: Run a single task from upgrades repo
Expand Down
Loading
Loading