Skip to content
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
39 changes: 36 additions & 3 deletions tests/prepare/artifact/install-cases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ xfail_plans_nobest=(
"^/broken/no-artifacts/obsoletes/basic$"
"^/broken/no-artifacts/upgrade/with-devel$"
)
xfail_centos7=(
# yum cannot downgrade a pre-installed package
"/pre-installed/downgrade/with-devel$"
"^/verified-artifacts/pre-installed/downgrade/only-foo$"
)
complicated_centos7=(
# Obsoletes wins over priority. Some of these tests pass when they should xfail
# some fail in different ways, it is hard to handle them all consistently, so just skip them.
"^/verified-artifacts/obsoletes/basic/downgrade$"
"^/available-artifacts/obsoletes/basic/downgrade$"
"^/available-artifacts/obsoletes/pre-installed/downgrade/with-devel$"
"^/broken/available-artifacts/obsoletes/basic/downgrade$"
"^/broken/available-artifacts/obsoletes/pre-installed/downgrade/with-devel$"
"^/verified-artifacts/obsoletes/basic/downgrade$"
)

while IFS= read -r image; do
if ! is_fedora "$image" && ! is_centos "$image"; then
Expand All @@ -47,8 +62,6 @@ xfail_plans_nobest=(
extra_env=""
if is_centos_7 "$image"; then
extra_env="-e DNF_CMD=yum"
# TODO: centos7 is hard
continue
fi

phase_prefix="$(test_phase_prefix $image)"
Expand All @@ -63,7 +76,7 @@ xfail_plans_nobest=(
break
fi
done
if is_centos_stream_9 "$image" || is_centos_stream_10 "$image" || is_fedora_eln "$image"; then
if is_centos_7 "$image" || is_centos_stream_9 "$image" || is_centos_stream_10 "$image" || is_fedora_eln "$image"; then
for check_pattern in ${xfail_plans_nobest[@]}; do
if [[ "$plan" =~ $check_pattern ]]; then
xfail="(XFAIL)"
Expand All @@ -72,6 +85,26 @@ xfail_plans_nobest=(
fi
done
fi
if is_centos_7 "$image"; then
for check_pattern in ${xfail_centos7[@]}; do
if [[ "$plan" =~ $check_pattern ]]; then
xfail="(XFAIL)"
expected_result=2
break
fi
done
# Skip too complicated situations altogether
unset complicated
for check_pattern in ${complicated_centos7[@]}; do
if [[ "$plan" =~ $check_pattern ]]; then
complicated=1
break
fi
done
if [[ -n "$complicated" ]]; then
continue
fi
fi
rlPhaseStartTest "$phase_prefix $plan $xfail"
rlRun "tmt run $extra_env -i $run --scratch -vvv --all \
plan --name '^$plan$' \
Expand Down
11 changes: 8 additions & 3 deletions tmt/package_managers/dnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,9 +533,14 @@ def _construct_presence_script(
def check_presence(self, *installables: Installable) -> ShellScript:
queries: list[str] = []
for original_installable in installables:
sanitized = shlex.quote(str(self._sanitize_rpm_whatprovides(original_installable)))
original = shlex.quote(str(original_installable))
queries.append(f"rpm -q --whatprovides {sanitized} >&2 || echo {original}")
escaped = shlex.quote(str(original_installable))
if original_installable != self._sanitize_rpm_whatprovides(original_installable):
# this only happens when there is a nevra where we cannot use --whatprovides
# but normal `rpm -q` works
queries.append(f"rpm -q {escaped} >&2 || echo {escaped}")
else:
# Otherwise, do the actual presence check
queries.append(f"rpm -q --whatprovides {escaped} >&2 || echo {escaped}")
return ShellScript("\n".join(queries))

# TODO: get rid of those `type: ignore` below. I think it's caused by the
Expand Down
2 changes: 1 addition & 1 deletion tmt/steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2408,7 +2408,7 @@ def go_prolog(self, logger: tmt.log.Logger) -> None:
# Include order in verbose mode
logger.verbose('order', self.order, 'magenta', level=3)

def essential_requires(self) -> list['tmt.base.core.Dependency']:
def essential_requires(self, guest: 'Guest') -> list['tmt.base.core.Dependency']:
"""
Collect all essential requirements of the plugin.

Expand Down
2 changes: 1 addition & 1 deletion tmt/steps/execute/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ def results(self) -> list[Result]:

return self._results

def essential_requires(self) -> list[tmt.base.core.Dependency]:
def essential_requires(self, guest: 'Guest') -> list[tmt.base.core.Dependency]:
"""
Collect all essential requirements of the plugin.

Expand Down
2 changes: 1 addition & 1 deletion tmt/steps/prepare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def go(self, force: bool = False) -> None:
].dependencies += tmt.base.core.assert_simple_dependencies(
# ignore[attr-defined]: mypy thinks that phase is Phase type, while its
# actually PluginClass
phase.essential_requires(), # type: ignore[attr-defined]
phase.essential_requires(guest), # type: ignore[attr-defined]
'After beakerlib processing, tests may have only simple requirements',
self._logger,
)
Expand Down
2 changes: 1 addition & 1 deletion tmt/steps/prepare/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def invoke_playbook(

return outcome

def essential_requires(self) -> list[tmt.base.core.Dependency]:
def essential_requires(self, guest: 'Guest') -> list[tmt.base.core.Dependency]:
"""
Collect all essential requirements of the plugin.

Expand Down
10 changes: 7 additions & 3 deletions tmt/steps/prepare/artifact/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,15 @@ def _prepare_verify(self, providers: list[ArtifactProvider], guest: Guest) -> No
verify_phase = PreparePlugin.delegate(self.step, data=verify_data) # pyright: ignore[reportUnknownVariableType]
self.step.add_phase(verify_phase) # pyright: ignore[reportUnknownArgumentType]

def essential_requires(self) -> list[tmt.base.core.Dependency]:
def essential_requires(self, guest: Guest) -> list[tmt.base.core.Dependency]:
# createrepo is needed to create repository metadata from downloaded artifacts
return [
tmt.base.core.DependencySimple('/usr/bin/createrepo'),
requires: list[tmt.base.core.Dependency] = [
tmt.base.core.DependencySimple('/usr/bin/createrepo')
]
if guest.facts.package_manager == "yum":
# On yum we need `yum-plugin-priorities` in order to handle repo priorities
requires.append(tmt.base.core.DependencySimple("yum-plugin-priorities"))
return requires

def _detect_duplicate_nvras(
self, provider: ArtifactProvider, seen_nvras: dict[str, str]
Expand Down
2 changes: 1 addition & 1 deletion tmt/steps/prepare/feature/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def go(

return outcome

def essential_requires(self) -> list[tmt.base.core.Dependency]:
def essential_requires(self, guest: 'Guest') -> list[tmt.base.core.Dependency]:
"""
Collect all essential requirements of the plugin.

Expand Down
2 changes: 1 addition & 1 deletion tmt/steps/provision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def guest(self) -> Optional[tmt.guest.Guest]:

return self._guest

def essential_requires(self) -> list['tmt.base.core.Dependency']:
def essential_requires(self, guest: tmt.guest.Guest) -> list['tmt.base.core.Dependency']:
"""
Collect all essential requirements of the guest implementation.

Expand Down
Loading