Skip to content

Commit

Permalink
Merge pull request #323 from lsm5/tmt-tests-simplify-2
Browse files Browse the repository at this point in the history
TMT: Simplify tests
  • Loading branch information
Luap99 authored Aug 1, 2024
2 parents a688655 + 74f7615 commit a1bbef4
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 70 deletions.
29 changes: 20 additions & 9 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ upstream_tag_template: v{version}
files_to_sync:
- src: rpm/gating.yaml
dest: gating.yaml
delete: true
- src: plans/
dest: plans/
delete: true
Expand Down Expand Up @@ -51,7 +52,7 @@ jobs:
packages: [container-selinux-centos]
notifications: *copr_build_failure_notification
enable_net: true
targets:
targets: &centos_targets
- centos-stream-9
- centos-stream-10

Expand Down Expand Up @@ -86,15 +87,23 @@ jobs:
message: "Tests failed. @containers/packit-build please check."
targets:
- fedora-all
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

# Tests for CentOS Stream
- job: tests
trigger: pull_request
packages: [container-selinux-centos]
notifications: *test_failure_notification
targets:
- centos-stream-9
- centos-stream-10
targets: *centos_targets
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 for RHEL
- job: tests
Expand All @@ -105,11 +114,13 @@ jobs:
targets:
epel-9-x86_64:
distros: [RHEL-9.4.0-Nightly,RHEL-9-Nightly]
# Use centos-stream-10 until we have epel-10
# TODO: Enable after RHEL-10 gets selinux-policy >= 40.13.1 which is
# already on CentOS Stream 10.
#centos-stream-10-x86_64:
# distros: [RHEL-10-Beta-Nightly]
tf_extra_params:
environments:
- artifacts:
- type: repository-file
id: https://copr.fedorainfracloud.org/coprs/rhcontainerbot/podman-next/repo/epel-$releasever/rhcontainerbot-podman-next-epel-$releasever.repo
- type: repository-file
id: https://src.fedoraproject.org/rpms/epel-release/raw/epel9/f/epel.repo

- job: propose_downstream
trigger: release
Expand Down
2 changes: 1 addition & 1 deletion plans/all.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ execute:
when: initiator is not defined or initiator != packit

/downstream:
summary: Run SELinux specific Podman e2e tests on bodhi / errata and dist-git PRs
summary: Run SELinux specific Podman tests on bodhi / errata and dist-git PRs
discover+:
filter: tag:downstream
adjust+:
Expand Down
20 changes: 6 additions & 14 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@ basic_check:
semodule --list=full | grep container
semodule -B

.PHONY: podman_e2e_test_upstream
podman_e2e_test_upstream:
bash ./podman-tests.sh e2e upstream
.PHONY: podman_e2e_test
podman_e2e_test:
bash ./podman-tests.sh e2e

.PHONY: podman_e2e_test_downstream
podman_e2e_test_downstream:
bash ./podman-tests.sh e2e downstream

.PHONY: podman_system_test_upstream
podman_system_test_upstream:
bash ./podman-tests.sh system upstream

.PHONY: podman_system_test_downstream
podman_system_test_downstream:
bash ./podman-tests.sh system downstream
.PHONY: podman_system_test
podman_system_test:
bash ./podman-tests.sh system

clean:
rm -rf podman-*dev* podman.spec
26 changes: 9 additions & 17 deletions test/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,16 @@ require:
- policycoreutils

/basic_check:
summary: Run basic checks
tag: [ upstream, downstream ]
summary: Run basic checks
test: make basic_check

/upstream:
tag: upstream
/upstream/podman_e2e_test:
summary: Run SELinux specific Podman e2e tests on upstream PRs
test: make podman_e2e_test_upstream
/upstream/podman_system_test:
summary: Run SELinux specific Podman system tests on upstream PRs
test: make podman_system_test_upstream
/podman_e2e_test:
tag: [ upstream, downstream ]
summary: Run SELinux specific Podman e2e tests
test: make podman_e2e_test

/downstream:
tag: downstream
/downstream/podman_e2e_test:
summary: Run SELinux specific Podman e2e tests on downstream bodhi / errata and dist-git PRs
test: make podman_e2e_test_downstream
/downstream/podman_system_test:
summary: Run SELinux specific Podman system tests on downstream bodhi / errata and dist-git PRs
test: make podman_system_test_downstream
/podman_system_test:
tag: [ upstream, downstream ]
summary: Run SELinux specific Podman system tests
test: make podman_system_test
33 changes: 4 additions & 29 deletions test/podman-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,19 @@

set -exo pipefail

cat /etc/redhat-release

if [[ "$(id -u)" -ne 0 ]];then
echo "Please run as superuser"
exit 1
fi

if [[ -z "$1" ]]; then
echo -e "Usage: podman-tests.sh TEST_TYPE STREAM\nTEST_TYPE can be 'e2e' or 'system'\nSTREAM can be 'upstream' or 'downstream'"
echo -e "Usage: $(basename ${BASH_SOURCE[0]}) TEST_TYPE\nTEST_TYPE can be 'e2e' or 'system'\n"
exit 1
fi

TEST_TYPE=$1
STREAM=$2

# `rhel` macro exists on RHEL, CentOS Stream, and Fedora ELN
# `centos` macro exists only on CentOS Stream
CENTOS_VERSION=$(rpm --eval '%{?centos}')
RHEL_VERSION=$(rpm --eval '%{?rhel}')

# For upstream tests, we need to test with podman and other packages from the
# podman-next copr. For downstream tests (bodhi, errata), we don't need any
# additional setup
if [[ "$STREAM" == "upstream" ]]; then
# Use CentOS Stream 10 copr target for RHEL-10 until EPEL 10 becomes
# available
if [[ -n $CENTOS_VERSION || $RHEL_VERSION -ge 10 ]]; then
dnf -y copr enable rhcontainerbot/podman-next centos-stream-$CENTOS_VERSION
else
dnf -y copr enable rhcontainerbot/podman-next
fi
echo "priority=5" >> /etc/yum.repos.d/_copr:copr.fedorainfracloud.org:rhcontainerbot:podman-next.repo
fi

# Remove testing-farm repos if they exist as these interfere with the packages
# we want to install, especially when podman-next copr is involved
Expand Down Expand Up @@ -69,18 +51,11 @@ tar zxf *.tar.gz

popd

# Enable EPEL on RHEL/CentOS Stream envs to fetch bats
if [[ -n $(rpm --eval '%{?rhel}') ]]; then
# Until EPEL 10 is available use epel-9 for all RHEL and CentOS Stream
dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
sed -i 's/$releasever/9/g' /etc/yum.repos.d/epel.repo
fi

# Install dependencies for running tests
# NOTE: bats will be fetched from Fedora repos on public testing-farm envs if EPEL repo is absent or disabled.
dnf -y install bats golang

# Print versions of distro and installed packages
cat /etc/redhat-release
rpm -q bats container-selinux golang podman podman-tests selinux-policy

if [[ "$TEST_TYPE" == "e2e" ]]; then
Expand Down

0 comments on commit a1bbef4

Please sign in to comment.