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

Fedora Testing Farm #1287

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
43e02e6
ci: enable Fedora Testing Farm
praiskup Jan 15, 2024
0101b7c
behave: remove dnf5 if needed
praiskup Jan 24, 2024
50a548f
testing-farm: install the correct package versions
praiskup Jan 25, 2024
6f198ce
packit: build also for stable fedora
praiskup Jan 25, 2024
1ae530f
ci: run old testsuite by testing farm
praiskup Jan 26, 2024
8933aa9
ci: disable mock rebuild with TMT
praiskup Jan 26, 2024
b87dc52
cat the long log
praiskup Jan 26, 2024
731eb21
fix
praiskup Jan 26, 2024
2f78fd9
revert: debug env again
praiskup Jan 28, 2024
f3fd46e
set -x
praiskup Jan 29, 2024
def4b6a
simplify packit
praiskup Jan 29, 2024
ec184c8
don't skip build to try sha1 match
praiskup Jan 29, 2024
213adfa
do not produce a local-only merge commit
praiskup Jan 29, 2024
10734fd
clean install-copr-packages
praiskup Jan 29, 2024
686ba40
polish old testsuite
praiskup Jan 29, 2024
2f19f9e
text
praiskup Jan 29, 2024
41c4daa
fail
praiskup Jan 29, 2024
e0baa4b
verbose failure
praiskup Jan 31, 2024
f551365
revert: verbosity
praiskup Jan 31, 2024
81ac20e
install-copr-packages to download SRPMs
praiskup Feb 1, 2024
3458e1b
Download srpm.
praiskup Feb 1, 2024
d2dfd83
sort out standard outputs
praiskup Feb 1, 2024
dc9941e
work in /tmp
praiskup Feb 1, 2024
e58c740
fix
praiskup Feb 1, 2024
082e983
tests: work-around for test failure #1300
praiskup Feb 1, 2024
c8afd99
shellcheck
praiskup Feb 1, 2024
a7456b5
t/f
praiskup Feb 1, 2024
2c16bc4
Revert "revert: debug env again"
praiskup Feb 1, 2024
6c92c4a
give it more time
praiskup Feb 1, 2024
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 .fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
35 changes: 21 additions & 14 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,34 @@
# https://packit.dev/docs/configuration/

---
actions:
create-archive:
- bash -c "tito build --tgz --test -o ."
- bash -c "ls -1t ./*.tar.gz | head -n 1"
get-current-version:
- bash -c "grep ^Version \"$PACKIT_CONFIG_PACKAGE_NAME.spec\" | awk '{ print $2 }'"

# We need to keep the pushed SHA, it is later exported
# as $PACKIT_COMMIT_SHA for Testing Farm jobs.
merge_pr_in_ci: false

packages:
mock:
specfile_path: mock.spec
paths:
- ./mock
actions:
create-archive:
- bash -c "tito build --tgz --test -o ."
- bash -c "ls -1t ./*.tar.gz | head -n 1"
get-current-version:
- bash -c "git describe --match mock-[0-9]* --abbrev=0 HEAD | egrep -o
[0-9]+\.[0-9]+"
downstream_package_name: mock
upstream_tag_template: mock-{version}
mock-core-configs:
specfile_path: mock-core-configs.spec
paths:
- ./mock-core-configs
actions:
create-archive:
- bash -c "tito build --tgz --test -o ."
- bash -c "ls -1t ./*.tar.gz | head -n 1"
get-current-version:
- bash -c "git describe --match mock-core-configs-[0-9]* --abbrev=0 HEAD
| egrep -o [0-9]+\.[0-9]+"
downstream_package_name: mock-core-configs
upstream_tag_template: mock-core-configs-{version}
srpm_build_deps:
- tito
- git

jobs:
- job: copr_build
trigger: pull_request
Expand All @@ -41,3 +39,12 @@ jobs:
metadata:
targets:
- fedora-rawhide
- fedora-latest-stable

- job: tests
trigger: pull_request
targets:
- fedora-latest-stable
# We don't want to run two test runs; so we limit this to a single package
packages:
- mock
29 changes: 28 additions & 1 deletion behave/features/steps/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,26 @@
# pylint: disable=missing-function-docstring,function-redefined


def _first_int(string, max_lines=20):
for line in string.split("\n")[:max_lines]:
if not line:
continue
first_word = line.split()[0]
if first_word.isdigit():
return first_word
raise Exception("unexpected dnf history output")


def add_cleanup_last_transaction(context):
# TODO: DNF5 support https://github.com/rpm-software-management/dnf5/issues/140
dnf = ["sudo", "/usr/bin/dnf-3", "-y", "history"]
_, out, _ = run(dnf + ["list"])
transaction_id = _first_int(out)
def _revert_transaction(_context):
cmd = dnf + ["undo", transaction_id]
assert_that(run(cmd)[0], equal_to(0))
context.add_cleanup(_revert_transaction, context)

@given(u'an unique mock namespace')
def step_impl(context):
print("using uniqueext {}".format(context.uniqueext))
Expand All @@ -39,7 +59,14 @@ def step_impl(context, package, state):
is_installed = bool(not is_installed)

if "not" in state:
assert_that(is_installed, equal_to(False))
if not is_installed:
return # nothing to do

# Remove the package and schedule its removal
cmd = ["sudo", "dnf", "-y", "remove", package]
assert_that(run(cmd)[0], equal_to(0))
# schedule removal
add_cleanup_last_transaction(context)
return

if is_installed:
Expand Down
20 changes: 17 additions & 3 deletions mock/integration-tests/runtests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/sh -x
# vim:tw=0:ts=4:sw=4

# this is a test script to run everything through its paces before you do a
Expand Down Expand Up @@ -32,6 +32,18 @@ trap '$MOCKCMD --clean; exit 1' INT HUP QUIT TERM
# pre-populate yum cache for the rest of the commands below
#

# With TMT, we have the deps pre-installed by ansible.
if test -z "$TMT_VERSION"; then
MOCKSRPM=$(
cd "$TOPDIR" || exit 1
tito build --srpm --offline | grep Wrote | grep src.rpm | awk '{ print $2 }'
)
test -e "$MOCKSRPM" || exit 1
else
set -- /tmp/mock-test-srpms/mock-*.src.rpm
MOCKSRPM=$1
fi

if [ -e /usr/bin/dnf ]; then
header "pre-populating the cache (DNF)"
runcmd "$MOCKCMD --init --dnf"
Expand All @@ -44,14 +56,16 @@ fi
header "installing dependencies for $MOCKSRPM"
runcmd "$MOCKCMD --disable-plugin=tmpfs --installdeps $MOCKSRPM"
if [ ! -e $CHROOT/usr/include/python* ]; then
echo "installdeps test FAILED. could not find /usr/include/python*"
exit 1
echo "installdeps test FAILED. could not find /usr/include/python*"
exit 1
fi

header "running regression tests"
sh ${TESTDIR}/runregressions.sh
fails=$?

exit $fails

msg=$(printf "%s regression failures\n" $fails)
header "$msg"

Expand Down
106 changes: 106 additions & 0 deletions mock/integration-tests/setup-playbook/files/install-copr-packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
#! /bin/bash

# Install an RPM package (and its dependencies) identified by
# the (a) package name, (b) upstream commmit and (c) Copr directory. The short
# variant of the upstream commit must be part of the package Release tag.
#
# ARG1: coprowner/projectname:dir or https://
# ARG2: upstream-commit
# ARGN: packagename1 packagename2 ...

# TODO: DNF5/YUM compat?
DNF=/usr/bin/dnf-3
REPOQUERY=( "$DNF" repoquery )
DOWNLOAD=( "$DNF" download )

copr_dir=$1 ; shift
commit=$1 ; shift
copr_uri=https://download.copr.fedorainfracloud.org/results

copr_chroot() (
# mimic: https://github.com/rpm-software-management/dnf5/blob/c6edcd75260accf7070f261e5b406fcf1f5db328/dnf5-plugins/copr_plugin/copr_config.cpp#L71-L80
. /etc/os-release
name=$ID
version=$VERSION_ID
arch=$(rpm --eval %_arch)
if test "$name" = fedora; then
if test "$REDHAT_SUPPORT_PRODUCT_VERSION" = rawhide; then
version=rawhide
fi
fi
echo "$name-$version-$arch"
)

repo=$copr_uri/$copr_dir/$(copr_chroot)

echo >&2 "using repo: $repo"

repoid=xyztest

export clean_cache=true


repos=( "--repofrompath=$repoid,$repo" )

_repoquery() {
local opts=( "${repos[@]}" --disablerepo='*' --enablerepo "$repoid" )
if ${clean_cache-true}; then
opts+=( "--setopt=$repoid.metadata_expire=1" )
fi
local cmd=( "${REPOQUERY[@]}" "${opts[@]}" "$@" )
info "Executing: ${cmd[*]}"
"${cmd[@]}" 2>/dev/null
}

info() { echo >&2 "INFO: $*" ; }
error() { echo >&2 "ERROR: $*" ; false; }
die() { echo >&2 "FATAL: $*" ; exit 1 ; }

find_nvr() {
# ARGS: $1=pkg $2=commit
# RETURN: $find_nvr_result
# STATUS: true if found
local _pkgname=$1 _commit=${2:0:7} _found=false
while read -r name version release; do
test -z "$name" && continue
test "$name" = "$_pkgname" || continue
case $release in
*$_commit*)
find_nvr_result=$name-$version-$release
$_found && error "second occurence of $name-$version-$release"
_found=true
;;
*)
continue
;;
esac
done < <( _repoquery --qf='%{NAME} %{VERSION} %{RELEASE}\n' )
$_found || error "$_pkgname with $commit in release not found"
}

nvrs=()
SECONDS=0
TIMEOUT=${TIMEOUT-1200} # 20 minutes by default
for pkg; do
while true; do
if find_nvr "$pkg" "$commit"; then
nvrs+=( "$find_nvr_result" )
clean_cache=false
break
fi
test "$SECONDS" -gt "$TIMEOUT" && die "The timeout ${TIMEOUT}s left"
clean_cache=true
sleep 5
done
done

if test -n "$SRPM_DOWNLOAD_DIR"; then
mkdir -p "$SRPM_DOWNLOAD_DIR"
cmd=( "${DOWNLOAD[@]}" "${repos[@]}" '--disablerepo=*' --enablerepo xyztest
"${nvrs[@]}" --source --downloaddir "$SRPM_DOWNLOAD_DIR" )
else
cmd=( "$DNF" -y install "${nvrs[@]}" "${repos[@]}" --nogpgcheck )
fi

info "Running: ${cmd[*]}"
"${cmd[@]}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#! /bin/bash -x

# Install specific RPM packages (and its dependencies) from a Copr repository
# created by Packit PR or PUSH workflow. Pick the precise package version built
# from the latest commit in the PR.

_d=$(dirname "$(readlink -f "$0")")

if test -n "$PACKIT_PR_ID"; then
PROJECT=packit/rpm-software-management-mock-$PACKIT_PR_ID
COMMIT=$PACKIT_COMMIT_SHA
elif test -n "$PACKIT_COPR_PROJECT"; then
PROJECT=$PACKIT_COPR_PROJECT
COMMIT=$PACKIT_COMMIT_SHA
elif test -n "$TEST_GIT_MAIN"; then
PROJECT=@mock/mock
COMMIT=$(curl -H "Accept: application/vnd.github.VERSION.sha" https://api.github.com/repos/rpm-software-management/mock/commits/main)
else
echo >&2 "Can't decide where to install packages from"
exit 1
fi

"$_d/install-copr-packages" "$PROJECT" "$COMMIT" "$@"
25 changes: 25 additions & 0 deletions mock/integration-tests/setup-playbook/play-tf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: Prepare the testing machine for running Mock tests
hosts: all
user: "root"
vars:
mock_test_username: mockbuild
mock_test_workdir: /home/mock/mock-testing
mock_gpg_dir: "/home/mockbuild/gpg"
mock_gpg_wrapper: "/home/mockbuild/gpg-mock"
mock_test_rpmmacros: /home/mockbuild/.rpmmacros
mock_lvm_volume: /test-lvm-disk
mock_clone: /home/mockbuild/mock
no_subscription_management: true

tasks:
- include_tasks: tasks/main.yml

- name: upload the "install copr package" script
copy:
src: "{{ item }}"
dest: "/usr/bin/{{ item }}"
mode: '0755'
loop:
- install-copr-packages
- install-mock-packages-built-by-packit
2 changes: 2 additions & 0 deletions mock/integration-tests/setup-playbook/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@
username: "{{ mock_rhn_user }}"
password: "{{ mock_rhn_pass }}"
pool: "Red Hat Enterprise Linux for Virtual Datacenters, Standard"
when:
- no_subscription_management is not defined or no_subscription_management is false

- name: Clone Mock repo
git:
Expand Down
1 change: 0 additions & 1 deletion mock/integration-tests/testenvironment
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
TESTDIR=$(cd $(dirname $0); pwd; cd ..)
TOPDIR=$(dirname $TESTDIR)
MOCKSRPM=$( (cd $TOPDIR; tito build --srpm --offline |grep Wrote | grep src.rpm | awk '{ print $2}' ))
SIMPLESRPM=$TESTDIR/test-C-1.1-0.src.rpm

#VERBOSE=
Expand Down
12 changes: 12 additions & 0 deletions testing-farm/plans/behave.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
summary: run the behave tests in Fedora Testing Farm
discover:
- how: fmf
filter: "tag: behave"

prepare:
- how: ansible
playbook: mock/integration-tests/setup-playbook/play-tf.yml

execute:
- how: tmt
12 changes: 12 additions & 0 deletions testing-farm/plans/old-testsuite.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
summary: run the old testsuite in Fedora Testing Farm
discover:
- how: fmf
filter: "tag: old_testsuite"

prepare:
- how: ansible
playbook: mock/integration-tests/setup-playbook/play-tf.yml

execute:
- how: tmt
9 changes: 9 additions & 0 deletions testing-farm/tests/behave/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
summary: Execute the behave test
test: ./test.sh
tag: behave
duration: 2h

require:
- type: file
pattern: /behave
5 changes: 5 additions & 0 deletions testing-farm/tests/behave/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -eux

cd ../../../behave
install-mock-packages-built-by-packit mock-core-configs mock
behave
10 changes: 10 additions & 0 deletions testing-farm/tests/old-testsuite/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
summary: Execute the old `make check` test-suite
test: ./test.sh
tag: old_testsuite
duration: 2h

require:
- type: file
# copy-paste the whole directory
pattern: /
22 changes: 22 additions & 0 deletions testing-farm/tests/old-testsuite/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash -eux

# Copy files so the 'mockbuild' user has the full access
workdir=$(mktemp -d --suffix=-mock-old-tests)
rsync -rav ../../../ "$workdir"
chown -Rv mockbuild:mockbuild "$workdir"

# Install the tested RPMs
install-mock-packages-built-by-packit mock-core-configs mock

# Download the tested SRPM
SRPM_DOWNLOAD_DIR=/tmp/mock-test-srpms install-mock-packages-built-by-packit mock

# Testsuite is prepared for the mockbuild user

cd "$workdir/mock"
if (sudo -E -u mockbuild make check > >(tee the-log | grep -e FAILED: -e PASSED:) 2>&1) >&2; then
Fixed Show fixed Hide fixed
echo "The 'make check' testsuite passed."
else
cat the-log
exit 1
fi
Loading