From 258a0cd95aea4d70fd34694392f9bf32bc5a6892 Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Thu, 4 Jan 2024 12:10:43 +0100 Subject: [PATCH 1/2] dnf5 config-manager: Sync with upstream - Add repoid to gener repo name The new upstream code adds the repository id to the generated repository name. --- .../config-manager-addrepo.feature | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/dnf-behave-tests/dnf/plugins-core/config-manager-addrepo.feature b/dnf-behave-tests/dnf/plugins-core/config-manager-addrepo.feature index 1d9bb9949..56aaddf59 100644 --- a/dnf-behave-tests/dnf/plugins-core/config-manager-addrepo.feature +++ b/dnf-behave-tests/dnf/plugins-core/config-manager-addrepo.feature @@ -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/ """ @@ -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/ """ @@ -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/ """ @@ -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/ """ @@ -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 @@ -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 @@ -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/ """ @@ -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/ """ @@ -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/ """ @@ -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/ """ From 6df66ec97700ed25805f9269e4ab422f45d61e5b Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Thu, 29 Feb 2024 12:39:57 +0100 Subject: [PATCH 2/2] dnf5 config-manager: Add tests for warning messages --- .../plugins-core/config-manager-opts.feature | 113 +++++++++++++++++- .../plugins-core/config-manager-vars.feature | 15 ++- 2 files changed, 125 insertions(+), 3 deletions(-) diff --git a/dnf-behave-tests/dnf/plugins-core/config-manager-opts.feature b/dnf-behave-tests/dnf/plugins-core/config-manager-opts.feature index 35b6dc9e6..29f6464bd 100644 --- a/dnf-behave-tests/dnf/plugins-core/config-manager-opts.feature +++ b/dnf-behave-tests/dnf/plugins-core/config-manager-opts.feature @@ -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] @@ -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 + """ Scenario: repository configuration overrides - new option to "repo1" @@ -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] @@ -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 diff --git a/dnf-behave-tests/dnf/plugins-core/config-manager-vars.feature b/dnf-behave-tests/dnf/plugins-core/config-manager-vars.feature index b7fa8ea52..05b05c87e 100644 --- a/dnf-behave-tests/dnf/plugins-core/config-manager-vars.feature +++ b/dnf-behave-tests/dnf/plugins-core/config-manager-vars.feature @@ -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 @@ -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 + """