Skip to content

Commit bf95d6c

Browse files
authored
Add testing base for package installation cases (#4960)
Related to #4910, but does not cover all cases. For now the cases covered are: - `/baseline`: the bare minimum for package installation - `/verified-artifacts/basic`: the equivalent of above but with verified artifacts - `/no-artifacts/upgrade`: the failure case described in #4421 - `/verified-artifacts/pre-installed`: the failure case described in #4838 (previously #4924, but that was closed because it was opened from a fork) --------- Signed-off-by: Cristian Le <git@lecris.dev>
1 parent 78f5b1e commit bf95d6c

28 files changed

Lines changed: 665 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
. /usr/share/beakerlib/beakerlib.sh || exit 1
3+
. ../../images.sh || exit 1
4+
. ./lib/common.sh || exit 1
5+
6+
rlJournalStart
7+
rlPhaseStartSetup "Prepare test environment"
8+
rlRun "testdir=$(mktemp -d)" 0 "Create test directory"
9+
10+
build_rpms
11+
12+
rlRun "cp -a install-cases $testdir/data" 0 "Copy test data"
13+
rlRun "cp -a rpms $testdir/data/" 0 "Copy rpms data"
14+
rlRun "pushd $testdir/data" 0 "Enter test directory"
15+
rlRun "run=$(mktemp -d)" 0 "Create run directory"
16+
17+
setup_distro_environment
18+
rlPhaseEnd
19+
20+
xfail_plans=(
21+
"/verified-artifacts/pre-installed"
22+
)
23+
24+
while IFS= read -r image; do
25+
if ! is_fedora "$image" && ! is_centos "$image"; then
26+
# Can only test rpm artifacts right now
27+
continue
28+
fi
29+
30+
extra_env=""
31+
if is_centos_7 "$image"; then
32+
extra_env="-e DNF_CMD=yum"
33+
# TODO: centos7 is hard
34+
continue
35+
fi
36+
37+
if is_centos_stream_9 "$image" || is_centos_stream_10 "$image"; then
38+
# TODO(#4941):
39+
# dnf repoquery fails
40+
# - Error: 'Package' object has no attribute 'full_nevra'
41+
# - Or gives an output of
42+
# 'bar':
43+
# - nevra: '%{full_nevra}'
44+
# repo_id: 'tmt-artifact-shared'
45+
continue
46+
fi
47+
48+
phase_prefix="$(test_phase_prefix $image)"
49+
50+
for plan in $(tmt plans ls); do
51+
xfail=""
52+
expected_result=0
53+
for check_pattern in ${xfail_plans[@]}; do
54+
if [[ "$plan" =~ $check_pattern ]]; then
55+
xfail="(XFAIL)"
56+
expected_result=2
57+
break
58+
fi
59+
done
60+
rlPhaseStartTest "$phase_prefix $plan $xfail"
61+
rlRun "tmt run $extra_env -i $run --scratch -vvv --all \
62+
plan --name $plan \
63+
provision -h $PROVISION_HOW --image $image" \
64+
$expected_result "Run test case $plan $xfail"
65+
rlPhaseEnd
66+
done
67+
done <<< "$IMAGES"
68+
69+
70+
rlPhaseStartCleanup
71+
rlRun "popd"
72+
rlRun "rm -rf $run $testdir" 0 "Remove temporary files directories"
73+
rlPhaseEnd
74+
rlJournalEnd
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
summary: Basic case (non-verified)
2+
description: |
3+
System repo: foo-1.4 (baseline)
4+
Pre-installed: None
5+
Artifacts: foo-2.2 or foo-1.2
6+
7+
Normal installation case with an non-verified artifact available
8+
9+
/upgrade:
10+
summary: " (upgrading)"
11+
context+:
12+
available_artifact: foo-2.2
13+
environment+:
14+
EXPECTED_PACKAGE: foo-2.2
15+
16+
/downgrade:
17+
summary: " (downgrading)"
18+
context+:
19+
available_artifact: foo-1.2
20+
environment+:
21+
# TODO: This downgraded because of the forced artifact priority
22+
# change this when the repo priority is opt-in
23+
EXPECTED_PACKAGE: foo-1.2
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
summary: Pre-installed package present (non-verified)
2+
description: |
3+
System repo: foo-1.4 (baseline)
4+
Pre-installed: foo-1.4
5+
Artifacts: foo-2.2 or foo-1.2
6+
7+
Pre-installed package should be respected in this case
8+
9+
environment+:
10+
PRE_INSTALLED_PACKAGE: rpms/foo-1.4/foo-1.4*.rpm
11+
12+
/upgrade:
13+
summary: " (upgrading)"
14+
context+:
15+
available_artifact: foo-2.2
16+
environment+:
17+
EXPECTED_PACKAGE: foo-1.4
18+
19+
/downgrade:
20+
summary: " (downgrading)"
21+
context+:
22+
available_artifact: foo-1.2
23+
environment+:
24+
EXPECTED_PACKAGE: foo-1.4
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
summary: Baseline case
2+
description: |
3+
System repo: foo-1.4 (baseline)
4+
Pre-installed: None
5+
Artifacts: None
6+
7+
Normal installation case with no artifacts or anything special
8+
9+
environment+:
10+
EXPECTED_PACKAGE: foo-1.4
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
discover:
2+
- how: fmf
3+
test:
4+
- /test
5+
prepare:
6+
- name: Setup system
7+
order: 20
8+
how: shell
9+
script: |
10+
# Prepare the system repo
11+
mkdir system_repo
12+
for pkg in $SYSTEM_PACKAGE; do
13+
cp rpms/$pkg/*.rpm system_repo/
14+
done
15+
16+
# Running dnf/createrepo commands manually to bypass prepare/install handling
17+
$DNF_CMD install -y createrepo
18+
createrepo system_repo
19+
cat > /etc/yum.repos.d/system-test-repo.repo <<EOF
20+
[system-test-repo]
21+
baseurl=file://$(pwd)/system_repo
22+
gpgcheck=0
23+
EOF
24+
25+
# Install packages expected to be pre-installed (if any)
26+
if [[ -n "$PRE_INSTALLED_PACKAGE" ]]; then
27+
$DNF_CMD install -y $PRE_INSTALLED_PACKAGE
28+
fi
29+
- name: Main artifact to test and verify
30+
order: 40
31+
how: artifact
32+
provide:
33+
- file:rpms/$@{verified_artifact}/*.rpm
34+
verify: true
35+
when: verified_artifact is defined
36+
- name: Secondary artifacts made available (not verified)
37+
order: 40
38+
how: artifact
39+
provide:
40+
- file:rpms/$@{available_artifact}/*.rpm
41+
verify: false
42+
when: available_artifact is defined
43+
44+
execute:
45+
how: tmt
46+
47+
context:
48+
want_devel: "false"
49+
with_bar: "false"
50+
xfail: "false"
51+
52+
environment:
53+
SYSTEM_PACKAGE: foo-1.4
54+
EXPECTED_PACKAGE: ""
55+
PRE_INSTALLED_PACKAGE: ""
56+
DNF_CMD: dnf
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
summary: Newer version on system
2+
description: |
3+
System repo: foo-1.4 (baseline)
4+
Pre-installed: foo-1.0
5+
Artifacts: None
6+
7+
`foo` is pre-installed but we do not really want to upgrade it.
8+
9+
environment+:
10+
EXPECTED_PACKAGE: foo-1.0
11+
PRE_INSTALLED_PACKAGE: rpms/foo-1.0/foo-1.0*.rpm
12+
13+
/only-foo:
14+
summary+: " (only foo requested)"
15+
16+
/with-bar:
17+
summary+: " (foo and bar requested)"
18+
description+: |
19+
Installing another dependency (`bar`) should not upgrade `foo`.
20+
context+:
21+
with_bar: "true"
22+
environment+:
23+
SYSTEM_PACKAGE+: " bar"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/:
2+
inherit: false
3+
4+
test: |
5+
rpm -q $EXPECTED_PACKAGE
6+
require:
7+
- foo
8+
9+
adjust:
10+
- when: want_devel == true
11+
require:
12+
- foo-devel
13+
- when: with_bar == true
14+
require+:
15+
- bar
16+
- when: xfail == true
17+
result: xfail
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
summary: Basic case
2+
description: |
3+
System repo: foo-1.4 (baseline)
4+
Pre-installed: None
5+
Artifacts: foo-2.4 or foo-1.1
6+
7+
Normal installation case with an artifact
8+
9+
/upgrade:
10+
summary: " (upgrading)"
11+
context+:
12+
verified_artifact: foo-2.4
13+
environment+:
14+
EXPECTED_PACKAGE: foo-2.4
15+
16+
/downgrade:
17+
summary: " (downgrading)"
18+
context+:
19+
verified_artifact: foo-1.1
20+
environment+:
21+
EXPECTED_PACKAGE: foo-1.1
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
summary: Pre-installed package present
2+
description: |
3+
System repo: foo-1.4 (baseline)
4+
Pre-installed: foo-1.4
5+
Artifacts: foo-2.4 or foo-1.1
6+
7+
Pre-installed package should be ignored in this case
8+
9+
environment+:
10+
PRE_INSTALLED_PACKAGE: rpms/foo-1.4/foo-1.4*.rpm
11+
context+:
12+
# Because presence check gets in the way.
13+
# It should fail at verify phase and test execution.
14+
xfail: "true"
15+
16+
/upgrade:
17+
summary: " (upgrading)"
18+
context+:
19+
verified_artifact: foo-2.4
20+
environment+:
21+
EXPECTED_PACKAGE: foo-2.4
22+
23+
/downgrade:
24+
summary: " (downgrading)"
25+
context+:
26+
verified_artifact: foo-1.1
27+
environment+:
28+
EXPECTED_PACKAGE: foo-1.1

0 commit comments

Comments
 (0)