Skip to content

Commit

Permalink
Use add_on_products to enable modules without registration
Browse files Browse the repository at this point in the history
For test scenarios that do not do registration, using add_on_products
can help enable modules and install packages without reigstration.
And module virt_autotest/reboot_and_wait_up_normal will be loaded for
unregistered released products.
  • Loading branch information
waynechen55 committed Nov 11, 2024
1 parent 8c92f4b commit ba72312
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
% } else {
<do_registration config:type="boolean">false</do_registration>
% }
<reg_server><%= defined $bmwqemu::vars{"HOST_SCC_URL"} ? $bmwqemu::vars{"HOST_SCC_URL"} : "" %></reg_server>
<reg_code><%= $get_var->('SCC_REGCODE') %></reg_code>
<install_updates config:type="boolean">true</install_updates>
% if (keys %$addons) {
Expand Down Expand Up @@ -34,6 +35,17 @@
</addons>
%}
</suse_register>
<add-on>
<add_on_products config:type="list">
% my $n =0;
% for my $repo (@$repos) {
<listentry>
<media_url><%= $repo %></media_url>
<alias>TEST_<%= $n++ %></alias>
</listentry>
% }
</add_on_products>
</add-on>
<bootloader>
<global>
<activate>true</activate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</addons>
%}
</suse_register>
<!--add-on>
<add-on>
<add_on_products config:type="list">
% my $n =0;
% for my $repo (@$repos) {
Expand All @@ -45,7 +45,7 @@
</listentry>
% }
</add_on_products>
</add-on-->
</add-on>
<bootloader>
<global>
<activate>true</activate>
Expand Down
80 changes: 75 additions & 5 deletions lib/virt_autotest/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,71 @@ use Utils::Architectures;
use IO::Socket::INET;
use Carp;

our @EXPORT = qw(is_vmware_virtualization is_hyperv_virtualization is_fv_guest is_pv_guest is_sev_es_guest guest_is_sle is_guest_ballooned is_xen_host is_kvm_host
is_monolithic_libvirtd turn_on_libvirt_debugging_log restart_libvirtd check_libvirtd restart_modular_libvirt_daemons check_modular_libvirt_daemons
reset_log_cursor check_failures_in_journal check_host_health check_guest_health print_cmd_output_to_file collect_virt_system_logs setup_rsyslog_host download_script download_script_and_execute upload_virt_logs enable_nm_debug upload_nm_debug_log
ssh_setup setup_common_ssh_config add_alias_in_ssh_config install_default_packages parse_subnet_address_ipv4 backup_file manage_system_service check_port_state is_registered_system do_system_registration check_system_registration subscribe_extensions_and_modules check_activate_network_interface wait_for_host_reboot
create_guest import_guest ssh_copy_id add_guest_to_hosts ensure_default_net_is_active ensure_guest_started remove_additional_disks remove_additional_nic start_guests is_guest_online ensure_online wait_guest_online restore_downloaded_guests save_original_guest_xmls restore_original_guests save_guests_xml_for_change restore_xml_changed_guests shutdown_guests wait_guests_shutdown remove_vm recreate_guests download_vm_import_disks get_guest_regcode
our @EXPORT = qw(
is_vmware_virtualization
is_hyperv_virtualization
is_fv_guest
is_pv_guest
is_sev_es_guest
guest_is_sle
is_guest_ballooned
is_xen_host
is_kvm_host
is_monolithic_libvirtd
turn_on_libvirt_debugging_log
restart_libvirtd
check_libvirtd
restart_modular_libvirt_daemons
check_modular_libvirt_daemons
reset_log_cursor
check_failures_in_journal
check_host_health
check_guest_health
print_cmd_output_to_file
collect_virt_system_logs
setup_rsyslog_host
download_script
download_script_and_execute
upload_virt_logs
enable_nm_debug
upload_nm_debug_log
ssh_setup
setup_common_ssh_config
add_alias_in_ssh_config
install_default_packages
parse_subnet_address_ipv4
backup_file
manage_system_service
check_port_state
is_registered_system
do_system_registration
check_system_registration
subscribe_extensions_and_modules
check_activate_network_interface
wait_for_host_reboot
create_guest
import_guest
ssh_copy_id
add_guest_to_hosts
ensure_default_net_is_active
ensure_guest_started
remove_additional_disks
remove_additional_nic
start_guests
is_guest_online
ensure_online wait_guest_online
restore_downloaded_guests
save_original_guest_xmls
restore_original_guests
save_guests_xml_for_change
restore_xml_changed_guests
shutdown_guests
wait_guests_shutdown
remove_vm
recreate_guests
download_vm_import_disks
get_guest_regcode
is_registered_sles
);

my %log_cursors;
Expand Down Expand Up @@ -1297,4 +1357,14 @@ sub wait_for_host_reboot {
select_console('root-ssh');
}

#Detect whether SUT host is installed with scc registration
sub is_registered_sles {
if ((!get_var('SCC_REGISTER') or check_var('SCC_REGISTER', 'none')) and (!get_var('REGISTER') or check_var('REGISTER', 'none'))) {
return 0;
}
else {
return 1;
}
}

1;
5 changes: 4 additions & 1 deletion products/sle/main.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use main_publiccloud;
use main_security;
use Utils::Architectures;
use DistributionProvider;
use virt_autotest::utils qw(is_registered_sles);

BEGIN {
unshift @INC, dirname(__FILE__) . '/../../lib';
Expand Down Expand Up @@ -864,7 +865,9 @@ elsif (get_var("VIRT_AUTOTEST")) {
loadtest "virt_autotest/update_package";
# Skip reset_partition for s390x due to there just be 42Gib disk space for each s390x LPAR
loadtest "virt_autotest/reset_partition" if (!is_s390x and get_var('VIRT_PRJ1_GUEST_INSTALL'));
loadtest "virt_autotest/reboot_and_wait_up_normal" if (!get_var('AUTOYAST') && get_var('REPO_0_TO_INSTALL'));
if (!is_registered_sles and get_var('REPO_0_TO_INSTALL')) {
loadtest "virt_autotest/reboot_and_wait_up_normal";
}
loadtest "virt_autotest/download_guest_assets" if get_var("SKIP_GUEST_INSTALL") && is_x86_64;
}
if (get_var("VIRT_PRJ1_GUEST_INSTALL")) {
Expand Down
4 changes: 2 additions & 2 deletions tests/virt_autotest/update_package.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use version_utils 'is_sle';
use virt_utils;
use ipmi_backend_utils;
use Utils::Architectures;
use virt_autotest::utils qw(is_xen_host is_kvm_host);
use virt_autotest::utils qw(is_xen_host is_kvm_host is_registered_sles);

sub update_package {
my $self = shift;
Expand Down Expand Up @@ -49,7 +49,7 @@ sub update_package {
sub run {
my $self = shift;
#workaroud: skip update package for registered sles as the packages are already up-to-date
$self->update_package() unless (!!get_var('AUTOYAST') || (is_registered_sles && !is_s390x));
$self->update_package() unless (is_registered_sles && !is_s390x);
if (!!get_var('AUTOYAST') || (is_registered_sles && !is_s390x)) {
my @files_to_upload = ("/boot/grub2/grub.cfg", "/etc/default/grub");
push(@files_to_upload, script_output("ls /boot/efi/efi/sles/xen-*.cfg")) if is_xen_host and is_uefi_boot;
Expand Down
41 changes: 29 additions & 12 deletions tests/virt_autotest/virt_utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,35 @@ use LWP::Simple 'head';
use virt_autotest::utils;
use version_utils qw(is_sle is_alp get_os_release);

our @EXPORT
= qw(enable_debug_logging update_guest_configurations_with_daily_build locate_sourcefile get_repo_0_prefix repl_repo_in_sourcefile repl_addon_with_daily_build_module_in_files repl_module_in_sourcefile handle_sp_in_settings handle_sp_in_settings_with_fcs handle_sp_in_settings_with_sp0 clean_up_red_disks lpar_cmd generate_guest_asset_name get_guest_disk_name_from_guest_xml compress_single_qcow2_disk get_guest_list download_guest_assets is_installed_equal_upgrade_major_release generateXML_from_data check_guest_disk_type perform_guest_restart collect_host_and_guest_logs cleanup_host_and_guest_logs monitor_guest_console start_monitor_guest_console stop_monitor_guest_console is_developing_sles is_registered_sles);
our @EXPORT = qw(
enable_debug_logging
update_guest_configurations_with_daily_build
locate_sourcefile
get_repo_0_prefix
repl_repo_in_sourcefile
repl_addon_with_daily_build_module_in_files
repl_module_in_sourcefile
handle_sp_in_settings
handle_sp_in_settings_with_fcs
handle_sp_in_settings_with_sp0
clean_up_red_disks
lpar_cmd
generate_guest_asset_name
get_guest_disk_name_from_guest_xml
compress_single_qcow2_disk
get_guest_list
download_guest_assets
is_installed_equal_upgrade_major_release
generateXML_from_data
check_guest_disk_type
perform_guest_restart
collect_host_and_guest_logs
cleanup_host_and_guest_logs
monitor_guest_console
start_monitor_guest_console
stop_monitor_guest_console
is_developing_sles
);

sub enable_debug_logging {

Expand Down Expand Up @@ -740,14 +767,4 @@ sub is_developing_sles {
}
}

#Detect whether SUT host is installed with scc registration
sub is_registered_sles {
if (!get_var('SCC_REGISTER') || check_var('SCC_REGISTER', 'none') || check_var('SCC_REGISTER', '')) {
return 0;
}
else {
return 1;
}
}

1;

0 comments on commit ba72312

Please sign in to comment.