-
Notifications
You must be signed in to change notification settings - Fork 168
Add testing base for package installation cases #4960
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
base: main
Are you sure you want to change the base?
Changes from all commits
28c8b4e
131c76e
456aa30
27d34eb
27cc324
256998d
3eb5b9d
950d0f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,74 @@ | ||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||
| . /usr/share/beakerlib/beakerlib.sh || exit 1 | ||||||||||||||||||||||||
| . ../../images.sh || exit 1 | ||||||||||||||||||||||||
| . ./lib/common.sh || exit 1 | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| rlJournalStart | ||||||||||||||||||||||||
| rlPhaseStartSetup "Prepare test environment" | ||||||||||||||||||||||||
| rlRun "testdir=$(mktemp -d)" 0 "Create test directory" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| build_rpms | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| rlRun "cp -a install-cases $testdir/data" 0 "Copy test data" | ||||||||||||||||||||||||
| rlRun "cp -a rpms $testdir/data/" 0 "Copy rpms data" | ||||||||||||||||||||||||
| rlRun "pushd $testdir/data" 0 "Enter test directory" | ||||||||||||||||||||||||
| rlRun "run=$(mktemp -d)" 0 "Create run directory" | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| setup_distro_environment | ||||||||||||||||||||||||
| rlPhaseEnd | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| xfail_plans=( | ||||||||||||||||||||||||
| "/verified-artifacts/pre-installed" | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| while IFS= read -r image; do | ||||||||||||||||||||||||
| if ! is_fedora "$image" && ! is_centos "$image"; then | ||||||||||||||||||||||||
| # Can only test rpm artifacts right now | ||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| extra_env="" | ||||||||||||||||||||||||
| if is_centos_7 "$image"; then | ||||||||||||||||||||||||
| extra_env="-e DNF_CMD=yum" | ||||||||||||||||||||||||
| # TODO: centos7 is hard | ||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if is_centos_stream_9 "$image" || is_centos_stream_10 "$image"; then | ||||||||||||||||||||||||
| # TODO(#4941): | ||||||||||||||||||||||||
| # dnf repoquery fails | ||||||||||||||||||||||||
| # - Error: 'Package' object has no attribute 'full_nevra' | ||||||||||||||||||||||||
| # - Or gives an output of | ||||||||||||||||||||||||
| # 'bar': | ||||||||||||||||||||||||
| # - nevra: '%{full_nevra}' | ||||||||||||||||||||||||
| # repo_id: 'tmt-artifact-shared' | ||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| phase_prefix="$(test_phase_prefix $image)" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| for plan in $(tmt plans ls); do | ||||||||||||||||||||||||
| xfail="" | ||||||||||||||||||||||||
| expected_result=0 | ||||||||||||||||||||||||
| for check_pattern in ${xfail_plans[@]}; do | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||
| if [[ "$plan" =~ $check_pattern ]]; then | ||||||||||||||||||||||||
| xfail="(XFAIL)" | ||||||||||||||||||||||||
| expected_result=2 | ||||||||||||||||||||||||
| break | ||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||
| done | ||||||||||||||||||||||||
| rlPhaseStartTest "$phase_prefix $plan $xfail" | ||||||||||||||||||||||||
| rlRun "tmt run $extra_env -i $run --scratch -vvv --all \ | ||||||||||||||||||||||||
| plan --name $plan \ | ||||||||||||||||||||||||
| provision -h $PROVISION_HOW --image $image" \ | ||||||||||||||||||||||||
| $expected_result "Run test case $plan $xfail" | ||||||||||||||||||||||||
|
Comment on lines
+60
to
+64
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create a unique run directory for each test case inside the loop to preserve logs for debugging. Reusing a single
Suggested change
|
||||||||||||||||||||||||
| rlPhaseEnd | ||||||||||||||||||||||||
| done | ||||||||||||||||||||||||
| done <<< "$IMAGES" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| rlPhaseStartCleanup | ||||||||||||||||||||||||
| rlRun "popd" | ||||||||||||||||||||||||
| rlRun "rm -rf $run $testdir" 0 "Remove temporary files directories" | ||||||||||||||||||||||||
| rlPhaseEnd | ||||||||||||||||||||||||
| rlJournalEnd | ||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| summary: Basic case (non-verified) | ||
| description: | | ||
| System repo: foo-1.4 (baseline) | ||
| Pre-installed: None | ||
| Artifacts: foo-2.2 or foo-1.2 | ||
|
|
||
| Normal installation case with an non-verified artifact available | ||
|
|
||
| /upgrade: | ||
| summary: " (upgrading)" | ||
| context+: | ||
| available_artifact: foo-2.2 | ||
| environment+: | ||
| EXPECTED_PACKAGE: foo-2.2 | ||
|
|
||
| /downgrade: | ||
| summary: " (downgrading)" | ||
| context+: | ||
| available_artifact: foo-1.2 | ||
| environment+: | ||
| # TODO: This downgraded because of the forced artifact priority | ||
| # change this when the repo priority is opt-in | ||
| EXPECTED_PACKAGE: foo-1.2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| summary: Pre-installed package present (non-verified) | ||
| description: | | ||
| System repo: foo-1.4 (baseline) | ||
| Pre-installed: foo-1.4 | ||
| Artifacts: foo-2.2 or foo-1.2 | ||
|
|
||
| Pre-installed package should be respected in this case | ||
|
|
||
| environment+: | ||
| PRE_INSTALLED_PACKAGE: rpms/foo-1.4/foo-1.4*.rpm | ||
|
|
||
| /upgrade: | ||
| summary: " (upgrading)" | ||
| context+: | ||
| available_artifact: foo-2.2 | ||
| environment+: | ||
| EXPECTED_PACKAGE: foo-1.4 | ||
|
|
||
| /downgrade: | ||
| summary: " (downgrading)" | ||
| context+: | ||
| available_artifact: foo-1.2 | ||
| environment+: | ||
| EXPECTED_PACKAGE: foo-1.4 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| summary: Baseline case | ||
| description: | | ||
| System repo: foo-1.4 (baseline) | ||
| Pre-installed: None | ||
| Artifacts: None | ||
|
|
||
| Normal installation case with no artifacts or anything special | ||
|
|
||
| environment+: | ||
| EXPECTED_PACKAGE: foo-1.4 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| discover: | ||
| - how: fmf | ||
| test: | ||
| - /test | ||
| prepare: | ||
| - name: Setup system | ||
| order: 20 | ||
| how: shell | ||
| script: | | ||
| # Prepare the system repo | ||
| mkdir system_repo | ||
| for pkg in $SYSTEM_PACKAGE; do | ||
| cp rpms/$pkg/*.rpm system_repo/ | ||
| done | ||
|
|
||
| # Running dnf/createrepo commands manually to bypass prepare/install handling | ||
| $DNF_CMD install -y createrepo | ||
| createrepo system_repo | ||
| cat > /etc/yum.repos.d/system-test-repo.repo <<EOF | ||
| [system-test-repo] | ||
| baseurl=file://$(pwd)/system_repo | ||
| gpgcheck=0 | ||
| EOF | ||
|
|
||
| # Install packages expected to be pre-installed (if any) | ||
| if [[ -n "$PRE_INSTALLED_PACKAGE" ]]; then | ||
| $DNF_CMD install -y $PRE_INSTALLED_PACKAGE | ||
| fi | ||
| - name: Main artifact to test and verify | ||
| order: 40 | ||
| how: artifact | ||
| provide: | ||
| - file:rpms/$@{verified_artifact}/*.rpm | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| verify: true | ||
| when: verified_artifact is defined | ||
| - name: Secondary artifacts made available (not verified) | ||
| order: 40 | ||
| how: artifact | ||
| provide: | ||
| - file:rpms/$@{available_artifact}/*.rpm | ||
| verify: false | ||
| when: available_artifact is defined | ||
|
|
||
| execute: | ||
| how: tmt | ||
|
|
||
| context: | ||
| want_devel: "false" | ||
| with_bar: "false" | ||
| xfail: "false" | ||
|
Comment on lines
+47
to
+50
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to lookup what |
||
|
|
||
| environment: | ||
| SYSTEM_PACKAGE: foo-1.4 | ||
| EXPECTED_PACKAGE: "" | ||
| PRE_INSTALLED_PACKAGE: "" | ||
| DNF_CMD: dnf | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume we will be also later testing wiht |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| summary: Newer version on system | ||
| description: | | ||
| System repo: foo-1.4 (baseline) | ||
| Pre-installed: foo-1.0 | ||
| Artifacts: None | ||
|
|
||
| `foo` is pre-installed but we do not really want to upgrade it. | ||
|
|
||
| environment+: | ||
| EXPECTED_PACKAGE: foo-1.0 | ||
| PRE_INSTALLED_PACKAGE: rpms/foo-1.0/foo-1.0*.rpm | ||
|
|
||
| /only-foo: | ||
| summary+: " (only foo requested)" | ||
|
|
||
| /with-bar: | ||
| summary+: " (foo and bar requested)" | ||
| description+: | | ||
| Installing another dependency (`bar`) should not upgrade `foo`. | ||
| context+: | ||
| with_bar: "true" | ||
| environment+: | ||
| SYSTEM_PACKAGE+: " bar" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /: | ||
| inherit: false | ||
|
|
||
| test: | | ||
| rpm -q $EXPECTED_PACKAGE | ||
| require: | ||
| - foo | ||
|
|
||
| adjust: | ||
| - when: want_devel == true | ||
| require: | ||
| - foo-devel | ||
| - when: with_bar == true | ||
| require+: | ||
| - bar | ||
| - when: xfail == true | ||
| result: xfail |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| summary: Basic case | ||
| description: | | ||
| System repo: foo-1.4 (baseline) | ||
| Pre-installed: None | ||
| Artifacts: foo-2.4 or foo-1.1 | ||
|
|
||
| Normal installation case with an artifact | ||
|
|
||
| /upgrade: | ||
| summary: " (upgrading)" | ||
| context+: | ||
| verified_artifact: foo-2.4 | ||
| environment+: | ||
| EXPECTED_PACKAGE: foo-2.4 | ||
|
|
||
| /downgrade: | ||
| summary: " (downgrading)" | ||
| context+: | ||
| verified_artifact: foo-1.1 | ||
| environment+: | ||
| EXPECTED_PACKAGE: foo-1.1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| summary: Pre-installed package present | ||
| description: | | ||
| System repo: foo-1.4 (baseline) | ||
| Pre-installed: foo-1.4 | ||
| Artifacts: foo-2.4 or foo-1.1 | ||
|
|
||
| Pre-installed package should be ignored in this case | ||
|
|
||
| environment+: | ||
| PRE_INSTALLED_PACKAGE: rpms/foo-1.4/foo-1.4*.rpm | ||
| context+: | ||
| # Because presence check gets in the way. | ||
| # It should fail at verify phase and test execution. | ||
| xfail: "true" | ||
|
|
||
| /upgrade: | ||
| summary: " (upgrading)" | ||
| context+: | ||
| verified_artifact: foo-2.4 | ||
| environment+: | ||
| EXPECTED_PACKAGE: foo-2.4 | ||
|
|
||
| /downgrade: | ||
| summary: " (downgrading)" | ||
| context+: | ||
| verified_artifact: foo-1.1 | ||
| environment+: | ||
| EXPECTED_PACKAGE: foo-1.1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| Name: foo | ||
| Version: 1.0 | ||
| Release: 1 | ||
| BuildArch: noarch | ||
| Summary: Main test package | ||
| License: none | ||
|
|
||
| %description | ||
| Pre-installed version, lower than current system package (foo-1.4) | ||
|
|
||
| %files | ||
|
|
||
| %package devel | ||
| Summary: Main test sub-package | ||
| Requires: foo-%{version} == %{version}-%{release} | ||
|
|
||
| %description devel | ||
| Version locked sub-package | ||
|
|
||
| %files devel |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| Name: foo | ||
| Version: 1.1 | ||
| Release: 1 | ||
| BuildArch: noarch | ||
| Summary: Main test package | ||
| License: none | ||
|
|
||
| # Arbitrary broken dependency at install time | ||
| Requires: some-non-existent-package | ||
|
|
||
| %description | ||
| Older version in verified artifacts (Broken) | ||
|
|
||
| %files | ||
|
|
||
| %package devel | ||
| Summary: Main test sub-package | ||
| Requires: foo-%{version} == %{version}-%{release} | ||
|
|
||
| %description devel | ||
| Version locked sub-package | ||
|
|
||
| %files devel |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| Name: foo | ||
| Version: 1.1 | ||
| Release: 1 | ||
| BuildArch: noarch | ||
| Summary: Main test package | ||
| License: none | ||
|
|
||
| %description | ||
| Older version in verified artifacts | ||
|
|
||
| %files | ||
|
|
||
| %package devel | ||
| Summary: Main test sub-package | ||
| Requires: foo-%{version} == %{version}-%{release} | ||
|
|
||
| %description devel | ||
| Version locked sub-package | ||
|
|
||
| %files devel |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| Name: foo | ||
| Version: 1.2 | ||
| Release: 1 | ||
| BuildArch: noarch | ||
| Summary: Main test package | ||
| License: none | ||
|
|
||
| # Arbitrary broken dependency at install time | ||
| Requires: some-non-existent-package | ||
|
|
||
| %description | ||
| Older version (not verified, Broken) | ||
|
|
||
| %files | ||
|
|
||
| %package devel | ||
| Summary: Main test sub-package | ||
| Requires: foo-%{version} == %{version}-%{release} | ||
|
|
||
| %description devel | ||
| Version locked sub-package | ||
|
|
||
| %files devel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Escape the
$in themktempcommand so that it is executed insiderlRun. This allowsrlRunto properly check the exit status ofmktempand report a failure if it fails.