Skip to content
Open
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: 18 additions & 2 deletions src/img/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,28 +511,44 @@ def install_tests(self):
packages = []
patterns = []
host_test_packages = []
for name in self.test_packages.keys():
pre_check = []
skip_already_installed = (
'rpm -qi {package} ||'
)
for name in self.test_packages:
Copy link
Member

Choose a reason for hiding this comment

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

Why have we gone from name in test_packages.keys(): to test_packages: ??

Copy link
Author

Choose a reason for hiding this comment

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

for-loop itself unpacks keys from dict, so calling .keys() is overhead for iterating dict keys

if name.startswith('@'):
if self.package_manager == 'zypper':
patterns.append(name[1:])
if self.package_manager == 'pkcon':
patterns.append('pattern:' + name[1:])

pre_check.extend(
skip_already_installed.format(package=name[1:]).split())

elif self.host_based_testing_enabled and name.endswith('-host-tests'):
pre_check.extend(
skip_already_installed.format(package=name).split())

host_test_packages.append(name)

else:
pre_check.extend(
skip_already_installed.format(package=name).split())
packages.append(name)

if packages:
print "installing test packages"
if self.package_manager == 'zypper':
install_comm = ['zypper', '-vv', 'in', '-y', '-f', '--force-resolution']
install_comm.extend(packages)
self.commands.ssh(install_comm)
self.commands.ssh(pre_check+install_comm)
Copy link
Member

Choose a reason for hiding this comment

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

this looks like it will result in a command like:
rpm -qi pkgA ||rpm -qi pkgB ||rpm -qi pkgC || zypper', -vv -in -y -f --force-resolution pkgA pkgB pkgC pkgD pkgE

That won't install pkgD or pkgE because pkgA is installed and it will abort
Is that the intention?

if patterns:
print "installing test patterns"
if self.package_manager == 'zypper':
install_comm = ['zypper', '-vv', 'in', '-y', '-f', '--force-resolution', '-t', 'pattern']
install_comm.extend(patterns)
self.commands.ssh(install_comm)

if self.host_based_testing_enabled and host_test_packages:
print "updating host packages reposity cache"
update_comm = ['sudo', '-n', self.host_test_package_manager, '-v']
Expand Down