Skip to content

Commit

Permalink
[skip-ci] TMT: system tests
Browse files Browse the repository at this point in the history
This commit introduces TMT test jobs triggered via packit to run system
tests on testing-farm infrastructure. Tests are run for all active
Fedora and CentOS Stream environments for aarch64 and x86_64. The same
test plan will be reused by Fedora for bodhi, zuul and fedora-ci gating
tests. Packit will handle syncing of test plan and sources from upstream
to downstream.

Jobs will be selectively triggered for `main` v/s release branches based
on the `release` PR label. The GHA for labeling PRs has also been
updated in this commit.

Test jobs on the main branch will include builds from the
`rhcontainerbot/podman-next` copr while tests on release branches will
only include official distro packages.

Signed-off-by: Lokesh Mandvekar <[email protected]>
  • Loading branch information
lsm5 committed Dec 18, 2024
1 parent 2459d1b commit 52599bc
Show file tree
Hide file tree
Showing 11 changed files with 237 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ kind/api-change:
machine:
- changed-files:
- any-glob-to-any-file: pkg/machine/**
release:
- base-branch: [^v?(0|[1-9]\d*).(0|[1-9]\d*)$]
70 changes: 68 additions & 2 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@
downstream_package_name: podman
upstream_tag_template: v{version}

# These files get synced from upstream to downstream (Fedora / CentOS Stream) on every
# propose-downstream job. This is done so tests maintained upstream can be run
# downstream in Zuul CI and Bodhi.
# Ref: https://packit.dev/docs/configuration#files_to_sync
files_to_sync:
- src: rpm/gating.yaml
dest: gating.yaml
delete: true
- src: plans/
dest: plans/
delete: true
mkpath: true
- src: .fmf/
dest: .fmf/
delete: true
- .packit.yaml

packages:
podman-fedora:
pkg_tool: fedpkg
Expand All @@ -31,7 +48,7 @@ jobs:
failure_comment:
message: "Ephemeral COPR build failed. @containers/packit-build please check."
enable_net: true
targets:
targets: &fedora_copr_targets
- fedora-all-x86_64
- fedora-all-aarch64

Expand All @@ -53,7 +70,7 @@ jobs:
packages: [podman-centos]
notifications: *packit_build_failure_notification
enable_net: true
targets:
targets: &centos_copr_targets
- centos-stream-9-x86_64
- centos-stream-9-aarch64
- centos-stream-10-x86_64
Expand All @@ -71,6 +88,55 @@ jobs:
project: podman-next
enable_net: true

- job: tests
trigger: pull_request
packages: [podman-fedora]
targets: *fedora_copr_targets
require: &dev_tests
label:
absent:
- release
tf_extra_params:
environments:
- artifacts:
- type: repository-file
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/fedora-$releasever/rhcontainerbot-podman-next-fedora-$releasever.repo
identifier: "dev"

- job: tests
trigger: pull_request
packages: [podman-fedora]
targets: *fedora_copr_targets
require: &release_tests
label:
present:
- release
preserve_project: true
identifier: "release"

# FIXME: Enable centos stream tests after containers-common is fixed
# FIXME: centos stream 10 currently also lacks bats
# https://bugzilla.redhat.com/show_bug.cgi?id=2329315
- job: tests
trigger: ignore
packages: [podman-centos]
targets: *centos_copr_targets
require: *dev_tests
tf_extra_params:
environments:
- artifacts:
- type: repository-file
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/centos-stream-$releasever/rhcontainerbot-podman-next-centos-stream-$releasever.repo
identifier: "dev"

- job: tests
trigger: ignore
packages: [podman-centos]
targets: *centos_copr_targets
require: *release_tests
preserve_project: true
identifier: "release"

- job: tests
identifier: cockpit-revdeps
trigger: pull_request
Expand Down
26 changes: 26 additions & 0 deletions plans/podman.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
discover:
how: fmf
execute:
how: tmt
adjust:
when: "initiator == packit"
because: "We need to test with updated packages from rhcontainerbot/podman-net copr"
prepare+:
how: shell
script: sed -i -n '/^priority=/!p;$apriority=5' /etc/yum.repos.d/*:rhcontainerbot:podman-next.repo

/upstream:
summary: Run tests on upstream PRs
discover+:
filter: tag:upstream
adjust+:
enabled: false
when: revdeps == yes or initiator is not defined or initiator != packit

/downstream:
summary: Run tests on bodhi / errata and dist-git PRs
discover+:
filter: tag:downstream
adjust+:
enabled: false
when: initiator == packit
17 changes: 17 additions & 0 deletions rpm/gating.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- !Policy
product_versions:
- fedora-*
decision_contexts:
- bodhi_update_push_stable
- bodhi_update_push_testing
subject_type: koji_build
rules:
- !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional}

# recipients: jnovy, lsm5, santiago
--- !Policy
product_versions:
- rhel-*
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}
2 changes: 2 additions & 0 deletions rpm/podman.spec
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

%if %{defined fedora}
%define build_with_btrfs 1
# No machine stuff for rhel
%define machine 1
%endif

%if %{defined copr_username}
Expand Down
24 changes: 24 additions & 0 deletions test/tmt/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -exo pipefail

uname -r

loginctl enable-linger "$ROOTLESS_USER"

rm -rf /home/$ROOTLESS_USER/.local/share/containers

rpm -q \
aardvark-dns \
buildah \
conmon \
container-selinux \
containers-common \
crun \
netavark \
passt \
podman \
podman-tests \
skopeo \
slirp4netns \
systemd
48 changes: 48 additions & 0 deletions test/tmt/system.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
require:
- bats
- golang
- make
- podman
- podman-remote
- podman-tests
- slirp4netns

environment:
PODMAN: /usr/bin/podman
PODMAN_TESTING: /usr/bin/podman-testing
QUADLET: /usr/libexec/podman/quadlet
ROOTLESS_USER: "fedora"
adjust+:
environment+:
ROOTLESS_USER: "ec2-user"
when: distro == centos-stream

/local-root:
tag: [ downstream, upstream ]
summary: local rootful test
test: bash ./system.sh
duration: 60m

/local-rootless:
tag: [ downstream, upstream ]
summary: rootless test
test: bash ./system.sh rootless
duration: 60m

/remote-root:
tag: [ downstream, upstream ]
summary: remote rootful test
test: bash ./system.sh
duration: 60m
adjust+:
environment+:
PODMAN: /usr/bin/podman-remote

/remote-rootless:
tag: [ downstream, upstream ]
summary: remote rootless test
test: bash ./system.sh rootless
duration: 60m
adjust+:
environment+:
PODMAN: /usr/bin/podman-remote
14 changes: 14 additions & 0 deletions test/tmt/system.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

set -exo pipefail

. setup.sh

export test_cmd="whoami && cd /usr/share/podman/test/system && bats ."

if [[ -z $1 ]]; then
eval $test_cmd
elif [[ $1 == "rootless" ]]; then
su --whitelist-environment=$(cat ./tmt-envvars | tr '\n' ',') - "$ROOTLESS_USER" -c "eval $test_cmd"
fi
exit 0
19 changes: 19 additions & 0 deletions test/tmt/tmt-envvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
TMT_TREE
TMT_PLAN_DATA
TMT_VERSION
TMT_TEST_NAME
TMT_TEST_DATA
TMT_TEST_SERIAL_NUMBER
TMT_TEST_ITERATION_ID
TMT_TEST_METADATA
TMT_SOURCE_DIR
TMT_REBOOT_COUNT
TMT_TEST_RESTART_COUNT
TMT_TOPOLOGY_BASH
TMT_TOPOLOGY_YAML
TMT_TEST_PIDFILE
TMT_TEST_PIDFILE_LOCK
TMT_TEST_PIDFILE_ROOT
PODMAN_TESTING
QUADLET
ROOTLESS_USER
9 changes: 9 additions & 0 deletions test/tmt/toolbox-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -exo pipefail

. setup.sh

rpm -q containers-common-extra podman toolbox

su --whitelist-environment=$(cat ./tmt-envvars | tr '\n' ',') - "$ROOTLESS_USER" -c "whoami && cd /usr/share/toolbox/test/system && bats ."
8 changes: 8 additions & 0 deletions test/tmt/toolbox.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require:
- toolbox-tests

/rootless:
tag: [ downstream ]
summary: rootless test
test: bash ./toolbox-test.sh'
duration: 60m

0 comments on commit 52599bc

Please sign in to comment.