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

dnf5 config-manager: Sync w upstream - Add repoid to gener repo name, test warning messages #1429

Merged
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
20 changes: 10 additions & 10 deletions dnf-behave-tests/dnf/plugins-core/config-manager-addrepo.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Scenario: test "addrepo" from "baseurl", "enabled=1" is set by default
And file "/etc/yum.repos.d/something.com_os_.repo" contents is
"""
[something.com_os_]
name=created by dnf5 config-manager
name=something.com_os_ - Created by dnf5 config-manager
enabled=1
baseurl=http://something.com/os/
"""
Expand All @@ -30,7 +30,7 @@ Scenario: test "addrepo" from "baseurl" with user defined repository id (--id=)
And file "/etc/yum.repos.d/test.repo" contents is
"""
[test]
name=created by dnf5 config-manager
name=test - Created by dnf5 config-manager
enabled=1
baseurl=http://something.com/os/
"""
Expand All @@ -42,7 +42,7 @@ Scenario: test "addrepo" from "baseurl" with user defined destination file name
And file "/etc/yum.repos.d/test.repo" contents is
"""
[something.com_os_]
name=created by dnf5 config-manager
name=something.com_os_ - Created by dnf5 config-manager
enabled=1
baseurl=http://something.com/os/
"""
Expand All @@ -54,7 +54,7 @@ Scenario: "addrepo" from "baseurl" with user defined destination file name, test
And file "/etc/yum.repos.d/test.repo" contents is
"""
[something.com_os_]
name=created by dnf5 config-manager
name=something.com_os_ - Created by dnf5 config-manager
enabled=1
baseurl=http://something.com/os/
"""
Expand All @@ -72,7 +72,7 @@ Scenario: test "addrepo" from "baseurl", set more options
And file "/etc/yum.repos.d/something.com_os_.repo" contents is
"""
[something.com_os_]
name=created by dnf5 config-manager
name=something.com_os_ - Created by dnf5 config-manager
enabled=1
baseurl=http://something.com/os/
gpgcheck=1
Expand All @@ -86,7 +86,7 @@ Scenario: test "addrepo" from "baseurl", set option multiple times with the same
And file "/etc/yum.repos.d/something.com_os_.repo" contents is
"""
[something.com_os_]
name=created by dnf5 config-manager
name=something.com_os_ - Created by dnf5 config-manager
enabled=1
baseurl=http://something.com/os/
gpgcheck=1
Expand Down Expand Up @@ -126,7 +126,7 @@ Scenario: test "addrepo" from "baseurl", destination directory does not exist, "
And file "/etc/yum.repos.d/test.repo" contents is
"""
[test]
name=created by dnf5 config-manager
name=test - Created by dnf5 config-manager
enabled=1
baseurl=http://something.com/os/
"""
Expand Down Expand Up @@ -171,7 +171,7 @@ Scenario: test "addrepo" from "baseurl", overwrite existing repo file (--overwri
And file "/etc/yum.repos.d/repo1.repo" contents is
"""
[repo1]
name=created by dnf5 config-manager
name=repo1 - Created by dnf5 config-manager
enabled=1
baseurl=http://something.com/os/
"""
Expand All @@ -188,7 +188,7 @@ Scenario: test "addrepo" from "baseurl", add repo to existing file (--add-or-rep
enabled=1
baseurl=http://something1.com/os/
[test]
name=created by dnf5 config-manager
name=test - Created by dnf5 config-manager
enabled=1
baseurl=http://something.com/os/
"""
Expand All @@ -201,7 +201,7 @@ Scenario: test "addrepo" from "baseurl", replace repo in existing file (--add-or
And file "/etc/yum.repos.d/repo1.repo" contents is
"""
[repo1]
name=created by dnf5 config-manager
name=repo1 - Created by dnf5 config-manager
enabled=1
baseurl=http://something.com/os/
"""
Expand Down
113 changes: 111 additions & 2 deletions dnf-behave-tests/dnf/plugins-core/config-manager-opts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,28 @@ Scenario: unset/remove an main option
"""


Scenario: unset/remove an main option, trying to unset an not set option is OK
Scenario: unset/remove unsupported main option is OK, but a warning is written
Given I create file "/etc/dnf/dnf.conf" with
"""
[main]
best=True
unsupported=1
skip_unavailable=True
"""
When I execute dnf with args "config-manager unsetopt best unsupported"
Then the exit code is 0
And file "/etc/dnf/dnf.conf" contents is
"""
[main]
skip_unavailable=True
"""
And stderr is
"""
config-manager: Request to remove unsupported main option: unsupported
"""


Scenario: unset/remove an main option, trying to unset an not set option is OK, but a warning is written
Given I create file "/etc/dnf/dnf.conf" with
"""
[main]
Expand All @@ -144,6 +165,20 @@ Scenario: unset/remove an main option, trying to unset an not set option is OK
[main]
skip_unavailable=True
"""
And stderr is
"""
config-manager: Request to remove main option but it is not present in the config file: installroot
"""


Scenario: trying to unset an not set main option (config file is not found) is OK, but a warning is written
Given I delete file "/etc/dnf/dnf.conf"
When I execute dnf with args "config-manager unsetopt best"
Then the exit code is 0
And stderr is
"""
config-manager: Request to remove main option but config file not found: {context.dnf.installroot}/etc/dnf/dnf.conf
"""
Comment on lines +174 to +181
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what changed, but this scenario fails for me now. The problem is that dnf5 always fails with "Configuration file {config_path} not found" when the config file path is provided on the cli, which is also the case for the ci-dnf-stack tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pkratoch It passed the tests locally on my PC. But you're right. If CI stack runs tests with config file path on cli it should fail. I have to look into it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pkratoch
I looked into it. Why does it pass in local CI? And I saw the command:
dnf5 -y --installroot=/tmp/dnf_ci_installroot_q04aelti --releasever=29 --setopt=module_platform_id=platform:f29 --disableplugin='*' config-manager unsetopt best

This means that the path to the configuration file is not provided on the cli. And that's why it goes right.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. The problem is in the CI stack in the get_dnf5_cmd method.
Compared to get_dnf4_cmd, it adds:

result.append("--setopt=reposdir=%s" % self.installroot + "/etc/yum.repos.d")
result.append("--setopt=config_file_path=%s" % self.installroot + "/etc/dnf/dnf.conf")
result.append("--setopt=cachedir=%s" % self.installroot + "/var/cache/dnf")

I started CI tests without --tags=dnf5, so get_dnf4_cmd was used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests pass with the change #1467



Scenario: repository configuration overrides - new option to "repo1"
Expand Down Expand Up @@ -321,7 +356,68 @@ Scenario: repository configuration overrides - unset/remove option, globs in rep
"""


Scenario: repository configuration overrides - unset/remove option, trying to unset an not set option is OK
Scenario: repository configuration overrides - unset/remove unsupported option is OK, but a warning is written
Given I create file "/etc/dnf/repos.override.d/99-config_manager.repo" with
"""
[repo1]
enabled=0
unsupported=1
priority=40
skip_if_unavailable=1
[repo2]
enabled=1
priority=50
skip_if_unavailable=0
"""
When I execute dnf with args "config-manager unsetopt repo1.unsupported repo1.priority"
Then the exit code is 0
And file "/etc/dnf/repos.override.d/99-config_manager.repo" contents is
"""
[repo1]
enabled=0
skip_if_unavailable=1
[repo2]
enabled=1
priority=50
skip_if_unavailable=0
"""
And stderr is
"""
config-manager: Request to remove unsupported repository option: repo1.unsupported
"""


Scenario: repository configuration overrides - unset/remove option, repoid not in overrides is OK, but a warning is written
Given I create file "/etc/dnf/repos.override.d/99-config_manager.repo" with
"""
[repo1]
enabled=0
priority=40
skip_if_unavailable=1
[repo2]
enabled=1
priority=50
skip_if_unavailable=0
"""
When I execute dnf with args "config-manager unsetopt test_repo.priority repo1.priority"
Then the exit code is 0
And file "/etc/dnf/repos.override.d/99-config_manager.repo" contents is
"""
[repo1]
enabled=0
skip_if_unavailable=1
[repo2]
enabled=1
priority=50
skip_if_unavailable=0
"""
And stderr is
"""
config-manager: Request to remove repository option but repoid is not present in the overrides: test_repo
"""


Scenario: repository configuration overrides - unset/remove option, trying to unset an not set option is OK, but a warning is written
Given I create file "/etc/dnf/repos.override.d/99-config_manager.repo" with
"""
[repo1]
Expand All @@ -345,6 +441,19 @@ Scenario: repository configuration overrides - unset/remove option, trying to un
priority=50
skip_if_unavailable=0
"""
And stderr is
"""
config-manager: Request to remove repository option but it is not present in the overrides: repo1.cost
"""


Scenario: repository configuration overrides - unset/remove option, no file with overrides found is OK, but a warning is written
When I execute dnf with args "config-manager unsetopt repo1.cost"
Then the exit code is 0
And stderr is
"""
config-manager: Request to remove repository option but file with overrides not found: {context.dnf.installroot}/etc/dnf/repos.override.d/99-config_manager.repo
"""


Scenario: repository configuration overrides - unset/remove option, empty section is removed
Expand Down
15 changes: 14 additions & 1 deletion dnf-behave-tests/dnf/plugins-core/config-manager-vars.feature
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Scenario: unset/remove an existing variable
"""


Scenario: unset/remove an existing variable, removing non-existent variable is OK
Scenario: unset/remove an existing variable, removing non-existent variable is OK, but a warning is written
Given I create file "/etc/dnf/vars/mvar1" with
"""
orig_value1
Expand All @@ -119,3 +119,16 @@ Scenario: unset/remove an existing variable, removing non-existent variable is O
"""
orig_value2
"""
And stderr is
"""
config-manager: Request to remove variable but it is not present in the vars directory: nonexistvar
"""


Scenario: removing non-existent variable (directory with variables not found) is OK, but a warning is written
When I execute dnf with args "config-manager unsetvar nonexistvar"
Then the exit code is 0
And stderr is
"""
config-manager: Request to remove variable but vars directory was not found: {context.dnf.installroot}/etc/dnf/vars
"""
Loading