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

Check if SUSEConnect command includes all expected addons info for migration #10452

Merged
merged 1 commit into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 17 additions & 3 deletions lib/services/registered_addons.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use registration 'get_addon_fullname';
use Mojo::JSON;
use List::MoreUtils 'uniq';

our @addons;
my @addons;

sub suseconnect_ls {
my ($search) = @_;
Expand All @@ -41,8 +41,8 @@ sub check_registered_system {
sub check_registered_addons {
my ($addonlist) = @_;
$addonlist //= get_var('SCC_ADDONS');
my @addons = grep { defined $_ && $_ } split(/,/, $addonlist);
my @unique_addons = uniq @addons;
my @my_addons = grep { defined $_ && $_ } split(/,/, $addonlist);
my @unique_addons = uniq @my_addons;
foreach my $addon (@unique_addons) {
$addon =~ s/(^\s+|\s+$)//g;
my $name = get_addon_fullname($addon);
Expand All @@ -63,6 +63,7 @@ sub check_upgraded_addons {
sub check_suseconnect {
my $output = script_output("SUSEConnect -s", 120);
my @out = grep { $_ =~ /identifier/ } split(/\n/, $output);
@addons = ();
if (@out) {
my $json = Mojo::JSON::decode_json($out[0]);
foreach (@$json) {
Expand All @@ -78,10 +79,23 @@ sub check_suseconnect {
diag "@addons";
}

sub check_suseconnect_cmd {
my $ls_out = script_output("SUSEConnect --list-extensions", 120);
diag "$ls_out";
my $status_out = script_output("SUSEConnect --status-text", 120);
diag "$status_out";
for (my $i = 1; $i < @addons; $i = $i + 1) {
diag "$addons[$i]";
die "$addons[$i] is not existed at SUSEConnect --list-extensions" if ($ls_out !~ /Deactivate(.*)$addons[$i]/);
die "$addons[$i] is not existed at SUSEConnect --status-text" if ($status_out !~ /$addons[$i]/);
}
}

sub full_registered_check {
my ($stage) = @_;
$stage //= '';
check_suseconnect();
check_suseconnect_cmd();
if ($stage eq 'before') {
check_registered_system(get_var('ORIGIN_SYSTEM_VERSION'));
check_registered_addons();
Expand Down
8 changes: 6 additions & 2 deletions tests/console/system_prepare.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use version_utils 'is_sle';
use serial_terminal 'add_serial_console';
use bootloader_setup qw(change_grub_config grub_mkconfig);
use registration;
use services::registered_addons 'full_registered_check';
use strict;
use warnings;

Expand Down Expand Up @@ -75,7 +76,7 @@ sub run {
}

# Save output info to logfile
if (is_sle) {
if (is_sle && get_required_var('FLAVOR') =~ /Migration/) {
rwx788 marked this conversation as resolved.
Show resolved Hide resolved
my $out;
my $timeout = bmwqemu::scale_timeout(30);
my $waittime = bmwqemu::scale_timeout(5);
Expand All @@ -87,7 +88,10 @@ sub run {
diag "SUSEConnect --status-text locked: $out";
}
diag "SUSEConnect --status-text: $out";
assert_script_run "SUSEConnect --status-text | grep -v 'Not Registered'" unless get_var('MEDIA_UPGRADE');
if (!get_var('MEDIA_UPGRADE')) {
assert_script_run "SUSEConnect --status-text | grep -v 'Not Registered'";
services::registered_addons::full_registered_check;
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that we have clash of names, so it should work if we just use full_registered_check. Otherwise we can skip explicit import as we call it by full name.

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 used 'full_registered_check' before, it cannot find this file. So I change to use full path

Copy link
Member

Choose a reason for hiding this comment

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

I've checked now, and it's actually because it's not exported in the lib/services/registered_addons.pm. As you import that method, I would propose to export it properly in lib/services/registered_addons.pm

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi Rodion, I merge it seems early, do you think we need revert it and add this modification?

}
}
}

Expand Down