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

Wrapper for zypper_call and trup_call #18204

Merged
merged 1 commit into from Dec 4, 2023
Merged

Conversation

@czerw
Copy link
Contributor

czerw commented Nov 28, 2023

I found, not kernel related test, which is great candidate for this PR: https://github.com/os-autoinst/os-autoinst-distri-opensuse/blob/master/tests/console/year_2038_detection.pm

Copy link

Great PR! Please pay attention to the following items before merging:

Files matching lib/**.pm:

  • Consider adding or extending unit tests in t/

This is an automatically generated QA checklist based on modified files.

@dzedro
Copy link
Contributor Author

dzedro commented Nov 28, 2023

I found, not kernel related test, which is great candidate for this PR: https://github.com/os-autoinst/os-autoinst-distri-opensuse/blob/master/tests/console/year_2038_detection.pm

Thank you @czerw, the year_2038_detection test is only on 15-SP5, if you want me to do it on other versions or do another test, let me please know. I think there should be no differences between versions in this case.

@dzedro dzedro force-pushed the install_pkg branch 2 times, most recently from d6c0b62 to c5f922e Compare November 28, 2023 09:15
Copy link
Contributor

@czerw czerw left a comment

Choose a reason for hiding this comment

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

LGTM, it's good start to have things more seamless.

lib/wrapper.pm Outdated
my $trup_packages = $args{trup_packages} // $args{packages};
my $zypper_packages = $args{zypper_packages} // $args{packages};
die 'At least one of packages, trup_packages, zypper_packages arguments is required' unless defined($args{packages} || $args{trup_packages} || $args{zypper_packages});
my $timeout = $args{timeout} // 500;
Copy link
Contributor

Choose a reason for hiding this comment

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

First, why add a new file? This should go to utils.pm or at least qam.pm because it'll be used a lot.

Second, I really don't like that all packages have to be passed in a keyword argument. I'd prefer the package list handling like this:

my ($packages, %args) = @_;

if (is_transactional) {
    $packages .= ' ' . $args{trup_extra} // '';
}
else {
    $packages .= ' ' . $args{zypper_extra} // '';
}

So that I can call just install_package('foo');.

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 I read somewhere it should be in separated package, but I don't mind to have it in likely utils.pm.
Sure, I will do the packages default parameter without keyword argument.

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 changed the code, if nobody disagrees @czerw @foursixnine ? I would move the install_package into utils.

Copy link
Member

Choose a reason for hiding this comment

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

This should go to utils.pm or at least qam.pm because it'll be used a lot.

That it will be used a lot isn't a good reason to keep making lib/utils grow, so @dzedro lets keep it separate.

In the end, Jozef's work would end up as a stepping stone to move towards something that abstracts most things from the caller, and end up in $self->action($packages) or something like that

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, can we at least rename the file so that it sounds like something related to package installation? rpm.pm, package_utils.pm, or something like that...

lib/wrapper.pm Outdated Show resolved Hide resolved
lib/wrapper.pm Outdated Show resolved Hide resolved
lib/wrapper.pm Outdated Show resolved Hide resolved
lib/wrapper.pm Outdated
# Maintainer: QE Core <qe-core@suse.de>

package wrapper;
use Mojo::Base qw(Exporter);
Copy link
Member

Choose a reason for hiding this comment

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

In the future, we can take a look into using perl signatures https://www.perl.com/article/announcing-perl-7/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

lib/wrapper.pm Outdated
Comment on lines 43 to 44
record_info('install_package', $args{skip_trup}) if $args{skip_trup} =~ /\w+/;
return if $args{skip_trup};
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
record_info('install_package', $args{skip_trup}) if $args{skip_trup} =~ /\w+/;
return if $args{skip_trup};
if $args{skip_trup}{ record_info "Skipping changes in transactional system as requested"; return };
record_info('install_package', $args{skip_trup}) if $args{skip_trup} =~ /\w+/;

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 can put also all the code on one line, can I ? 🙄

Copy link
Member

Choose a reason for hiding this comment

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

I can put also all the code on one line, can I ?

Well I mean to have a clear indicator that there's an intended skip

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 would do it, but then record_info after return is pointless.
I did it just because existing code had record_info, there is option to leave message,
must be not done always.

Copy link
Contributor

Choose a reason for hiding this comment

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

record_info('install_package', ...); would be just pointless spam...

lib/wrapper.pm Outdated
Comment on lines 50 to 51
record_info('install_package', $args{skip_zypper}) if $args{skip_zypper} =~ /\w+/;
return if $args{skip_zypper};
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

Copy link
Member

@foursixnine foursixnine left a comment

Choose a reason for hiding this comment

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

Looking good @dzedro, I guess the update or patch are what come next, isn't it?

(random question, is there a difference between patch vs dup/up? from a customer point of view?

@dzedro
Copy link
Contributor Author

dzedro commented Nov 29, 2023

Looking good @dzedro, I guess the update or patch are what come next, isn't it?

(random question, is there a difference between patch vs dup/up? from a customer point of view?

IDK, Whatever is needed
I guess path and up are kind of same, patch just does first update zypper then in next run other packages,
up does all at onde, dup is like up with vendor change. There is probably more differences, this is what I know.

Regarding location of install_package, I will not put it into utils, because of failure https://dzedro.suse.cz/tests/252, probably some circular dependency.
So please agree where you want it, I don't mind wrapper, qam, utils or other package.

@mdoucha
Copy link
Contributor

mdoucha commented Nov 29, 2023

Regarding location of install_package, I will not put it into utils, because of failure https://dzedro.suse.cz/tests/252, probably some circular dependency. So please agree where you want it, I don't mind wrapper, qam, utils or other package.

qam.pm is fine.

@dzedro dzedro marked this pull request as ready for review November 29, 2023 10:55
@dzedro
Copy link
Contributor Author

dzedro commented Nov 29, 2023

It's in qam.pm, I had ready also package_utils.pm

lib/qam.pm Outdated Show resolved Hide resolved
Copy link
Contributor

@mdoucha mdoucha left a comment

Choose a reason for hiding this comment

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

LGTM

@czerw czerw merged commit 49164a8 into os-autoinst:master Dec 4, 2023
8 checks passed
@dzedro dzedro deleted the install_pkg branch December 5, 2023 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants