Skip to content

Commit

Permalink
Enable history-undo.feature
Browse files Browse the repository at this point in the history
- dnf5 history list doesn't fill in actions: rpm-software-management/dnf5#1448
- Undoing install of dependecies that are not used by anything else is
  now described as `remove-unused`.
- There is a change in one `Altered` count because dnf4 doesn't
  count/list `Upgraded` and `Downgraded` actions. dnf5 on the other hand
  shows the `Replaced` action which is their equivalent.
  • Loading branch information
kontura committed Jun 11, 2024
1 parent 0fe4515 commit a4a81db
Showing 1 changed file with 110 additions and 69 deletions.
179 changes: 110 additions & 69 deletions dnf-behave-tests/dnf/history-undo.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@dnf5
Feature: Transaction history undo


Expand All @@ -9,17 +10,17 @@ Scenario: Undoing transactions
Given I successfully execute dnf with args "install filesystem"
Then History is following
| Id | Command | Action | Altered |
| 1 | install filesystem | Install | 2 |
| 1 | install filesystem | | 2 |
When I execute dnf with args "history undo last"
Then the exit code is 0
And Transaction is following
| Action | Package |
| remove-dep | setup-0:2.12.1-1.fc29.noarch |
| remove-unused | setup-0:2.12.1-1.fc29.noarch |
| remove | filesystem-0:3.9-2.fc29.x86_64 |
And History is following
| Id | Command | Action | Altered |
| 2 | | Removed | 2 |
| 1 | | Install | 2 |
| 2 | undo last | | 2 |
| 1 | install filesystem | | 2 |
When I execute dnf with args "history undo last"
Then the exit code is 0
And Transaction is following
Expand All @@ -28,21 +29,21 @@ Scenario: Undoing transactions
| install | filesystem-0:3.9-2.fc29.x86_64 |
And History is following
| Id | Command | Action | Altered |
| 3 | | Install | 2 |
| 2 | | Removed | 2 |
| 1 | | Install | 2 |
| 3 | undo last | | 2 |
| 2 | undo last | | 2 |
| 1 | install filesystem | | 2 |
When I execute dnf with args "history undo last-2"
Then the exit code is 0
And Transaction is following
| Action | Package |
| remove-dep | setup-0:2.12.1-1.fc29.noarch |
| remove-unused | setup-0:2.12.1-1.fc29.noarch |
| remove | filesystem-0:3.9-2.fc29.x86_64 |
And History is following
| Id | Command | Action | Altered |
| 4 | | Removed | 2 |
| 3 | | Install | 2 |
| 2 | | Removed | 2 |
| 1 | | Install | 2 |
| 4 | undo last-2 | | 2 |
| 3 | undo last | | 2 |
| 2 | undo last | | 2 |
| 1 | install filesystem | | 2 |


@1627111
Expand All @@ -62,17 +63,19 @@ Scenario: Handle missing packages required for undoing the transaction
| upgrade | flac-0:1.3.3-3.fc29.x86_64 |
| upgrade | wget-0:1.19.6-5.fc29.x86_64 |
And History is following
| Id | Command | Action | Altered |
| 2 | | Upgrade | 2 |
| 1 | | Install | 2 |
| Id | Command | Action | Altered |
| 2 | update | | 4 |
| 1 | install wget flac | | 2 |
Then I execute dnf with args "history undo 2"
Then the exit code is 1
And Transaction is empty
And stderr is
"""
Error: The following problems occurred while running a transaction:
Cannot find rpm nevra "flac-1.3.2-8.fc29.x86_64".
Cannot find rpm nevra "wget-1.19.5-5.fc29.x86_64".
Failed to resolve the transaction:
Cannot perform Install action, no match for: flac-1.3.2-8.fc29.x86_64.
Cannot perform Install action, no match for: wget-1.19.5-5.fc29.x86_64.
You can try to add to command line:
--skip-unavailable to skip unavailable packages
"""


Expand All @@ -96,9 +99,8 @@ Scenario: Missing packages are skipped if --skip-unavailable is specified
And Transaction is empty
And stderr is
"""
Warning, the following problems occurred while running a transaction:
Cannot find rpm nevra "flac-1.3.2-8.fc29.x86_64".
Cannot find rpm nevra "wget-1.19.5-5.fc29.x86_64".
Cannot perform Install action, no match for: flac-1.3.2-8.fc29.x86_64.
Cannot perform Install action, no match for: wget-1.19.5-5.fc29.x86_64.
"""


Expand All @@ -108,8 +110,11 @@ Scenario: Undo a transaction with a package that is no longer available
Then the exit code is 1
And stderr is
"""
Error: The following problems occurred while running a transaction:
Cannot find rpm nevra "filesystem-3.9-2.fc29.x86_64".
Failed to resolve the transaction:
Cannot perform Remove action because 'filesystem-3.9-2.fc29.x86_64' matches only excluded packages.
Problem: installed package filesystem-3.9-2.fc29.x86_64 requires setup, but none of the providers can be installed
- conflicting requests
- problem with installed package
"""


Expand All @@ -119,31 +124,32 @@ Scenario: Undoing a transaction with Reason Change
Given I successfully execute dnf with args "install filesystem"
Then History is following
| Id | Command | Action | Altered |
| 1 | install filesystem | Install | 2 |
| 1 | install filesystem | | 2 |
And package reasons are
| Package | Reason |
| filesystem-3.9-2.fc29.x86_64 | user |
| setup-2.12.1-1.fc29.noarch | dependency |
When I execute dnf with args "mark group filesystem"
| filesystem-3.9-2.fc29.x86_64 | User |
| setup-2.12.1-1.fc29.noarch | Dependency |
When I execute dnf with args "mark weak filesystem"
Then the exit code is 0
Then History is following
| Id | Command | Action | Altered |
| 2 | | Reason Change | 1 |
| 1 | install filesystem | Install | 2 |
| Id | Command | Action | Altered |
| 2 | mark weak filesystem | | 1 |
| 1 | install filesystem | | 2 |
And package reasons are
| Package | Reason |
| filesystem-3.9-2.fc29.x86_64 | group |
| setup-2.12.1-1.fc29.noarch | dependency |
| filesystem-3.9-2.fc29.x86_64 | Weak Dependency |
| setup-2.12.1-1.fc29.noarch | Dependency |
When I execute dnf with args "history undo last"
Then the exit code is 0
And History is following
| Id | Command | Action | Altered |
| 3 | | Reason Change | 1 |
| 2 | | Reason Change | 1 |
| 1 | | Install | 2 |
| Id | Command | Action | Altered |
| 3 | history undo last | | 1 |
| 2 | mark weak filesystem | | 1 |
| 1 | install filesystem | | 2 |
And package reasons are
| Package | Reason |
| filesystem-3.9-2.fc29.x86_64 | user |
| setup-2.12.1-1.fc29.noarch | dependency |
| filesystem-3.9-2.fc29.x86_64 | User |
| setup-2.12.1-1.fc29.noarch | Dependency |


@bz2010259
Expand All @@ -152,68 +158,103 @@ Scenario: Undoing an older transaction with Reason Change
Given I successfully execute dnf with args "install filesystem"
Then History is following
| Id | Command | Action | Altered |
| 1 | install filesystem | Install | 2 |
| 1 | install filesystem | | 2 |
And package reasons are
| Package | Reason |
| filesystem-3.9-2.fc29.x86_64 | user |
| setup-2.12.1-1.fc29.noarch | dependency |
When I execute dnf with args "mark group filesystem"
| filesystem-3.9-2.fc29.x86_64 | User |
| setup-2.12.1-1.fc29.noarch | Dependency |
When I execute dnf with args "mark weak filesystem"
Then History is following
| Id | Command | Action | Altered |
| 2 | | Reason Change | 1 |
| 1 | install filesystem | Install | 2 |
| 2 | mark weak filesystem | | 1 |
| 1 | install filesystem | | 2 |
And package reasons are
| Package | Reason |
| filesystem-3.9-2.fc29.x86_64 | group |
| setup-2.12.1-1.fc29.noarch | dependency |
| filesystem-3.9-2.fc29.x86_64 | Weak Dependency |
| setup-2.12.1-1.fc29.noarch | Dependency |
When I execute dnf with args "install wget"
Then the exit code is 0
When I execute dnf with args "history undo last-1"
Then the exit code is 0
And History is following
| Id | Command | Action | Altered |
| 4 | | Reason Change | 1 |
| 3 | | Install | 1 |
| 2 | | Reason Change | 1 |
| 1 | | Install | 2 |
| Id | Command | Action | Altered |
| 4 | history undo last-1 | | 1 |
| 3 | install wget | | 1 |
| 2 | mark weak filesystem | | 1 |
| 1 | install filesystem | | 2 |
And package reasons are
| Package | Reason |
| filesystem-3.9-2.fc29.x86_64 | user |
| setup-2.12.1-1.fc29.noarch | dependency |
| wget-1.19.5-5.fc29.x86_64 | user |
| filesystem-3.9-2.fc29.x86_64 | User |
| setup-2.12.1-1.fc29.noarch | Dependency |
| wget-1.19.5-5.fc29.x86_64 | User |


@xfail
@bz2010259
@bz2053014
Scenario: Undoing a transaction range with Reason Change
Given I successfully execute dnf with args "install filesystem"
Then History is following
| Id | Command | Action | Altered |
| 1 | install filesystem | Install | 2 |
| 1 | install filesystem | | 2 |
And package reasons are
| Package | Reason |
| filesystem-3.9-2.fc29.x86_64 | user |
| setup-2.12.1-1.fc29.noarch | dependency |
When I execute dnf with args "mark group filesystem"
| filesystem-3.9-2.fc29.x86_64 | User |
| setup-2.12.1-1.fc29.noarch | Dependency |
When I execute dnf with args "mark weak filesystem"
Then History is following
| Id | Command | Action | Altered |
| 2 | | Reason Change | 1 |
| 1 | install filesystem | Install | 2 |
| 2 | mark weak filesystem | | 1 |
| 1 | install filesystem | | 2 |
And package reasons are
| Package | Reason |
| filesystem-3.9-2.fc29.x86_64 | group |
| setup-2.12.1-1.fc29.noarch | dependency |
| filesystem-3.9-2.fc29.x86_64 | Weak Dependency |
| setup-2.12.1-1.fc29.noarch | Dependency |
When I execute dnf with args "install wget"
Then the exit code is 0
When I execute dnf with args "history rollback 1"
Then the exit code is 0
And History is following
| Id | Command | Action | Altered |
| 4 | | C, E | 2 |
| 3 | | Install | 1 |
| 2 | | Reason Change | 1 |
| 1 | | Install | 2 |
| Id | Command | Action | Altered |
| 4 | history rollback 1 | | 2 |
| 3 | install wget | | 1 |
| 2 | mark weak filesystem | | 1 |
| 1 | install filesystem | | 2 |
And package reasons are
| Package | Reason |
| filesystem-3.9-2.fc29.x86_64 | user |
| setup-2.12.1-1.fc29.noarch | dependency |
| filesystem-3.9-2.fc29.x86_64 | User |
| setup-2.12.1-1.fc29.noarch | Dependency |


Scenario: Undo a downgrade transaction
Given I use repository "dnf-ci-fedora-updates"
And I successfully execute dnf with args "install wget"
And I successfully execute dnf with args "downgrade wget"
When I execute dnf with args "history undo last"
Then the exit code is 0
And Transaction is following
| Action | Package |
| upgrade | wget-0:1.19.6-5.fc29.x86_64 |
And stderr is
"""
Warning: skipped PGP checks for 1 package from repository: dnf-ci-fedora-updates
"""


Scenario: Undo an upgrade transaction with --skip-unavailable where the orignal package is not available
Given I successfully execute dnf with args "install wget"
And I use repository "dnf-ci-fedora-updates"
And I successfully execute dnf with args "upgrade wget"
And I drop repository "dnf-ci-fedora"
When I execute dnf with args "history undo last --skip-unavailable"
Then the exit code is 0
And Transaction is empty
And stdout is
"""
<REPOSYNC>
Nothing to do.
"""
And stderr is
"""
Cannot perform Install action, no match for: wget-1.19.5-5.fc29.x86_64.
"""

0 comments on commit a4a81db

Please sign in to comment.