Re: [tck PATCH] Don't assume the domain's network interface tap device is named "vnet0"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 04, 2018 at 09:52:52AM -0400, Laine Stump wrote:
> Some of the tests perform operations on the tap device of the test
> domain's network interface. They mostly assume that this tap device is
> named "vnet0", which is the case if there is no other domain running
> on the host, but isn't true if some other domain was running.
> 
> This patch adds a utility function
> NetworkHelpers::get_first_interface_target_dev($dom), which learns the
> name of the tap device for the first interface in the domain, and uses
> the result of that function instead of "vnet0".
> 
> It's an ugly name, but follows the pattern of other function names in
> that file. It also is very specific (it could have been parameterized
> to get the tap device name of other interfaces, but we only ever need
> the first). On the other hand, it causes the tests in question to
> succeed on my host when they previously failed. (If anyone wants the
> function to be named differently or be more flexible, I'd be happy to
> do that).

This 3rd paragraph could probably be after the "---", ie no need for
it to be part of git history.

> 
> Signed-off-by: Laine Stump <laine@xxxxxxxxx>
> ---
>  lib/Sys/Virt/TCK.pm                       | 3 ++-
>  lib/Sys/Virt/TCK/NetworkHelpers.pm        | 6 ++++++
>  scripts/domain/180-interface-parameters.t | 6 ++++--
>  scripts/nwfilter/100-ping-still-working.t | 3 ++-
>  scripts/nwfilter/210-no-mac-spoofing.t    | 3 ++-
>  scripts/nwfilter/230-no-mac-broadcast.t   | 3 ++-
>  scripts/nwfilter/240-no-arp-spoofing.t    | 3 ++-
>  7 files changed, 20 insertions(+), 7 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>



> 
> diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm
> index ac9c125..29280f6 100644
> --- a/lib/Sys/Virt/TCK.pm
> +++ b/lib/Sys/Virt/TCK.pm
> @@ -821,11 +821,12 @@ sub generic_machine_domain {
>              $dom->create();
>  
>              # Wait for the first boot to reach network setting
> +            my $iface = get_first_interface_target_dev($dom);
>              my $stats;
>              my $tries = 0;
>              do {
>                  sleep(10);
> -                $stats  = $dom->interface_stats("vnet0");
> +                $stats  = $dom->interface_stats($iface);
>                  $tries++;
>              } while ($stats->{"tx_packets"} < 10 && $tries < 10);
>  
> diff --git a/lib/Sys/Virt/TCK/NetworkHelpers.pm b/lib/Sys/Virt/TCK/NetworkHelpers.pm
> index 7bbce62..50ade0f 100644
> --- a/lib/Sys/Virt/TCK/NetworkHelpers.pm
> +++ b/lib/Sys/Virt/TCK/NetworkHelpers.pm
> @@ -10,6 +10,12 @@ sub get_first_macaddress {
>      return $mac;
>  }
>  
> +sub get_first_interface_target_dev {
> +    my $dom = shift;
> +    my $targetdev = xpath($dom, "string(/domain/devices/interface[1]/target/\@dev)");
> +    return $targetdev;
> +}
> +
>  sub get_network_ip {
>      my $conn = shift;
>      my $netname = shift;
> diff --git a/scripts/domain/180-interface-parameters.t b/scripts/domain/180-interface-parameters.t
> index d7866c0..66c7ed6 100644
> --- a/scripts/domain/180-interface-parameters.t
> +++ b/scripts/domain/180-interface-parameters.t
> @@ -33,6 +33,7 @@ use warnings;
>  use Test::More tests => 10;
>  
>  use Sys::Virt::TCK;
> +use Sys::Virt::TCK::NetworkHelpers;
>  use Test::Exception;
>  use File::stat;
>  
> @@ -59,12 +60,13 @@ diag "Set/Get interface parameters";
>  my %params = (Sys::Virt::Domain::BANDWIDTH_IN_AVERAGE=>1000, Sys::Virt::Domain::BANDWIDTH_IN_PEAK=>1001,
>                Sys::Virt::Domain::BANDWIDTH_IN_BURST=>1002, Sys::Virt::Domain::BANDWIDTH_OUT_AVERAGE=>1003,
>                Sys::Virt::Domain::BANDWIDTH_OUT_PEAK=>1004, Sys::Virt::Domain::BANDWIDTH_OUT_BURST=>1005);
> -lives_ok(sub {$dom->set_interface_parameters("vnet0", \%params)}, "Set vnet0 parameters");
> +my $iface = get_first_interface_target_dev($dom);
> +lives_ok(sub {$dom->set_interface_parameters($iface, \%params)}, "Set $iface parameters");
>  for my $key (sort keys %params) {
>       diag "Set $key => $params{$key} ";
>  }
>  
> -my $param = $dom->get_interface_parameters("vnet0", 0);
> +my $param = $dom->get_interface_parameters($iface, 0);
>  my $in_average = $param->{Sys::Virt::Domain::BANDWIDTH_IN_AVERAGE};
>  my $in_burst = $param->{Sys::Virt::Domain::BANDWIDTH_IN_BURST};
>  my $in_peak = $param->{Sys::Virt::Domain::BANDWIDTH_IN_PEAK};
> diff --git a/scripts/nwfilter/100-ping-still-working.t b/scripts/nwfilter/100-ping-still-working.t
> index 1bbd7c5..12f2c7c 100644
> --- a/scripts/nwfilter/100-ping-still-working.t
> +++ b/scripts/nwfilter/100-ping-still-working.t
> @@ -55,11 +55,12 @@ $dom->create;
>  ok($dom->get_id() > 0, "running domain has an ID > 0");
>  
>  diag "Waiting for guest to finish booting";
> +my $iface = get_first_interface_target_dev($dom);
>  my $stats;
>  my $tries = 0;
>  do {
>      sleep(10);
> -    $stats  = $dom->interface_stats("vnet0");
> +    $stats  = $dom->interface_stats($iface);
>      $tries++;
>  } while ($stats->{"tx_packets"} < 10 && $tries < 10);
>  
> diff --git a/scripts/nwfilter/210-no-mac-spoofing.t b/scripts/nwfilter/210-no-mac-spoofing.t
> index 7b74f94..99c5058 100644
> --- a/scripts/nwfilter/210-no-mac-spoofing.t
> +++ b/scripts/nwfilter/210-no-mac-spoofing.t
> @@ -59,11 +59,12 @@ $dom->create;
>  ok($dom->get_id() > 0, "running domain has an ID > 0");
>  
>  diag "Waiting for guest to finish booting";
> +my $iface = get_first_interface_target_dev($dom);
>  my $stats;
>  my $tries = 0;
>  do {
>      sleep(10);
> -    $stats  = $dom->interface_stats("vnet0");
> +    $stats  = $dom->interface_stats($iface);
>      $tries++;
>  } while ($stats->{"tx_packets"} < 10 && $tries < 10);
>  
> diff --git a/scripts/nwfilter/230-no-mac-broadcast.t b/scripts/nwfilter/230-no-mac-broadcast.t
> index ee2d43f..b65b3fc 100644
> --- a/scripts/nwfilter/230-no-mac-broadcast.t
> +++ b/scripts/nwfilter/230-no-mac-broadcast.t
> @@ -85,11 +85,12 @@ $dom->create;
>  ok($dom->get_id() > 0, "running domain has an ID > 0");
>  
>  diag "Waiting for guest to finish booting";
> +my $iface = get_first_interface_target_dev($dom);
>  my $stats;
>  my $tries = 0;
>  do {
>      sleep(10);
> -    $stats  = $dom->interface_stats("vnet0");
> +    $stats  = $dom->interface_stats($iface);
>      $tries++;
>  } while ($stats->{"tx_packets"} < 10 && $tries < 10);
>  
> diff --git a/scripts/nwfilter/240-no-arp-spoofing.t b/scripts/nwfilter/240-no-arp-spoofing.t
> index 350b604..69851b6 100644
> --- a/scripts/nwfilter/240-no-arp-spoofing.t
> +++ b/scripts/nwfilter/240-no-arp-spoofing.t
> @@ -58,11 +58,12 @@ $dom->create;
>  ok($dom->get_id() > 0, "running domain has an ID > 0");
>  
>  diag "Waiting for guest to finish booting";
> +my $iface = get_first_interface_target_dev($dom);
>  my $stats;
>  my $tries = 0;
>  do {
>      sleep(10);
> -    $stats  = $dom->interface_stats("vnet0");
> +    $stats  = $dom->interface_stats($iface);
>      $tries++;
>  } while ($stats->{"tx_packets"} < 10 && $tries < 10);
>  
> -- 
> 2.14.4
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux