diff --git a/lib/virt_autotest/utils.pm b/lib/virt_autotest/utils.pm index ced7abb95227..9de894753378 100644 --- a/lib/virt_autotest/utils.pm +++ b/lib/virt_autotest/utils.pm @@ -185,7 +185,7 @@ sub is_hyperv_virtualization { # Return 1 if it is SLES MU virt test, otherwise return 0 sub is_sles_mu_virt_test { - return is_sle && get_var('REGRESSION') =~ /xen|kvm|qemu|hyperv|vmware/ && !get_var("VIRT_AUTOTEST"); + return is_sle && get_var('REGRESSION', '') =~ /xen|kvm|qemu|hyperv|vmware/ && !get_var("VIRT_AUTOTEST"); } #return 1 if it is a fv guest judging by name diff --git a/tests/virt_autotest/virt_utils.pm b/tests/virt_autotest/virt_utils.pm index 71d8ef581b33..edcade65dc0f 100644 --- a/tests/virt_autotest/virt_utils.pm +++ b/tests/virt_autotest/virt_utils.pm @@ -403,95 +403,62 @@ sub get_guest_list { return $guest_list; } -# Download guest image and xml from a NFS location to local -# the image and xml is coming from a guest installation testsuite -# need set SKIP_GUEST_INSTALL=1 in the test suite settings -# return the account of the guests downloaded -# only available on x86_64 +# Download guest image and xml which are defined in ASSET_* +# fg. ASSET_10=guest_%-GUEST_LIST%fv-def-net_on-host_%DISTRI%-%VERSION%_build%BUILD%_%SYSTEM_ROLE%_%ARCH%.xml +# ASSET_11=guest_%-GUEST_LIST%fv-def-net_on-host_%DISTRI%-%VERSION%_build%BUILD%_%SYSTEM_ROLE%_%ARCH%.disk +# Need set SKIP_GUEST_INSTALL=1 in the test suite settings +# Return the account of the guests downloaded +# Only available on x86_64 sub download_guest_assets { # guest_pattern is a string, like sles-11-sp4-64, may or may not with pv or fv given. - my ($expected_guests, $vm_xml_dir) = @_; - - # mount the remote NFS location of guest assets - # OPENQA_URL="localhost" in local openQA instead of the IP, so the line below need to be turned on and set to the webUI IP when you are using local openQA - # Tips: Using local openQA, you need "rcnfs-server start & vi /etc/exports; exportfs -r") - # set OPENQA_URL="your_ip" on openQA web UI - my $openqa_server = get_required_var('OPENQA_URL'); - - # check if vm xml files have been uploaded - my @available_guests = (); - foreach my $guest (split "\n", $expected_guests) { - my $guest_asset = generate_guest_asset_name("$guest"); - my $vm_disk_url = $openqa_server . "/assets/other/" . $guest_asset . '.disk'; - $vm_disk_url =~ s#^(?!http://)(.*)$#http://$1#; #add 'http://' at beginning if needed. - if (head($vm_disk_url)) { - push @available_guests, $guest; - } - else { - record_info('Softfail', "$vm_disk_url not found!", result => 'softfail'); - } - } - return 0 unless @available_guests; + my ($guests_list, $vm_xml_dir) = @_; # clean up vm stuff - my $mount_point = "/tmp/remote_guest"; - script_run "[ -d $mount_point ] && { if findmnt $mount_point; then umount $mount_point; rm -rf $mount_point; fi }"; - script_run "mkdir -p $mount_point"; script_run "[ -d $vm_xml_dir ] && rm -rf $vm_xml_dir; mkdir -p $vm_xml_dir"; my $disk_image_dir = script_output "source /usr/share/qa/virtautolib/lib/virtlib; get_vm_disk_dir"; - script_run "umount $disk_image_dir; rm -rf $disk_image_dir/*"; script_run "[ -d /tmp/prj3_guest_migration/ ] && rm -rf /tmp/prj3_guest_migration/" if get_var('VIRT_NEW_GUEST_MIGRATION_SOURCE'); - # tip: nfs4 is not supported on sles12sp4, so use '-t nfs' instead of 'nfs4' here. - $openqa_server =~ s/^http:\/\///; - my $remote_export_dir = "/var/lib/openqa/factory/other/"; - assert_script_run("mount -t nfs $openqa_server:$remote_export_dir $mount_point", 120); - - # copy guest images and xml files to local - # test aborts if failing in copying all the guests - my $guest_count = 0; - foreach my $guest (@available_guests) { - my $guest_asset = generate_guest_asset_name("$guest"); - my $remote_guest_xml_file = $guest_asset . '.xml'; - my $remote_guest_disk = $guest_asset . '.disk'; - - # download vm xml file - my $rc = script_run("cp $mount_point/$remote_guest_xml_file $vm_xml_dir/$guest.xml", 60); - if ($rc) { - record_info('Softfail', "Failed copying: $mount_point/$remote_guest_xml_file", result => 'softfail'); - next; - } - script_run("ls -l $vm_xml_dir", 10); - save_screenshot; - - # download vm disk files - my $local_guest_image = script_output "grep ' 'softfail'); - next; + # check if vm xml files have been uploaded + my @guests = split "\n", $guests_list; + my @downloaded_guests; + foreach my $guest (@guests) { + my $guest_asset_name = generate_guest_asset_name("$guest"); + for my $i (1 .. @guests) { + # ASSET_n0: put the guest xml file + # ASSET_n1: put the guest disk file + if (get_var("ASSET_${i}0", "") =~ /$guest_asset_name/) { + + # Download the guest xml file + script_run("curl " . autoinst_url("/assets/other/" . get_var("ASSET_${i}0")) . " -o $vm_xml_dir/$guest.xml"); + script_run("ls -l $vm_xml_dir"); + + # Download the guest disk file + my $local_guest_image = script_output "grep ' 'softfail') unless grep $guest, @downloaded_guests; } - # umount - script_run("umount $mount_point"); - - return $guest_count; + record_info("Downloaded guests", "@downloaded_guests") if @downloaded_guests; + return @downloaded_guests; } sub is_installed_equal_upgrade_major_release {