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

Add tests for supporting included configuration files #1351

Closed
Closed
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
162 changes: 162 additions & 0 deletions dnf-behave-tests/dnf/config.feature
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,165 @@ Scenario: Reposdir option in dnf.conf file in host
| Action | Package |
| install | vagare-1.0-1.fc29.x86_64 |
| install-dep | labirinto-1.0-1.fc29.x86_64 |


@dnf5
Scenario: Test including another config file
Given I use repository "dnf-ci-fedora"
And I create file "/test/dnf.conf" with
"""
[main]
exclude=filesystem
"""
And I include configuration path "/test/dnf.conf" in dnf.conf
When I execute dnf with args "install filesystem"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
Argument 'filesystem' matches only excluded packages.
"""


@dnf5
Scenario: Test including another config file located outside the installroot
Given I use repository "dnf-ci-fedora"
And I create file "//test/dnf.conf" with
"""
[main]
exclude=filesystem
"""
And I include configuration path "/test/dnf.conf" in dnf.conf
When I execute dnf with args "install filesystem --use-host-config"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
Argument 'filesystem' matches only excluded packages.
"""


@dnf5
Scenario: The order of configs depends on the order of inclusions
Given I use repository "dnf-ci-fedora"
And I create file "/test/dnf1.conf" with
"""
[main]
exclude=filesystem
"""
And I create file "/test/dnf2.conf" with
"""
[main]
exclude=,
"""
And I include configuration path "/test/dnf1.conf" in dnf.conf
And I include configuration path "/test/dnf2.conf" in dnf.conf
When I execute dnf with args "install filesystem"
Then the exit code is 0


@dnf5
Scenario: The order of configs depends on the order of inclusions
Given I use repository "dnf-ci-fedora"
And I create file "/test/dnf1.conf" with
"""
[main]
exclude=filesystem
"""
And I create file "/test/dnf2.conf" with
"""
[main]
exclude=,
"""
And I include configuration path "/test/dnf2.conf" in dnf.conf
And I include configuration path "/test/dnf1.conf" in dnf.conf
When I execute dnf with args "install filesystem"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
Argument 'filesystem' matches only excluded packages.
"""


@dnf5
Scenario: The default config overrides the included config
Given I use repository "dnf-ci-fedora"
And I configure dnf with
| key | value |
| exclude | filesystem |
And I create file "/test/dnf.conf" with
"""
[main]
exclude=,
"""
And I include configuration path "/test/dnf.conf" in dnf.conf
When I execute dnf with args "install filesystem"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
Argument 'filesystem' matches only excluded packages.
"""


@dnf5
Scenario: The config that includes another config overrides the included config
Given I use repository "dnf-ci-fedora"
And I create file "/test/dnf1.conf" with
"""
#!include_config /test/dnf2.conf
[main]
exclude=filesystem
"""
And I create file "/test/dnf2.conf" with
"""
[main]
exclude=,
"""
And I include configuration path "/test/dnf1.conf" in dnf.conf
When I execute dnf with args "install filesystem"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
Argument 'filesystem' matches only excluded packages.
"""


@dnf5
Scenario: The including configs using globs
Given I use repository "dnf-ci-fedora"
And I create file "/test/dnf1.conf" with
"""
[main]
exclude=filesystem
"""
And I create file "/test/dnf2.conf" with
"""
[main]
exclude=yum
"""
And I create file "/test/something_else.conf" with
"""
[main]
exclude=wget
"""
And I include configuration path "/test/dnf*.conf" in dnf.conf
# This fails, because the yum exclude overrides the filesystem exclude
# When I execute dnf with args "install filesystem"
# Then the exit code is 1
# And stderr is
# """
# Failed to resolve the transaction:
# Argument 'filesystem' matches only excluded packages.
# """
Comment on lines +447 to +454
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the option (and probably others) should be appendable, the same way you can append it from the command line in dnf4. However, it currently isn't appendable even from the command line, so I wouldn't block the PR on it, just create an issue.

When I execute dnf with args "install yum"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
Argument 'yum' matches only excluded packages.
"""
When I execute dnf with args "install wget"
Then the exit code is 0
1 change: 1 addition & 0 deletions dnf-behave-tests/dnf/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(self, userdata, force_installroot=False, no_installroot=False):
"best": "True"
}
}
self.config_includes = list()

# Since protected_packages don't work in installroot override host configuration
if not no_installroot:
Expand Down
9 changes: 9 additions & 0 deletions dnf-behave-tests/dnf/steps/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,12 @@ def step_configure_dnf(context):
context.dnf.config[section][k] = v

write_config(context)


@behave.step("I include configuration path \"{path}\" in dnf.conf")
def step_include_configuration_file_in_dnf_conf(context, path):
"""
Adds the path to the list of includes in dnf.conf
"""
context.dnf.config_includes.append(path)
write_config(context)
5 changes: 5 additions & 0 deletions dnf-behave-tests/dnf/steps/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def write_config(context):
ensure_directory_exists(config_dir)

conf_text = ""

# put in the config includes
for include in context.dnf.config_includes:
conf_text += "#!include_config %s\n" % include

# sort and put [main] first
for section, values in \
sorted(list(context.dnf.config.items()), key=lambda i: "" if i[0] == "[main]" else i[0]):
Expand Down
Loading