[libvirt] [libvirt-tck] [RFC] 802.1Qbg test scripts
Daniel P. Berrange
berrange at redhat.com
Thu Oct 7 12:23:01 UTC 2010
On Thu, Oct 07, 2010 at 02:07:23PM +0200, Gerhard Stenzel wrote:
> On Wed, 2010-10-06 at 12:52 +0100, Daniel P. Berrange wrote:
> > I don't like this approach. JUst add an optional parameter
> > to the build_domain methods
> >
> > my $mode = @_ ? shift : "bridge";
> >
> >
> > eg so it default to traditional bridging, but you can pass
> > in 'vepa' if you desire to change it. Or something like
> > that.
>
> Thanks for the feedback. The changes are in the attached new versions of
> the patches. It would be great if you could push at least
> modify_library_functions.patch to the git.
>
> --
> Best regards,
>
> Gerhard Stenzel,
> -----------------------------------------------------------------------------------------------------------------------------------
> IBM Deutschland Research & Development GmbH
> Vorsitzender des Aufsichtsrats: Martin Jetter
> Geschäftsführung: Dirk Wittkopp
> Sitz der Gesellschaft: Böblingen
> Registergericht: Amtsgericht Stuttgart, HRB 243294
> Index: libvirt-tck/scripts/nwfilter/300-vsitype.t
> ===================================================================
> --- /dev/null
> +++ libvirt-tck/scripts/nwfilter/300-vsitype.t
> @@ -0,0 +1,71 @@
> +# -*- perl -*-
> +#
> +# Copyright (C) 2010 IBM Corp.
> +#
> +# This program is free software; You can redistribute it and/or modify
> +# it under the GNU General Public License as published by the Free
> +# Software Foundation; either version 2, or (at your option) any
> +# later version
> +#
> +# The file "LICENSE" distributed along with this file provides full
> +# details of the terms and conditions
> +#
> +
> +=pod
> +
> +=head1 NAME
> +
> +nwfilter/300-vsitype.t - verify VSI informatio
> +
> +=head1 DESCRIPTION
> +
> +The test case validates that the corrrect VSI is set in the adjacent switch
> +
> +=cut
> +
> +use strict;
> +use warnings;
> +
> +use Test::More tests => 3;
> +
> +use Sys::Virt::TCK;
> +use Sys::Virt::TCK::NetworkHelpers;
> +use Test::Exception;
> +use Net::SSH::Perl;
> +use File::Spec::Functions qw(catfile catdir rootdir);
> +
> +my $tck = Sys::Virt::TCK->new();
> +my $conn = eval { $tck->setup(); };
> +BAIL_OUT "failed to setup test harness: $@" if $@;
> +END {
> + $tck->cleanup if $tck;
> +}
Since most systems won't yet have lldptool present, you should
surround the entire test from here onwards in a big 'SKIP : {}'
block. eg
SKIP: {
skip "lldptool not present", 3 unless -e "/usr/sbin/lldptool";
.....
> +
> +# creating domain
> +my $dom1;
> +my $dom_name ="tck8021Qbgtest";
> +
> +# speficy mode="vepa" for a direct interface
> +$dom1 = prepare_test_disk_and_vm($tck, $conn, $dom_name, "vepa");
> +$dom1->create();
> +
> +ok($dom1->get_id() > 0, "running domain has an ID > 0");
> +my $xml = $dom1->get_xml_description;
> +diag $xml;
> +my $mac1 = get_first_macaddress($dom1);
> +diag "mac is $mac1";
> +
> +sleep(30);
> +
> +# check vsi information
> +diag "Verifying VSI information using lldptool";
> +my $lldptool = `/usr/sbin/lldptool -t -i eth2 -V vdp mode`;
> +diag $lldptool;
> +# check if instance is listed
> +ok($lldptool =~ "instance", "check instance");
> +ok($lldptool =~ $mac1, "check mac as well");
> +
> +
> +shutdown_vm_gracefully($dom1);
> +
> +exit 0;
};
This will ensure that the TCK simply skips over the test
rather than showing a failure
> Index: libvirt-tck/lib/Sys/Virt/TCK/DomainBuilder.pm
> ===================================================================
> --- libvirt-tck.orig/lib/Sys/Virt/TCK/DomainBuilder.pm
> +++ libvirt-tck/lib/Sys/Virt/TCK/DomainBuilder.pm
> @@ -410,8 +410,25 @@ sub as_xml {
>
> $w->emptyTag("mac",
> address => $interface->{mac});
> - $w->emptyTag("source",
> - network => $interface->{source});
> +
> + if( $interface->{dev}) {
> + $w->emptyTag("source",
> + dev => $interface->{dev},
> + mode => $interface->{mode});
> + } else {
> + $w->emptyTag("source",
> + network => $interface->{source});
> + }
> + if( $interface->{virtualport}) {
> + $w->startTag("virtualport",
> + type => $interface->{virtualport});
> + $w->emptyTag("parameters",
> + managerid => '1',
> + typeid => '2',
> + typeidversion => '3',
> + instanceid => '40000000-0000-0000-0000-000000000000');
> + $w->endTag("virtualport");
> + }
> $w->emptyTag("model",
> type => $interface->{model});
> if( $interface->{filterref}) {
> Index: libvirt-tck/lib/Sys/Virt/TCK/NetworkHelpers.pm
> ===================================================================
> --- libvirt-tck.orig/lib/Sys/Virt/TCK/NetworkHelpers.pm
> +++ libvirt-tck/lib/Sys/Virt/TCK/NetworkHelpers.pm
> @@ -42,6 +42,7 @@ sub build_cdrom_ks_image {
> sub build_domain{
> my $tck = shift;
> my $domain_name = shift;
> + my $mode = @_ ? shift : "bridge";
>
> my $guest;
> my $mac = "52:54:00:11:11:11";
> @@ -50,10 +51,19 @@ sub build_domain{
> my $filterref = "clean-traffic";
> my $network = "network";
> my $source = "default";
> + my $dev = "eth2";
> + my $virtualport;
>
> my ($cdrom, $ksurl) = build_cdrom_ks_image($tck);
>
> my $guest = $tck->generic_domain($domain_name);
> +
> + # change the type of network connection for 802.1Qbg tests
> + if ($mode eq "vepa") {
> + $network ="direct";
> + $virtualport = "802.1Qbg";
> + }
> +
> # We want a bigger disk than normal
> $guest->rmdisk();
> my $diskpath = $tck->create_sparse_disk("nwfilter", "main.img", 2048);
> @@ -79,12 +89,23 @@ sub build_domain{
> } else {
> diag "Do normal boot";
> $guest->clear_kernel_initrd_cmdline();
> - $guest->interface(type => $network,
> - source => $source,
> - model => $model,
> - mac => $mac,
> - filterref => $filterref);
> + if ($mode eq "vepa") {
> + $guest->interface(type => $network,
> + source => $source,
> + model => $model,
> + mac => $mac,
> + dev => $dev,
> + mode => $mode,
> + virtualport => $virtualport);
> + } else {
> + $guest->interface(type => $network,
> + source => $source,
> + model => $model,
> + mac => $mac,
> + filterref => $filterref);
> + }
> }
> +
> # common configuration
> $guest->maxmem("524288");
> $guest->memory("524288");
> @@ -111,8 +132,9 @@ sub prepare_test_disk_and_vm{
> my $tck = shift;
> my $conn = shift;
> my $domain_name = shift;
> + my $mode = @_ ? shift : "bridge";
>
> - my ($guest, $need_install) = build_domain($tck, $domain_name);
> + my ($guest, $need_install) = build_domain($tck, $domain_name, $mode);
> if ($need_install) {
> my $dom = $conn->define_domain($guest->as_xml);
> diag "Starting installation domain";
> @@ -129,7 +151,7 @@ sub prepare_test_disk_and_vm{
> diag " .. done";
> }
>
> - ($guest, $need_install) = build_domain($tck, $domain_name);
> + ($guest, $need_install) = build_domain($tck, $domain_name, $mode);
> if ($need_install) {
> die "guest install appears to have failed";
> }
This all looks fine now.
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
More information about the libvir-list
mailing list