Skip to content

Commit

Permalink
[virtualization][alp] Enable core feature tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alice-suse committed Jan 20, 2023
1 parent 3ec79c8 commit ce7163e
Show file tree
Hide file tree
Showing 18 changed files with 355 additions and 50 deletions.
6 changes: 3 additions & 3 deletions data/virt_autotest/clean_up_virt_logs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ function do_cleanup_on_host() {

#Just power on or reboot active guests to give them a clear start
function do_cleanup_on_guests() {
local guest_domain_types="sles"
local guests_inactive_array=`virsh list --inactive | grep -E "${guest_domain_types}" | awk '{print $2}'`
local guest_domains_array=`virsh list --all | grep -E "${guest_domain_types}" | awk '{print $2}'`
local guest_domain_types="sles|alp"
local guests_inactive_array=`virsh list --inactive | grep -Ei "${guest_domain_types}" | awk '{print $2}'`
local guest_domains_array=`virsh list --all | grep -Ei "${guest_domain_types}" | awk '{print $2}'`
local guest_current=""
local ret_result=0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<guest_name></guest_name>
<guest_domain_name></guest_domain_name>
<guest_memory>2048,maxmemory=4096</guest_memory>
<guest_vcpus>4,maxvcpus=8</guest_vcpus>
<guest_vcpus>2,maxvcpus=4</guest_vcpus>
<guest_cpumodel>host-model</guest_cpumodel>
<guest_metadata></guest_metadata>
<guest_xpath></guest_xpath>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0"?>
<guest>
<guest_os_name>alp</guest_os_name>
<guest_version>0.1</guest_version>
<guest_version_major>0</guest_version_major>
<guest_version_minor>1</guest_version_minor>
<guest_os_word_length>64</guest_os_word_length>
<guest_build></guest_build>
<host_hypervisor_uri></host_hypervisor_uri>
<host_virt_type>kvm</host_virt_type>
<guest_virt_type>hvm</guest_virt_type>
<guest_machine_type>q35</guest_machine_type>
<guest_arch>x86_64</guest_arch>
<guest_name></guest_name>
<guest_domain_name></guest_domain_name>
<guest_memory>2048,maxmemory=4096</guest_memory>
<guest_vcpus>2,maxvcpus=4</guest_vcpus>
<guest_cpumodel>host-model</guest_cpumodel>
<guest_metadata></guest_metadata>
<guest_boot_settings>uefi</guest_boot_settings>
<guest_xpath></guest_xpath>
<guest_installation_automation></guest_installation_automation>
<guest_installation_automation_file></guest_installation_automation_file>
<guest_installation_method>import</guest_installation_method>
<guest_installation_extra_args></guest_installation_extra_args>
<guest_installation_wait></guest_installation_wait>
<guest_installation_method_others></guest_installation_method_others>
<guest_installation_media></guest_installation_media>
<guest_installation_fine_grained></guest_installation_fine_grained>
<guest_os_variant>opensusetumbleweed</guest_os_variant>
<guest_storage_path></guest_storage_path>
<guest_storage_type>disk</guest_storage_type>
<guest_storage_format>qcow2</guest_storage_format>
<guest_storage_label>gpt</guest_storage_label>
<guest_storage_size>40</guest_storage_size>
<guest_storage_others>backing_store=/var/lib/libvirt/images/ALP-VM.x86_64-0.0.1-kvm-back.qcow2,backing_format=qcow2,bus=virtio,cache=none</guest_storage_others>
<guest_network_type>virtual_network</guest_network_type>
<guest_network_device>br123</guest_network_device>
<guest_network_others></guest_network_others>
<guest_netaddr>192.168.123.0/24</guest_netaddr>
<guest_ipaddr></guest_ipaddr>
<guest_ipaddr_static>false</guest_ipaddr_static>
<guest_macaddr></guest_macaddr>
<guest_virtual_network>test-virt-net</guest_virtual_network>
<guest_graphics>vnc</guest_graphics>
<guest_controller></guest_controller>
<guest_input></guest_input>
<guest_serial>pty</guest_serial>
<guest_parallel></guest_parallel>
<guest_channel></guest_channel>
<guest_console></guest_console>
<guest_hostdev></guest_hostdev>
<guest_filesystem></guest_filesystem>
<guest_sound></guest_sound>
<guest_watchdog></guest_watchdog>
<guest_video>cirrus</guest_video>
<guest_smartcard></guest_smartcard>
<guest_redirdev></guest_redirdev>
<guest_memballoon></guest_memballoon>
<guest_tpm></guest_tpm>
<guest_rng></guest_rng>
<guest_panic></guest_panic>
<guest_memdev></guest_memdev>
<guest_vsock></guest_vsock>
<guest_iommu></guest_iommu>
<guest_iothreads></guest_iothreads>
<guest_seclabel></guest_seclabel>
<guest_keywrap></guest_keywrap>
<guest_cputune></guest_cputune>
<guest_memtune></guest_memtune>
<guest_blkiotune></guest_blkiotune>
<guest_memorybacking></guest_memorybacking>
<guest_features></guest_features>
<guest_clock></guest_clock>
<guest_power_management></guest_power_management>
<guest_events></guest_events>
<guest_resource></guest_resource>
<guest_sysinfo>type=fwcfg,entry0.name="opt/com.coreos/config",entry0.file="/var/lib/libvirt/images/VIRT_TEST_VM_config.ign"</guest_sysinfo>
<guest_qemu_command></guest_qemu_command>
<guest_launchSecurity></guest_launchSecurity>
<guest_autostart></guest_autostart>
<guest_transient></guest_transient>
<guest_destroy_on_exit></guest_destroy_on_exit>
<guest_autoconsole></guest_autoconsole>
<guest_noautoconsole>false</guest_noautoconsole>
<guest_noreboot></guest_noreboot>
<guest_default_target>graphical</guest_default_target>
<guest_do_registration>false</guest_do_registration>
<guest_registration_server></guest_registration_server>
<guest_registration_username></guest_registration_username>
<guest_registration_password></guest_registration_password>
<guest_registration_extensions></guest_registration_extensions>
</guest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0"?>
<guest>
<guest_os_name>sles</guest_os_name>
<guest_version>15-sp4</guest_version>
<guest_version_major>15</guest_version_major>
<guest_version_minor>4</guest_version_minor>
<guest_os_word_length>64</guest_os_word_length>
<guest_build>gm</guest_build>
<host_hypervisor_uri></host_hypervisor_uri>
<host_virt_type>kvm</host_virt_type>
<guest_virt_type>hvm</guest_virt_type>
<guest_machine_type></guest_machine_type>
<guest_arch>x86_64</guest_arch>
<guest_name></guest_name>
<guest_domain_name></guest_domain_name>
<guest_memory>2048,maxmemory=4096</guest_memory>
<guest_vcpus>2,maxvcpus=4</guest_vcpus>
<guest_cpumodel></guest_cpumodel>
<guest_metadata></guest_metadata>
<guest_boot_settings>uefi</guest_boot_settings>
<guest_secure_boot>true</guest_secure_boot>
<guest_power_management>suspend_to_mem.enabled=yes,suspend_to_disk.enabled=yes</guest_power_management>
<guest_xpath>./os/boot[@dev='hd']/@order=1#./os/boot[@dev='network']/@order=2</guest_xpath>
<guest_installation_automation>autoyast</guest_installation_automation>
<guest_installation_automation_file>sles_15_plus_kvm_hvm_guest_graphical_x86_64.xml</guest_installation_automation_file>
<guest_installation_method>location</guest_installation_method>
<guest_installation_extra_args>sshd=1#sshpassword=nots3cr3t#console=ttyS0,115200n8#textmode=1#rd.debug#rd.memdebug=4#rd.udev.debug</guest_installation_extra_args>
<guest_installation_wait></guest_installation_wait>
<guest_installation_method_others></guest_installation_method_others>
<guest_installation_media>http://openqa.suse.de/assets/repo/fixed/SLE-15-SP4-Full-x86_64-GM-Media1/</guest_installation_media>
<guest_installation_fine_grained></guest_installation_fine_grained>
<guest_os_variant></guest_os_variant>
<guest_storage_path></guest_storage_path>
<guest_storage_type>disk</guest_storage_type>
<guest_storage_format>qcow2</guest_storage_format>
<guest_storage_label>gpt</guest_storage_label>
<guest_storage_size></guest_storage_size>
<guest_storage_others></guest_storage_others>
<guest_network_type>virtual_network</guest_network_type>
<guest_network_device>br123</guest_network_device>
<guest_network_others></guest_network_others>
<guest_netaddr>192.168.123.0/24</guest_netaddr>
<guest_ipaddr></guest_ipaddr>
<guest_ipaddr_static>false</guest_ipaddr_static>
<guest_virtual_network>test-virt-net</guest_virtual_network>
<guest_macaddr></guest_macaddr>
<guest_graphics>vnc</guest_graphics>
<guest_controller></guest_controller>
<guest_input></guest_input>
<guest_serial>pty</guest_serial>
<guest_parallel></guest_parallel>
<guest_channel></guest_channel>
<guest_console></guest_console>
<guest_hostdev></guest_hostdev>
<guest_filesystem></guest_filesystem>
<guest_sound></guest_sound>
<guest_watchdog></guest_watchdog>
<guest_video>cirrus</guest_video>
<guest_smartcard></guest_smartcard>
<guest_redirdev></guest_redirdev>
<guest_memballoon></guest_memballoon>
<guest_tpm></guest_tpm>
<guest_rng></guest_rng>
<guest_panic></guest_panic>
<guest_memdev></guest_memdev>
<guest_vsock></guest_vsock>
<guest_iommu></guest_iommu>
<guest_iothreads></guest_iothreads>
<guest_seclabel></guest_seclabel>
<guest_keywrap></guest_keywrap>
<guest_cputune></guest_cputune>
<guest_memtune></guest_memtune>
<guest_blkiotune></guest_blkiotune>
<guest_memorybacking></guest_memorybacking>
<guest_features></guest_features>
<guest_clock></guest_clock>
<guest_events></guest_events>
<guest_resource></guest_resource>
<guest_sysinfo></guest_sysinfo>
<guest_qemu_command></guest_qemu_command>
<guest_launchSecurity></guest_launchSecurity>
<guest_autostart></guest_autostart>
<guest_transient></guest_transient>
<guest_destroy_on_exit></guest_destroy_on_exit>
<guest_autoconsole>text</guest_autoconsole>
<guest_noreboot></guest_noreboot>
<guest_default_target>graphical</guest_default_target>
<guest_do_registration>true</guest_do_registration>
<guest_registration_server></guest_registration_server>
<guest_registration_username>[email protected]</guest_registration_username>
<guest_registration_password></guest_registration_password>
<guest_registration_extensions>sle-module-legacy#sle-module-basesystem#sle-module-server-applications#sle-module-desktop-applications#sle-module-web-scripting</guest_registration_extensions>
</guest>

5 changes: 3 additions & 2 deletions lib/alp_workloads/kvm_workload_utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ sub config_host_and_kvm_container {
}

sub cleanup_host_and_kvm_container {
assert_script_run("if $ct_engine ps | grep libvirtd; then kvm-container-manage.sh stop;fi");
script_run("if $ct_engine ps | grep libvirtd; then kvm-container-manage.sh stop;fi");
validate_script_output("$ct_engine ps", sub { $_ !~ 'libvirtd' });
assert_script_run("if $ct_engine ps --all | grep libvirtd; then kvm-container-manage.sh rm;fi");
assert_script_run("if which kvm-container-manage.sh;then kvm-container-manage.sh uninstall;fi");
validate_script_output("$ct_engine ps --all", sub { $_ !~ 'libvirtd' });
Expand Down Expand Up @@ -135,7 +136,7 @@ sub install_tools_within_kvm_container {
my $_tools_to_install = shift;

# The packages needed by guest installation and following tests`
$_tools_to_install //= "wget screen xmlstarlet yast2-schema python3 nmap openssh hostname gawk expect supportutils systemd-coredump";
$_tools_to_install //= "wget screen xmlstarlet yast2-schema python3 nmap openssh hostname gawk expect supportutils systemd-coredump util-linux-systemd file iputils";

assert_script_run("clear");
assert_screen('in-libvirtd-container-bash');
Expand Down
1 change: 0 additions & 1 deletion lib/ipmi_backend_utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ sub set_grub_terminal_and_timeout {
}

sub reconnect_when_ssh_console_broken {

# Switch to sol console to check serial console output
# It is useful in the case of host crash and reboot
record_info("WARN", "ssh connection is broken and switch to SOL console", result => 'fail');
Expand Down
2 changes: 1 addition & 1 deletion lib/virt_autotest/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ sub check_host_health {
# Welcome everybody to extend this function
sub check_guest_health {
my $vm = shift;
return unless is_x86_64 and guest_is_sle($vm);
return unless is_x86_64 and ($vm =~ /sle|alp/i);

#check if guest is still alive
validate_script_output "virsh domstate $vm", sub { /running/ };
Expand Down
64 changes: 47 additions & 17 deletions lib/virt_autotest/virtual_network_utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Summary: virtual_network_utils:
# This file provides fundamental utilities for virtual network.
# Maintainer: Leon Guo <[email protected]>
# Maintainer: Leon Guo <[email protected]>, [email protected]

package virt_autotest::virtual_network_utils;

Expand All @@ -32,7 +32,7 @@ our @EXPORT
= qw(download_network_cfg prepare_network restore_standalone destroy_standalone restart_network
restore_guests restore_network destroy_vir_network restore_libvirt_default enable_libvirt_log pload_debug_log
check_guest_status check_guest_module check_guest_ip save_guest_ip test_network_interface hosts_backup
hosts_restore get_free_mem get_active_pool_and_available_space clean_all_virt_networks setup_vm_simple_dns_with_ip);
hosts_restore get_free_mem get_active_pool_and_available_space clean_all_virt_networks setup_vm_simple_dns_with_ip get_guest_ip_from_vnet_with_mac update_simple_dns_for_all_vm);

sub check_guest_ip {
my ($guest, %args) = @_;
Expand All @@ -44,17 +44,30 @@ sub check_guest_ip {

# ensure guest is still alive
if (script_output("virsh domstate $guest") eq "running") {
script_run "sed -i '/ $guest /d' /etc/hosts";
my $mac_guest = script_output("virsh domiflist $guest | grep $net | grep -oE \"[[:xdigit:]]{2}(:[[:xdigit:]]{2}){5}\"");
my $syslog_cmd = "journalctl --no-pager | grep DHCPACK";
script_retry "$syslog_cmd | grep $mac_guest | grep -oE \"([0-9]{1,3}[\.]){3}[0-9]{1,3}\"", delay => 90, retry => 9, timeout => 90;
my $gi_guest = script_output("$syslog_cmd | grep $mac_guest | tail -1 | grep -oE \"([0-9]{1,3}[\.]){3}[0-9]{1,3}\"");
assert_script_run "echo '$gi_guest $guest # virtualization' >> /etc/hosts";
my $gi_guest = '';
if (is_alp) {
$gi_guest = get_guest_ip_from_vnet_with_mac($mac_guest, $net);
} else {
my $syslog_cmd = "journalctl --no-pager | grep DHCPACK";
script_retry "$syslog_cmd | grep $mac_guest | grep -oE \"([0-9]{1,3}[\.]){3}[0-9]{1,3}\"", delay => 90, retry => 9, timeout => 90;
$gi_guest = script_output("$syslog_cmd | grep $mac_guest | tail -1 | grep -oE \"([0-9]{1,3}[\.]){3}[0-9]{1,3}\"");
}
setup_vm_simple_dns_with_ip($guest, $gi_guest);
script_retry("nmap $guest -PN -p ssh | grep open", delay => 30, retry => 6, timeout => 60) if ($guest =~ m/sles-11/i);
die "Ping $guest failed !" if (script_retry("ping -c5 $guest", delay => 30, retry => 6, timeout => 60) ne 0);
}
}

sub get_guest_ip_from_vnet_with_mac {
my ($mac, $net) = @_;

my $cmd = "virsh net-dhcp-leases $net | sed '1,2d' | grep '$mac'";
script_retry($cmd, delay => 3, retry => 20);
$cmd .= " | gawk '{print \$5 }' | sed -r 's/\\\/[0-9]+//'";
return script_output($cmd);
}

sub check_guest_module {
my ($guest, %args) = @_;
my $module = $args{module};
Expand All @@ -75,13 +88,17 @@ sub save_guest_ip {

# If we don't know guest's address or the address is wrong so the guest is not responding to ICMP
if (script_run("grep $guest /etc/hosts") != 0 || script_retry("ping -c3 $guest", delay => 6, retry => 30, die => 0) != 0) {
script_run "sed -i '/ $guest /d' /etc/hosts";
assert_script_run "virsh domiflist $guest";
my $mac_guest = script_output("virsh domiflist $guest | grep $name | grep -oE \"[[:xdigit:]]{2}(:[[:xdigit:]]{2}){5}\"");
my $syslog_cmd = is_sle('=11-sp4') ? 'grep DHCPACK /var/log/messages' : 'journalctl --no-pager | grep DHCPACK';
script_retry "$syslog_cmd | grep $mac_guest | grep -oE \"([0-9]{1,3}[\.]){3}[0-9]{1,3}\"", delay => 90, retry => 9, timeout => 90;
my $gi_guest = script_output("$syslog_cmd | grep $mac_guest | tail -1 | grep -oE \"([0-9]{1,3}[\.]){3}[0-9]{1,3}\"");
assert_script_run "echo '$gi_guest $guest # virtualization' >> /etc/hosts";
my $gi_guest = '';
if (is_alp) {
$gi_guest = get_guest_ip_from_vnet_with_mac($mac_guest, $name);
} else {
my $syslog_cmd = is_sle('=11-sp4') ? 'grep DHCPACK /var/log/messages' : 'journalctl --no-pager | grep DHCPACK';
script_retry "$syslog_cmd | grep $mac_guest | grep -oE \"([0-9]{1,3}[\.]){3}[0-9]{1,3}\"", delay => 90, retry => 9, timeout => 90;
$gi_guest = script_output("$syslog_cmd | grep $mac_guest | tail -1 | grep -oE \"([0-9]{1,3}[\.]){3}[0-9]{1,3}\"");
}
setup_vm_simple_dns_with_ip($guest, $gi_guest);
script_retry("nmap $guest -PN -p ssh | grep open", delay => 30, retry => 6, timeout => 60) if ($guest =~ m/sles-11/i);
die "Ping $guest failed !" if (script_retry("ping -c5 $guest", delay => 30, retry => 6, timeout => 60) ne 0);
}
Expand All @@ -96,7 +113,7 @@ sub test_network_interface {
my $routed = $args{routed} // 0;
my $target = $args{target} // script_output("dig +short openqa.suse.de");

check_guest_ip("$guest") if (is_sle('>15') && ($isolated == 1) && get_var('VIRT_AUTOTEST'));
check_guest_ip("$guest", net => $net) if ((is_sle('>15') || is_alp) && ($isolated == 1) && get_var('VIRT_AUTOTEST'));

save_guest_ip("$guest", name => $net);

Expand Down Expand Up @@ -246,7 +263,7 @@ sub restart_network {

sub restore_guests {
return if get_var('INCIDENT_ID'); # QAM does not recreate guests every time
my $get_vm_hostnames = "virsh list --all | grep -e sles -e opensuse | awk \'{print \$2}\'";
my $get_vm_hostnames = "virsh list --all | grep -e sles -e opensuse -e alp -i | awk \'{print \$2}\'";
my $vm_hostnames = script_output($get_vm_hostnames, 30, type_command => 0, proceed_on_failure => 0);
my @vm_hostnames_array = split(/\n+/, $vm_hostnames);
foreach (@vm_hostnames_array)
Expand Down Expand Up @@ -293,8 +310,8 @@ sub upload_debug_log {

sub check_guest_status {
my $wait_script = "30";
my $vm_types = "sles";
my $get_vm_hostnames = "virsh list --all | grep $vm_types | awk \'{print \$2}\'";
my $vm_types = "sles|alp";
my $get_vm_hostnames = "virsh list --all | grep -E \"$vm_types\" -i | awk \'{print \$2}\'";
my $vm_hostnames = script_output($get_vm_hostnames, $wait_script, type_command => 0, proceed_on_failure => 0);
my @vm_hostnames_array = split(/\n+/, $vm_hostnames);
foreach (@vm_hostnames_array) {
Expand Down Expand Up @@ -323,7 +340,12 @@ sub get_active_pool_and_available_space {
# get some debug info about storage pool
script_run 'virsh pool-list --details';
# ensure the available disk space size for active pool
my $active_pool = script_output("virsh pool-list --persistent | grep -iv nvram | grep active | awk '{print \$1}'");
my $active_pool = '';
if (is_alp) {
$active_pool = script_output("virsh pool-list | grep -ivE \"nvram|boot\" | grep active | awk '{print \$1}'");
} else {
$active_pool = script_output("virsh pool-list --persistent | grep -iv nvram | grep active | awk '{print \$1}'");
}
my $available_size = script_output("virsh pool-info $active_pool | grep ^Available | awk '{print \$2}'");
my $pool_unit = script_output("virsh pool-info $active_pool | grep ^Available | awk '{print \$3}'");
# default available pool unit as GiB
Expand Down Expand Up @@ -362,4 +384,12 @@ sub setup_vm_simple_dns_with_ip {
record_info("Simple DNS setup in /etc/hosts for $_ip $_vm is successful!", script_output("cat /etc/hosts"));
}

sub update_simple_dns_for_all_vm {
my $_vnet = shift;

my $_cmd = "virsh list --all | grep -e sles -e opensuse -e alp -i | awk \'{print \$2}\'";
my $_vms = script_output($_cmd, 30, type_command => 0, proceed_on_failure => 0);
check_guest_ip("$_", net => $_vnet) foreach (split(/\n+/, $_vms));
}

1;
Loading

0 comments on commit ce7163e

Please sign in to comment.