From ff43feaff18a954956e5f20edf4284f7848ab37c Mon Sep 17 00:00:00 2001 From: Lokesh Mandvekar Date: Wed, 25 Dec 2024 15:45:41 +0530 Subject: [PATCH] [skip-ci] Packit/TMT: Run system tests This commit enables system tests via TMT. Signed-off-by: Lokesh Mandvekar --- .fmf/version | 1 + .packit.yaml | 75 +++++++++++++++++++++++++++++++++++++++-- plans/main.fmf | 40 ++++++++++++++++++++++ rpm/gating.yaml | 16 +++++++++ rpm/skopeo.spec | 7 +++- systemtest/tmt/main.fmf | 10 ++++++ systemtest/tmt/test.sh | 16 +++++++++ 7 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 .fmf/version create mode 100644 plans/main.fmf create mode 100644 rpm/gating.yaml create mode 100644 systemtest/tmt/main.fmf create mode 100644 systemtest/tmt/test.sh diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.packit.yaml b/.packit.yaml index 8b284aa8df..16f6f42830 100644 --- a/.packit.yaml +++ b/.packit.yaml @@ -9,6 +9,27 @@ downstream_package_name: skopeo 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: systemtest/tmt/ + dest: test/tmt/ + delete: true + mkpath: true + - src: .fmf/ + dest: .fmf/ + delete: true + - .packit.yaml + packages: skopeo-fedora: pkg_tool: fedpkg @@ -29,7 +50,7 @@ jobs: notifications: &copr_build_failure_notification failure_comment: message: "Ephemeral COPR build failed. @containers/packit-build please check." - targets: + targets: &fedora_copr_targets - fedora-all-x86_64 - fedora-all-aarch64 enable_net: true @@ -51,7 +72,7 @@ jobs: trigger: pull_request packages: [skopeo-centos] notifications: *copr_build_failure_notification - targets: + targets: ¢os_copr_targets - centos-stream-9-x86_64 - centos-stream-9-aarch64 - centos-stream-10-x86_64 @@ -70,6 +91,56 @@ jobs: project: podman-next enable_net: true + # Tests on Fedora + - job: tests + trigger: pull_request + packages: [skopeo-fedora] + notifications: &test_failure_notification + failure_comment: + message: "Tests failed. @containers/packit-build please check." + 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 + + - job: tests + trigger: pull_request + packages: [skopeo-fedora] + targets: *fedora_copr_targets + require: &release_tests + label: + present: + - release + preserve_project: true + identifier: "release" + + # Tests on CentOS Stream + - job: tests + trigger: pull_request + packages: [skopeo-centos] + notifications: *test_failure_notification + 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 + + # Tests on CentOS Stream + - job: tests + trigger: pull_request + packages: [skopeo-centos] + notifications: *test_failure_notification + targets: *centos_copr_targets + require: *release_tests + # Sync to Fedora - job: propose_downstream trigger: release diff --git a/plans/main.fmf b/plans/main.fmf new file mode 100644 index 0000000000..eb12823b64 --- /dev/null +++ b/plans/main.fmf @@ -0,0 +1,40 @@ +discover: + how: fmf +execute: + how: tmt +adjust: + - when: "initiator == packit" + because: "We need to test with updated packages from rhcontainerbot/podman-next copr" + prepare+: + how: shell + script: | + sed -i -n '/^priority=/!p;$apriority=1' /etc/yum.repos.d/*podman-next*.repo + dnf -y upgrade --allowerasing + # FIXME: Use epel10 once bats is available there + - when: distro == centos-stream-10 or distro == rhel-10 + because: "bats isn't yet available on epel10" + prepare+: + how: install + copr: rhcontainerbot/bats-el10 + package: bats + - when: distro == centos-stream or distro == rhel + because: "bats is present on EPEL on rhel9 / c9s" + prepare+: + how: feature + epel: enabled + +/upstream: + summary: Run tests on upstream PRs + discover+: + filter: tag:upstream + adjust+: + - enabled: false + when: 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 diff --git a/rpm/gating.yaml b/rpm/gating.yaml new file mode 100644 index 0000000000..c92e206d78 --- /dev/null +++ b/rpm/gating.yaml @@ -0,0 +1,16 @@ +--- !Policy +product_versions: + - fedora-* +decision_context: + - bodhi_update_push_stable + - bodhi_update_push_testing +subject_type: koji_build +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} + +--- !Policy +product_versions: + - rhel-* +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional} diff --git a/rpm/skopeo.spec b/rpm/skopeo.spec index 24f89899af..e8484c4e73 100644 --- a/rpm/skopeo.spec +++ b/rpm/skopeo.spec @@ -27,6 +27,7 @@ # Copr builds set a separate epoch for all environments %if %{defined fedora} %define conditional_epoch 1 +%define fakeroot 1 %else %define conditional_epoch 2 %endif @@ -81,8 +82,12 @@ registries without the need to pull them Summary: Tests for %{name} Requires: %{name} = %{epoch}:%{version}-%{release} -%if %{defined fedora} +%if %{defined bats_epel} Requires: bats +%else +Recommends: bats +%endif +%if %{defined fakeroot} Requires: fakeroot %endif Requires: gnupg diff --git a/systemtest/tmt/main.fmf b/systemtest/tmt/main.fmf new file mode 100644 index 0000000000..c937a94d06 --- /dev/null +++ b/systemtest/tmt/main.fmf @@ -0,0 +1,10 @@ +require: + - skopeo-tests + +environment: + SKOPEO_BINARY: /usr/bin/skopeo + +tag: [ upstream, downstream ] +summary: System test +test: bash ./test.sh +duration: 60m diff --git a/systemtest/tmt/test.sh b/systemtest/tmt/test.sh new file mode 100644 index 0000000000..bc3a1271b3 --- /dev/null +++ b/systemtest/tmt/test.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -exo pipefail + +uname -r + +rpm -q \ + conmon \ + container-selinux \ + containers-common \ + crun \ + podman \ + skopeo \ + skopeo-tests \ + +bats /usr/share/skopeo/test/system