Skip to content
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

Enable and update help and history-* features #1622

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 28 additions & 103 deletions dnf-behave-tests/dnf/help.feature
Original file line number Diff line number Diff line change
@@ -1,118 +1,43 @@
@dnf5
Feature: Help command

Scenario: General help (dnf)
Given I set dnf command to "dnf"
When I execute dnf with args "--help"
Then the exit code is 0
And stdout contains "List of Main Commands"
When I execute dnf with args "--unknown-option"
Then the exit code is 0
And stdout contains "List of Main Commands"
When I execute dnf with args "help"
Then the exit code is 0
And stdout contains "List of Main Commands"
When I execute dnf with args "unknown-command"
Then the exit code is 1
And stderr is
"""
No such command: unknown-command. Please use /usr/bin/dnf --help
It could be a DNF plugin command, try: "dnf install 'dnf-command(unknown-command)'"
"""

Scenario: General help (yum)
Given I set dnf command to "yum"
Scenario: General help
When I execute dnf with args "--help"
Then the exit code is 0
And stdout contains "List of Main Commands"
And stdout contains "Software Management Commands"
When I execute dnf with args "--unknown-option"
Then the exit code is 0
And stdout contains "List of Main Commands"
Then the exit code is 2
And stdout is empty
And stderr is
"""
Unknown argument "--unknown-option" for command "dnf5". Add "--help" for more information about the arguments.
"""
When I execute dnf with args "help"
Then the exit code is 0
And stdout contains "List of Main Commands"
Then the exit code is 2
And stdout is empty
And stderr is
"""
Unknown argument "help" for command "dnf5". Add "--help" for more information about the arguments.
It could be a command provided by a plugin, try: dnf5 install 'dnf5-command(help)'
"""
When I execute dnf with args "unknown-command"
Then the exit code is 1
Then the exit code is 2
And stdout is empty
And stderr is
"""
No such command: unknown-command. Please use /usr/bin/yum --help
It could be a YUM plugin command, try: "yum install 'dnf-command(unknown-command)'"
"""
"""
Unknown argument "unknown-command" for command "dnf5". Add "--help" for more information about the arguments.
It could be a command provided by a plugin, try: dnf5 install 'dnf5-command(unknown-command)'
"""


Scenario: Command help
When I execute dnf with args "help install"
Then the exit code is 0
And stdout contains "usage: .+ install"
When I execute dnf with args "install --help"
Then the exit code is 0
And stdout contains "usage: .+ install"
And stdout contains "dnf5 \[GLOBAL OPTIONS\] install \[OPTIONS\] \[ARGUMENTS\]"
When I execute dnf with args "install --unknown-option"
Then the exit code is 2
And stderr contains ".+ install: err"

@bz1746474
@use.with_os=rhel__ge__8
@use.with_os=centos__ge__8
@use.with_os=fedora__ge__30
@use.with_os=fedora__lt__30
Scenario Outline: Help should refer to yum/dnf depending on what command was used
When I execute "<command> <args>"
Then the exit code is 0
And stdout contains "usage: <help>"

Examples:
| command | args | help |
| dnf | help | dnf \[options] COMMAND |
| dnf | --help | dnf \[options] COMMAND |
| dnf-3 | help | dnf \[options] COMMAND |
| dnf-3 | --help | dnf \[options] COMMAND |
| yum | help | yum \[options] COMMAND |
| yum | --help | yum \[options] COMMAND |
| yum-builddep | --help | dnf builddep \[-c \[config file]] \[-q] \[-v] \[--version] |
| yum shell | --help | yum shell \[-c \[config file]] \[-q] \[-v] \[--version] |

@bz1746474
@use.with_os=rhel__ge__8
@use.with_os=centos__ge__8
@use.with_os=fedora__ge__30
@use.with_os=fedora__lt__30
Scenario Outline: Help should refer to yum/dnf depending on what command was used
When I execute "<command> <args>"
Then the exit code is 0
And stdout contains "<help>"

Examples:
| command | args | help |
| dnf builddep | --help | General DNF options: |
| yum builddep | --help | General YUM options: |
| yum-builddep | --help | General DNF options: |
| yum shell | --help | run an interactive YUM shell |
| dnf shell | --help | run an interactive DNF shell |
| yum alias | --help | show YUM version and exit |
| dnf alias | --help | show DNF version and exit |
| yum alias | --help | enables yum's obsoletes processing logic for upgrade |
| dnf alias | --help | enables dnf's obsoletes processing logic for upgrade |
| yum deplist | --help | Display only packages that can be removed by "yum |
| dnf deplist | --help | Display only packages that can be removed by "dnf |
| yum repoquery | --help | Display only packages that can be removed by "yum |
| dnf repoquery | --help | Display only packages that can be removed by "dnf |
| yum swap | --help | run an interactive YUM mod for remove and install one spec |
| dnf swap | --help | run an interactive DNF mod for remove and install one spe |
| yum config-manager | --help | manage yum configuration options and repositories |
| dnf config-manager | --help | manage dnf configuration options and repositories |

@use.with_os=rhel__eq__7
@use.with_os=centos__eq__7
@xfail
Scenario Outline: Help should refer to yum4/dnf depending on what command was used
When I execute "<command> <args>"
Then the exit code is 0
And stdout contains "usage: <command>"

Examples:
| command | args |
| dnf | help |
| dnf | --help |
| dnf-2 | help |
| dnf-2 | --help |
| yum4 | help |
| yum4 | --help |
And stderr is
"""
Unknown argument "--unknown-option" for command "install". Add "--help" for more information about the arguments.
"""
48 changes: 21 additions & 27 deletions dnf-behave-tests/dnf/history-error.feature
Original file line number Diff line number Diff line change
@@ -1,84 +1,78 @@
@dnf5
Feature: Handling of errors on the history database

Background:
Given I use repository "dnf-ci-fedora"


Scenario: history list on a broken history database
Given I create file "/var/lib/dnf/history.sqlite" with
Given I create file "/usr/lib/sysimage/libdnf5/transaction_history.sqlite" with
"""
GARBAGE
"""
When I execute dnf with args "history filesystem"
When I execute dnf with args "history list"
Then the exit code is 1
And stderr is
"""
History database is not writable: SQLite error on "{context.dnf.installroot}/var/lib/dnf/history.sqlite": Executing an SQL statement failed: file is not a database
Error: SQLite error on "{context.dnf.installroot}/var/lib/dnf/history.sqlite": Executing an SQL statement failed: file is not a database
SQL statement execution failed: "PRAGMA locking_mode = NORMAL; PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON;": (26) - file is not a database
"""


Scenario: install with a broken history database
Given I use repository "dnf-ci-fedora"
And I create file "/var/lib/dnf/history.sqlite" with
And I create file "/usr/lib/sysimage/libdnf5/transaction_history.sqlite" with
"""
GARBAGE
"""
When I execute dnf with args "install filesystem"
Then the exit code is 1
And stderr is
"""
History database is not writable: SQLite error on "{context.dnf.installroot}/var/lib/dnf/history.sqlite": Executing an SQL statement failed: file is not a database
History database is not writable: SQLite error on "{context.dnf.installroot}/var/lib/dnf/history.sqlite": Executing an SQL statement failed: file is not a database
Error: SQLite error on "{context.dnf.installroot}/var/lib/dnf/history.sqlite": Executing an SQL statement failed: file is not a database
"""
And stderr contains "SQL statement execution failed: "PRAGMA locking_mode = NORMAL; PRAGMA journal_mode = WAL; PRAGMA foreign_keys = ON;": \(26\) - file is not a database"


@bz1634385
@no_installroot
Scenario: history database not present under a regular user, who has write permission
Given I successfully execute "chmod o+rwx {context.dnf.tempdir}"
When I execute dnf with args "--setopt=persistdir={context.dnf.tempdir} repoquery --userinstalled" as an unprivileged user
When I execute dnf with args "--setopt=system_state_dir={context.dnf.tempdir} history list" as an unprivileged user
Then the exit code is 0
And stderr is empty
And file "{context.dnf.tempdir}/history.sqlite" exists
And stdout is empty
And file "{context.dnf.tempdir}/transaction_history.sqlite" exists


@bz1634385
@no_installroot
Scenario: history database not present under a regular user
When I execute dnf with args "--setopt=persistdir={context.dnf.tempdir} repoquery --userinstalled" as an unprivileged user
Then the exit code is 0
When I execute dnf with args "--setopt=system_state_dir={context.dnf.tempdir} history list" as an unprivileged user
Then the exit code is 1
And stderr is
"""
History database is not readable, using in-memory database instead: Failed to access "{context.dnf.tempdir}/history.sqlite": Permission denied
Failed to open database "{context.dnf.tempdir}/transaction_history.sqlite": (14) - unable to open database file
"""


@bz1761976
@no_installroot
Scenario: read permission error on the history database
Given I successfully execute dnf with args "--setopt=persistdir={context.dnf.tempdir} install abcde"
And I successfully execute "chmod o-r {context.dnf.tempdir}/history.sqlite"
When I execute dnf with args "--setopt=persistdir={context.dnf.tempdir} history abcde" as an unprivileged user
Then the exit code is 0
Given I successfully execute dnf with args "--setopt=system_state_dir={context.dnf.tempdir} install abcde"
And I successfully execute "chmod o-r {context.dnf.tempdir}/transaction_history.sqlite"
When I execute dnf with args "--setopt=system_state_dir={context.dnf.tempdir} history list" as an unprivileged user
Then the exit code is 1
And stderr is
"""
History database is not readable, using in-memory database instead: Failed to access "{context.dnf.tempdir}/history.sqlite": Permission denied
History database is not readable, using in-memory database instead: Failed to access "{context.dnf.tempdir}/history.sqlite": Permission denied
Failed to open database "{context.dnf.tempdir}/transaction_history.sqlite": (14) - unable to open database file
"""


@bz1761976
@no_installroot
Scenario: read permission error on the history database directory
Given I successfully execute dnf with args "--setopt=persistdir={context.dnf.tempdir} install abcde"
Given I successfully execute dnf with args "--setopt=system_state_dir={context.dnf.tempdir} install abcde"
# executable permission on directory means its contents can't be read
And I successfully execute "chmod o-x {context.dnf.tempdir}"
When I execute dnf with args "--setopt=persistdir={context.dnf.tempdir} history abcde" as an unprivileged user
Then the exit code is 0
When I execute dnf with args "--setopt=system_state_dir={context.dnf.tempdir} history list" as an unprivileged user
Then the exit code is 1
And stderr is
"""
History database is not readable, using in-memory database instead: Failed to access "{context.dnf.tempdir}/history.sqlite": Permission denied
History database is not readable, using in-memory database instead: Failed to access "{context.dnf.tempdir}/history.sqlite": Permission denied
Failed to open database "{context.dnf.tempdir}/transaction_history.sqlite": (14) - unable to open database file
"""
Loading
Loading