From 511ce1403bdabd3d41e667c044771fe555b812ca Mon Sep 17 00:00:00 2001 From: Eva Mrakova Date: Thu, 12 Oct 2023 11:17:10 +0200 Subject: [PATCH] update tests for 'dnf5 mark' --- dnf-behave-tests/dnf/mark-install.feature | 49 ----- dnf-behave-tests/dnf/mark-remove.feature | 24 --- dnf-behave-tests/dnf/mark.feature | 251 ++++++++++++++++++++++ 3 files changed, 251 insertions(+), 73 deletions(-) delete mode 100644 dnf-behave-tests/dnf/mark-install.feature delete mode 100644 dnf-behave-tests/dnf/mark-remove.feature create mode 100644 dnf-behave-tests/dnf/mark.feature diff --git a/dnf-behave-tests/dnf/mark-install.feature b/dnf-behave-tests/dnf/mark-install.feature deleted file mode 100644 index 2ec82ac2a..000000000 --- a/dnf-behave-tests/dnf/mark-install.feature +++ /dev/null @@ -1,49 +0,0 @@ -Feature: Mark install - - -# @dnf5 -# TODO(nsella) Unknown argument "mark" for command "microdnf" -Scenario: Marking non-existing package for fails - Given I use repository "dnf-ci-fedora" - When I execute dnf with args "mark install i-dont-exist" - Then the exit code is 1 - - -# @dnf5 -# TODO(nsella) Unknown argument "mark" for command "microdnf" -Scenario: Marking dependency as user-installed should not remove it automatically - Given I use repository "dnf-ci-fedora" - When I execute dnf with args "install filesystem" - Then the exit code is 0 - And Transaction is following - | Action | Package | - | install | filesystem-0:3.9-2.fc29.x86_64 | - | install-dep | setup-0:2.12.1-1.fc29.noarch | - When I execute dnf with args "mark install setup" - Then the exit code is 0 - When I execute dnf with args "remove filesystem" - Then the exit code is 0 - And Transaction is following - | Action | Package | - | remove | filesystem-0:3.9-2.fc29.x86_64 | - | unchanged | setup-0:2.12.1-1.fc29.noarch | - When I execute dnf with args "remove setup" - Then the exit code is 0 - And Transaction is following - | Action | Package | - | remove | setup-0:2.12.1-1.fc29.noarch | - -# @dnf5 -# TODO(nsella) Unknown argument "--qf" for command "repoquery" -@bz2046581 -Scenario: Marking installed package when history DB is not on the system (deleted or not created yet) - When I execute rpm with args "-i {context.dnf.fixturesdir}/repos/dnf-ci-fedora-updates/x86_64/wget-1.19.6-5.fc29.x86_64.rpm" - Then the exit code is 0 - And package reasons are - | Package | Reason | - | wget-1.19.6-5.fc29.x86_64 | unknown | - When I execute dnf with args "mark install wget" - Then the exit code is 0 - And package reasons are - | Package | Reason | - | wget-1.19.6-5.fc29.x86_64 | user | diff --git a/dnf-behave-tests/dnf/mark-remove.feature b/dnf-behave-tests/dnf/mark-remove.feature deleted file mode 100644 index 372e18202..000000000 --- a/dnf-behave-tests/dnf/mark-remove.feature +++ /dev/null @@ -1,24 +0,0 @@ -@dnf5 -Feature: Mark dependency - -Scenario: Marking toplevel package as dependency should not remove shared dependencies on autoremove - Given I use repository "dnf-ci-fedora" - When I execute dnf with args "install nss_hesiod libnsl" - Then the exit code is 0 - And Transaction is following - | Action | Package | - | install | libnsl-0:2.28-9.fc29.x86_64 | - | install | nss_hesiod-0:2.28-9.fc29.x86_64 | - | install-dep | setup-0:2.12.1-1.fc29.noarch | - | install-dep | filesystem-0:3.9-2.fc29.x86_64 | - | install-dep | basesystem-0:11-6.fc29.noarch | - | install-dep | glibc-0:2.28-9.fc29.x86_64 | - | install-dep | glibc-common-0:2.28-9.fc29.x86_64 | - | install-dep | glibc-all-langpacks-0:2.28-9.fc29.x86_64 | - When I execute dnf with args "mark dependency libnsl" - Then the exit code is 0 - When I execute dnf with args "autoremove" - Then the exit code is 0 - And Transaction is following - | Action | Package | - | remove | libnsl-0:2.28-9.fc29.x86_64 | diff --git a/dnf-behave-tests/dnf/mark.feature b/dnf-behave-tests/dnf/mark.feature new file mode 100644 index 000000000..b0f2c492c --- /dev/null +++ b/dnf-behave-tests/dnf/mark.feature @@ -0,0 +1,251 @@ +Feature: Mark command + + +@dnf5 +Scenario Outline: Marking non-existent package as fails + Given I use repository "dnf-ci-fedora" + When I execute dnf with args "mark nosuchpkg" + Then the exit code is 1 + And stderr is + """ + Failed to resolve the transaction: + No match for argument: nosuchpkg + """ + +Examples: + | type | + | user | + | dependency | + | weak | + + +@dnf5 +Scenario: Marking as group for non-existent package or non-existent group fails + Given I use repository "dnf-ci-thirdparty" + And I use repository "dnf-ci-fedora" + When I execute dnf with args "mark group dnf-ci-testgroup nosuchpkg" + Then the exit code is 1 + And stderr is + """ + Failed to resolve the transaction: + No match for argument: nosuchpkg + """ + When I execute dnf with args "install lame" + And I execute dnf with args "mark group nosuchgrp lame" + Then the exit code is 1 + And stderr is + """ + Group state for "nosuchgrp" not found. + """ + + +@dnf5 +Scenario: Marking available but not installed package fails + Given I use repository "dnf-ci-fedora" + When I execute dnf with args "mark user lame" + Then the exit code is 1 + And stderr is + """ + Failed to resolve the transaction: + No match for argument: lame + """ + + +@dnf5 +Scenario: Marking as dependency a list of pkgs when one of them is not available fails + Given I use repository "dnf-ci-fedora" + When I execute dnf with args "install lame" + And I execute dnf with args "mark dependency lame nosuchpkg" + Then the exit code is 1 + And package reasons are + | Package | Reason | + | lame-3.100-4.fc29.x86_64 | user | + And stderr is + """ + Failed to resolve the transaction: + No match for argument: nosuchpkg + """ + + +@dnf5 +Scenario: Marking as dependency a list of pkgs when one of them is not available passes with --skip-unavailable + Given I use repository "dnf-ci-fedora" + When I execute dnf with args "install lame" + And I execute dnf with args "mark --skip-unavailable dependency lame nosuchpkg" + Then the exit code is 0 + And package reasons are + | Package | Reason | + | lame-3.100-4.fc29.x86_64 | dependency | + And stderr is + """ + No match for argument: nosuchpkg + """ + + +@dnf5 +Scenario Outline: Mark user installed package as + Given I use repository "dnf-ci-fedora" + When I execute dnf with args "install lame" + Then the exit code is 0 + When I execute dnf with args "mark lame" + Then the exit code is 0 + And package reasons are + | Package | Reason | + | lame-3.100-4.fc29.x86_64 | | + +Examples: + | type | + | dependency | + | weak | + + +@dnf5 +Scenario Outline: Mark package installed as dependency as + Given I use repository "dnf-ci-fedora" + When I execute dnf with args "install filesystem" + Then the exit code is 0 + And package reasons are + | Package | Reason | + | filesystem-0:3.9-2.fc29.x86_64 | user | + | setup-0:2.12.1-1.fc29.noarch | dependency | + When I execute dnf with args "mark setup" + Then the exit code is 0 + And package reasons are + | Package | Reason | + | setup-0:2.12.1-1.fc29.noarch | | + +Examples: + | type | + | user | + | weak | + + +@dnf5 +Scenario: Mark package as the same reason it currently has + Given I use repository "dnf-ci-fedora" + When I execute dnf with args "install lame" + Then the exit code is 0 + And package reasons are + | Package | Reason | + | lame-3.100-4.fc29.x86_64 | user | + When I execute dnf with args "mark user lame" + Then the exit code is 0 + And stdout is + """ + + Nothing to do. + """ + And stderr is + """ + Package "lame-3.100-4.fc29.x86_64" is already installed with reason "User". + """ + + +@dnf5 +Scenario: Mark user installed package as group + Given I use repository "dnf-ci-thirdparty" + And I use repository "dnf-ci-fedora" + When I execute dnf with args "install lame" + And I execute dnf with args "group install dnf-ci-testgroup" + Then the exit code is 0 + And package reasons are + | Package | Reason | + | lame-3.100-4.fc29.x86_64 | user | + When I execute dnf with args "mark group dnf-ci-testgroup lame" + Then the exit code is 0 + And package reasons are + | Package | Reason | + | lame-3.100-4.fc29.x86_64 | group | + + +#@dnf5 currently fails, see: +# https://github.com/rpm-software-management/dnf5/issues/935 +# TODO (emrakova): update the scenario when the issue is fixed +Scenario: Mark group installed package as user and back again + Given I use repository "dnf-ci-thirdparty" + And I use repository "dnf-ci-fedora" + And I execute dnf with args "group install dnf-ci-testgroup" + Then the exit code is 0 + And package reasons are + | Package | Reason | + | lame-3.100-4.fc29.x86_64 | group | + When I execute dnf with args "mark user lame" + Then the exit code is 0 + And package reasons are + | Package | Reason | + | lame-3.100-4.fc29.x86_64 | user | + When I execute dnf with args "mark group dnf-ci-testgroup lame" + Then the exit code is 0 + And package reasons are + | Package | Reason | + | lame-3.100-4.fc29.x86_64 | group | + When I execute dnf with args "mark group dnf-ci-testgroup lame" + Then the exit code is 0 + And stdout does not contain "User -> Group" + And stderr is + """ + Package "lame-3.100-4.fc29.x86_64" is already installed with reason "Group". + """ + + +@dnf5 +Scenario: Marking dependency as user-installed should not remove it automatically + Given I use repository "dnf-ci-fedora" + When I execute dnf with args "install filesystem" + Then the exit code is 0 + And Transaction is following + | Action | Package | + | install | filesystem-0:3.9-2.fc29.x86_64 | + | install-dep | setup-0:2.12.1-1.fc29.noarch | + When I execute dnf with args "mark user setup" + Then the exit code is 0 + When I execute dnf with args "remove filesystem" + Then the exit code is 0 + And Transaction is following + | Action | Package | + | remove | filesystem-0:3.9-2.fc29.x86_64 | + | unchanged | setup-0:2.12.1-1.fc29.noarch | + When I execute dnf with args "remove setup" + Then the exit code is 0 + And Transaction is following + | Action | Package | + | remove | setup-0:2.12.1-1.fc29.noarch | + + +@dnf5 +@bz2046581 +Scenario: Marking installed package when history DB is not on the system (deleted or not created yet) + When I execute rpm with args "-i {context.dnf.fixturesdir}/repos/dnf-ci-fedora-updates/x86_64/wget-1.19.6-5.fc29.x86_64.rpm" + Then the exit code is 0 + And package reasons are + | Package | Reason | + | wget-1.19.6-5.fc29.x86_64 | unknown | + When I execute dnf with args "mark user wget" + Then the exit code is 0 + And package reasons are + | Package | Reason | + | wget-1.19.6-5.fc29.x86_64 | user | + + +@dnf5 +Scenario: Marking toplevel package as dependency should not remove shared dependencies on autoremove + Given I use repository "dnf-ci-fedora" + When I execute dnf with args "install nss_hesiod libnsl" + Then the exit code is 0 + And Transaction is following + | Action | Package | + | install | libnsl-0:2.28-9.fc29.x86_64 | + | install | nss_hesiod-0:2.28-9.fc29.x86_64 | + | install-dep | setup-0:2.12.1-1.fc29.noarch | + | install-dep | filesystem-0:3.9-2.fc29.x86_64 | + | install-dep | basesystem-0:11-6.fc29.noarch | + | install-dep | glibc-0:2.28-9.fc29.x86_64 | + | install-dep | glibc-common-0:2.28-9.fc29.x86_64 | + | install-dep | glibc-all-langpacks-0:2.28-9.fc29.x86_64 | + When I execute dnf with args "mark dependency libnsl" + Then the exit code is 0 + When I execute dnf with args "autoremove" + Then the exit code is 0 + And Transaction is following + | Action | Package | + | remove | libnsl-0:2.28-9.fc29.x86_64 |