Skip to content
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
43 changes: 29 additions & 14 deletions tests/prepare/artifact/lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,41 @@

# Setup distro test environment
#
# This function checks the distro, sets up the release version
# and image_name variables, and builds the container image.
# This function checks the distro, sets up the release version,
# image_name, and koji_tag variables, and builds the container image.
#
# Sets the following global variables:
# fedora_release - The Fedora release version (e.g., "43")
# release - The distro release version (e.g., "43" for Fedora, "10" for CentOS)
# image_name - The container image name (e.g., "fedora/43:latest")
# koji_tag - The koji tag for querying builds (e.g., "f43" for Fedora, "epel10" for CentOS)
#
# Usage: setup_distro_environment
#
# TODO: Add CentOS/RHEL support when needed
#
setup_distro_environment() {
if ! rlIsFedora; then
rlDie "Test requires Fedora"
if rlIsFedora; then
release=$(rlGetDistroRelease)
koji_tag="f${release}"
distro="fedora-${release}"
# TODO: Rawhide reports numeric release identifiers (e.g., "45") but versioned
# container targets (fedora/45/*) don't exist yet. Mapping fedora/45 to rawhide
# as a workaround until https://github.com/teemtee/tmt/pull/4775 is merged.
if grep -qi "rawhide" /etc/os-release; then
image_name="fedora/rawhide:latest"
else
image_name="fedora/${release}:latest"
fi
elif rlIsCentOS; then
release=$(rlGetDistroRelease)
image_name="centos/stream${release}/upstream:latest"
koji_tag="epel${release}"
distro="centos-stream-${release}"
else
rlDie "Test requires Fedora or CentOS"
fi

# TODO: Temporary hardcoded release - should be taken from function input
fedora_release=43
image_name="fedora/${fedora_release}:latest"
build_container_image "$image_name"
}

# Get koji build ID from package name (fetch latest for tag)
# Get koji build ID from package name (fetch latest for tag, with inheritance)
#
# Usage:
# get_koji_build_id "make" "f43"
Expand All @@ -44,14 +56,17 @@ setup_distro_environment() {
# in the KOJI_BUILD_ID global variable (not printed to stdout) to
# avoid capturing rlRun output when using command substitution.
#
# The --inherit flag is used to also search parent tags (e.g., epel10.3
# inherits from epel10), ensuring builds inherited from parent tags are found.
#
get_koji_build_id() {
local package="$1"
local tag="$2"
unset KOJI_BUILD_ID # Clear any previous value

# Get the latest tagged build for the package
# Get the latest tagged build for the package (including inherited tags)
# Output format: "make-4.4.1-10.fc42 f42 releng"
rlRun -s "koji list-tagged --latest $tag $package" 0 "Get the latest $package build"
rlRun -s "koji list-tagged --latest --inherit $tag $package" 0 "Get the latest $package build (with inheritance)"

# The NVR should be the first word in the last line
if [[ ! "$(tail -1 $rlRun_LOG)" =~ ^([^[:space:]]+) ]]; then
Expand Down
5 changes: 5 additions & 0 deletions tests/prepare/artifact/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ adjust:
- when: distro != fedora
enabled: false
because: Need to dynamically handle centos/brew/epel artifacts somehow also
# FIXME: docker-ce.repo does not support Fedora 44+, pick a stable
# repository-file source available on all Fedora releases and remove this gate.
- when: distro > fedora-43
enabled: false
because: docker-ce.repo does not support Fedora 44+
8 changes: 8 additions & 0 deletions tests/prepare/artifact/providers/copr-repository/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@ summary: Test copr-repository artifact provider
description: |
Test copr-repository artifact provider which makes packages from Copr
repositories available for installation.

# FIXME: mariobl/pyspread only has chroots for Fedora 43+. Replace with a
# tmt-owned COPR project with auto-branching so the gate can be removed.
# See https://github.com/teemtee/tmt/issues/4776
adjust+:
- when: distro < fedora-43
enabled: false
because: mariobl/pyspread COPR only has chroots for Fedora 43+
Comment thread
psss marked this conversation as resolved.
14 changes: 7 additions & 7 deletions tests/prepare/artifact/providers/file/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ rlJournalStart
rlPhaseStartSetup
rlRun "PROVISION_HOW=${PROVISION_HOW:-container}"
rlRun "pushd data"
rlRun "run=$(mktemp -d)" 0 "Create run directory"
rlRun "rpm_dir=$(mktemp -d)" 0 "Create local RPM directory"
rlRun "run=\$(mktemp -d)" 0 "Create run directory"
rlRun "rpm_dir=\$(mktemp -d)" 0 "Create local RPM directory"

setup_distro_environment

# 1. REMOTE URL (noarch)
get_koji_nvr "cowsay" "f${fedora_release}"
get_koji_nvr "cowsay" "$koji_tag"
COWSAY_NVR="$KOJI_NVR"

# Construct URL: Parses NVR (Name-Version-Release) and assembles Koji URL
Expand All @@ -27,16 +27,16 @@ rlJournalStart
rlLog "Using cowsay URL: $REMOTE_RPM_URL"

# 2. LOCAL FILE (arch-specific)
get_koji_nvr "figlet" "f${fedora_release}"
get_koji_nvr "figlet" "$koji_tag"
FIGLET_NVR="$KOJI_NVR"

rlRun "pushd $rpm_dir && koji download-build --arch=$ARCH $FIGLET_NVR; popd" 0 "Download figlet RPM for local test"
LOCAL_RPM=$(ls $rpm_dir/figlet*.rpm)
rlAssertExists "$LOCAL_RPM"

rlRun "multi_rpm_dir=$(mktemp -d)" 0 "Create directory for multiple RPMs"
# Use $fedora_release (set by setup_distro_environment) to ensure packages
rlRun "dnf download --forcearch=$ARCH --releasever=$fedora_release --destdir=$multi_rpm_dir boxes fortune-mod" 0 "Download boxes and fortune-mod RPMs using dnf"
rlRun "multi_rpm_dir=\$(mktemp -d)" 0 "Create directory for multiple RPMs"
# Use $release (set by setup_distro_environment) to ensure packages
rlRun "dnf download --forcearch=$ARCH --releasever=$release --destdir=$multi_rpm_dir boxes fortune-mod" 0 "Download boxes and fortune-mod RPMs using dnf"
rlPhaseEnd

rlPhaseStartTest "Test file provider with remote URL, local RPM, and directory with multiple RPMs"
Expand Down
2 changes: 1 addition & 1 deletion tests/prepare/artifact/providers/koji-build/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rlJournalStart
setup_distro_environment

# Get koji build ID for make
get_koji_build_id "make" "f${fedora_release}"
get_koji_build_id "make" "$koji_tag"
rlPhaseEnd

rlPhaseStartTest "Test koji.build provider with command-line override"
Expand Down
2 changes: 1 addition & 1 deletion tests/prepare/artifact/providers/koji-nvr/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rlJournalStart
setup_distro_environment

# Get koji NVR for make
get_koji_nvr "make" "f${fedora_release}"
get_koji_nvr "make" "$koji_tag"
rlPhaseEnd

rlPhaseStartTest "Test koji.nvr provider"
Expand Down
5 changes: 5 additions & 0 deletions tests/prepare/artifact/providers/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
adjust:
# TODO: Handle centos artifacts also
- when: distro != fedora
enabled: false
because: Need to dynamically handle centos/brew/epel artifacts somehow also
7 changes: 7 additions & 0 deletions tests/prepare/artifact/providers/multi/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ summary: Test multiple artifact providers
description: |
Test using multiple artifact providers together in a single
prepare step.

# FIXME: docker-ce.repo does not support Fedora 44+, pick a stable
# repository-file source available on all Fedora releases and remove this gate.
adjust+:
- when: distro > fedora-43
enabled: false
because: docker-ce.repo does not support Fedora 44+
2 changes: 1 addition & 1 deletion tests/prepare/artifact/providers/multi/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rlJournalStart
setup_distro_environment

# Get koji build ID for make
get_koji_build_id "make" "f${fedora_release}"
get_koji_build_id "make" "$koji_tag"
rlPhaseEnd

rlPhaseStartTest "Test multiple providers with command-line override"
Expand Down
7 changes: 7 additions & 0 deletions tests/prepare/artifact/providers/repository-file/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@ summary: Test repository-file artifact provider
description: |
Test repository-file artifact provider which configures external
package repositories from .repo files or URLs.

# FIXME: docker-ce.repo does not support Fedora 44+, pick a stable
# repository-file source available on all Fedora releases and remove this gate.
adjust+:
- when: distro > fedora-43
enabled: false
because: docker-ce.repo does not support Fedora 44+
Comment thread
psss marked this conversation as resolved.
2 changes: 1 addition & 1 deletion tests/prepare/artifact/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ rlJournalStart
setup_distro_environment

# Get koji build ID for make using common function
get_koji_build_id "make" "f${fedora_release}"
get_koji_build_id "make" "$koji_tag"
rlPhaseEnd

rlPhaseStartTest "Test artifact installation on Fedora"
Expand Down
35 changes: 0 additions & 35 deletions tests/prepare/verify-installation/data-centos/main.fmf

This file was deleted.

1 change: 0 additions & 1 deletion tests/prepare/verify-installation/data-fedora/.fmf/version

This file was deleted.

Comment thread
LecrisUT marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,27 @@
provide:
- koji.build:KOJI_BUILD_ID

adjust+:
- when: distro == centos
Comment thread
LecrisUT marked this conversation as resolved.
prepare+:
- how: feature
epel: enabled
order: 40

/plan/success:
prepare+:
- how: verify-installation
verify:
make: tmt-artifact-shared
make-devel: tmt-artifact-shared
diffutils: fedora
centpkg: tmt-artifact-shared

/plan/failure:
prepare+:
- how: verify-installation
verify:
make: tmt-artifact-shared
make-devel: SOME_NON_EXISTENT_REPO
diffutils: fedora
centpkg: SOME_NON_EXISTENT_REPO
random-non-existent-package: some-repo

/test:
test: /bin/true
require:
- make
- make-devel
- diffutils
- centpkg
63 changes: 15 additions & 48 deletions tests/prepare/verify-installation/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,69 +7,40 @@ rlJournalStart
rlRun "PROVISION_HOW=${PROVISION_HOW:-container}"
rlRun "run=\$(mktemp -d)" 0 "Create run directory"

if rlIsFedora; then
. ../artifact/lib/common.sh || exit 1
. ../artifact/lib/common.sh || exit 1

setup_distro_environment
rlRun "image=\$TEST_IMAGE_PREFIX/\$image_name"
setup_distro_environment

rlRun "data_dir=\$(mktemp -d)" 0 "Create temp data directory"
rlRun "image=$TEST_IMAGE_PREFIX/$image_name"

# Fetch the latest koji build ID for make dynamically
get_koji_build_id "make" "f\${fedora_release}"
rlRun "data_dir=\$(mktemp -d)" 0 "Create temp data directory"
rlRun "cp -r data/. $data_dir/" 0 "Copy test data"

# Copy plan data and substitute the dynamic build ID
rlRun "cp -r data-fedora/. \$data_dir/" 0 "Copy test data"
rlRun "sed -i 's/KOJI_BUILD_ID/${KOJI_BUILD_ID}/g' \$data_dir/main.fmf" 0 "Substitute koji build ID"
rlRun "pushd \$data_dir"
else
build_container_image "centos/stream10/upstream:latest"
rlRun "image=\$TEST_IMAGE_PREFIX/centos/stream10/upstream:latest"
rlRun "pushd data-centos"
fi
get_koji_build_id "centpkg" "$koji_tag"
rlRun "sed -i 's/KOJI_BUILD_ID/${KOJI_BUILD_ID}/g' $data_dir/main.fmf" 0 "Substitute koji build ID"
rlRun "pushd $data_dir"
rlPhaseEnd

rlPhaseStartTest "Test successful verification"
rlRun -s "tmt run -i \$run/success --scratch -vvv --all \
rlRun -s "tmt -c distro=$distro run -i $run/success --scratch -vvv --all \
plan --name /plan/success \
provision -h \$PROVISION_HOW --image \$image" \
provision -h $PROVISION_HOW --image $image" \
Comment thread
LecrisUT marked this conversation as resolved.
0 "Run verification test with correct repos"

# make and diffutils are available in both Fedora and CentOS
rlAssertGrep "pass .* / make" $rlRun_LOG
rlAssertGrep "pass .* / diffutils" $rlRun_LOG

if rlIsFedora; then
rlAssertGrep "pass .* / make-devel" $rlRun_LOG
else
rlAssertGrep "pass .* / centpkg" $rlRun_LOG
fi
rlAssertGrep "pass .* / centpkg" $rlRun_LOG

rlAssertGrep "All packages verified successfully." $rlRun_LOG
rlAssertNotGrep "Package source verification failed for:" $rlRun_LOG
rlAssertGrep "1 test passed" $rlRun_LOG
rlPhaseEnd

rlPhaseStartTest "Test verification failure"
rlRun -s "tmt run -i \$run/failure --scratch -vvv --all \
rlRun -s "tmt -c distro=$distro run -i $run/failure --scratch -vvv --all \
plan --name /plan/failure \
provision -h \$PROVISION_HOW --image \$image" \
provision -h $PROVISION_HOW --image $image" \
2 "Verification should fail with wrong repo"

# diffutils passes on both distros in the failure plan
rlAssertGrep "pass .* / diffutils" $rlRun_LOG

rlAssertGrep "4 packages" $rlRun_LOG
if rlIsFedora; then
rlAssertGrep "pass .* / make" $rlRun_LOG
rlAssertGrep "fail .* / make-devel" $rlRun_LOG
rlAssertGrep "actual 'tmt-artifact-shared'" $rlRun_LOG
else
rlAssertGrep "pass .* / centpkg" $rlRun_LOG
rlAssertGrep "fail .* / make" $rlRun_LOG
rlAssertGrep "actual 'baseos'" $rlRun_LOG
fi

rlAssertGrep "fail .* / centpkg" $rlRun_LOG
rlAssertGrep "expected repo 'SOME_NON_EXISTENT_REPO'" $rlRun_LOG
rlAssertGrep "fail .* / random-non-existent-package" $rlRun_LOG
rlAssertGrep "random-non-existent-package.*not installed" $rlRun_LOG
Expand All @@ -78,11 +49,7 @@ rlJournalStart
rlPhaseEnd

rlPhaseStartCleanup
if rlIsFedora; then
rlRun "rm -rf \$run \$data_dir" 0 "Removing run and data directories"
else
rlRun "rm -rf \$run" 0 "Removing run directory"
fi
rlRun "rm -rf $run $data_dir" 0 "Removing run and data directories"
rlRun "popd"
rlPhaseEnd
rlJournalEnd
Loading