[libvirt] [PATCH tck 0/5] Misc. TCK cleanups

While running TCK on qemu, lxc and xen, I've ran into a few issues worth fixing upstream. The patches in this series are mainly focused on fixing minor typos, or safeguarding against failures in non-qemu environments. Depending on how interested people are in running TCK with xen, I can provide a few additional patches. Mike Latimer (5): hooks_051-return0 nwfilter_050-handle-failures hooks_qemu-only_skip TCK-check_uri TCK-eval-snapshots-list lib/Sys/Virt/TCK.pm | 3 ++- lib/Sys/Virt/TCK/Capabilities.pm | 6 ++++-- scripts/hooks/051-daemon-hook.t | 6 +++++- scripts/hooks/052-domain-hook.t | 2 +- scripts/nwfilter/nwfilter2vmtest.sh | 4 +++- 5 files changed, 15 insertions(+), 6 deletions(-) -- 1.8.4.5

Despite running all subtests successfully, hooks/051-daemon-hook.t ends with a return code of 141. This is due to the connection to tck not being cleaned up properly after libvirtd is restarted in the middle of the test. Ignoring the SIGPIPE and specifically undefining $tck allows the test to complete with a return code of 0 (which is helpful when running the full libvirt-tck kit). --- scripts/hooks/051-daemon-hook.t | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/hooks/051-daemon-hook.t b/scripts/hooks/051-daemon-hook.t index 165cf4e..da46edf 100644 --- a/scripts/hooks/051-daemon-hook.t +++ b/scripts/hooks/051-daemon-hook.t @@ -163,5 +163,9 @@ SKIP: { ok(`service libvirtd status` =~ /running/, "libvirtd is running"); $hook->cleanup(); + + # Restarting libvirtd broke the tck connection, so ignore the sigpipe and remove $tck + $SIG{PIPE} = 'IGNORE'; + undef $tck; }; -- 1.8.4.5

If nwfilter/050-apply-verify-host.t fails to start a test VM, a typo causes the word 'Domain' to be executed as a command after undefining the VM: ./nwfilter2vmtest.sh: line 425: Domain: command not found Also, if either one of the test VM fails to be created, the test filter should be deleted before exiting the test. --- scripts/nwfilter/nwfilter2vmtest.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/nwfilter/nwfilter2vmtest.sh b/scripts/nwfilter/nwfilter2vmtest.sh index ca2abbb..4fae831 100644 --- a/scripts/nwfilter/nwfilter2vmtest.sh +++ b/scripts/nwfilter/nwfilter2vmtest.sh @@ -429,7 +429,7 @@ EOF echo "Press enter." read enter fi - $(${VIRSH} undefine ${vmname}) + ${VIRSH} undefine ${vmname} return 1 fi @@ -649,6 +649,7 @@ main() { createVM "${vm1}" "tck-testcase" "10.2.2.2" "52:54:0:0:0:1" "${flags}" if [ $? -ne 0 ]; then echo "Could not create VM ${vm1}. Exiting." + deleteTestFilter "${flags}" exit 1 fi @@ -657,6 +658,7 @@ main() { if [ $? -ne 0 ]; then echo "Could not create VM ${vm2}. Exiting." destroyVM "${vm1}" "${flags}" + deleteTestFilter "${flags}" exit 1 fi -- 1.8.4.5

Correct the order of parameters passed to skip to ensure the following tests are only executed under qemu and lxc environments: hooks/051-daemon-hook.t hooks/052-domain-hook.t --- scripts/hooks/051-daemon-hook.t | 2 +- scripts/hooks/052-domain-hook.t | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/hooks/051-daemon-hook.t b/scripts/hooks/051-daemon-hook.t index da46edf..61909c1 100644 --- a/scripts/hooks/051-daemon-hook.t +++ b/scripts/hooks/051-daemon-hook.t @@ -43,7 +43,7 @@ END { $tck->cleanup if $tck; } SKIP: { my $uri = $conn->get_uri(); - skip 12, "NOT using QEMU/LXC driver" unless + skip "NOT using QEMU/LXC driver", 12 unless $uri eq "qemu:///system" or $uri eq "lxc:///"; my $hook = Sys::Virt::TCK::Hooks->new(type => 'daemon', diff --git a/scripts/hooks/052-domain-hook.t b/scripts/hooks/052-domain-hook.t index 460d72d..cdd70af 100644 --- a/scripts/hooks/052-domain-hook.t +++ b/scripts/hooks/052-domain-hook.t @@ -46,7 +46,7 @@ END { $tck->cleanup if $tck; } SKIP: { my $uri = $conn->get_uri(); - skip 12, "Not using QEMU/LXC driver" unless + skip "NOT using QEMU/LXC driver", 12 unless $uri eq "qemu:///system" or $uri eq "lxc:///"; my $xml = $tck->generic_domain(name => "tck")->as_xml; -- 1.8.4.5

Under some environments (such as Xen), there may not be a uri_transport defined. As this is not required, ensure the value is defined before attempting to use it --- lib/Sys/Virt/TCK/Capabilities.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Sys/Virt/TCK/Capabilities.pm b/lib/Sys/Virt/TCK/Capabilities.pm index 8b79db4..281f41e 100644 --- a/lib/Sys/Virt/TCK/Capabilities.pm +++ b/lib/Sys/Virt/TCK/Capabilities.pm @@ -115,8 +115,10 @@ sub _parse_host_migration { $mig->{transports} = []; my $trans = $node->first_child("uri_transports"); - foreach my $child ($trans->children("uri_transport")) { - push @{$mig->{transports}}, $child->text; + if (defined $trans) { + foreach my $child ($trans->children("uri_transport")) { + push @{$mig->{transports}}, $child->text; + } } $self->{host}->{migration} = $mig; -- 1.8.4.5

When TCK cleans up a test domain, existing snapshots are deleted. However, not all drivers (e.g. libxl) support snapshots. When such a driver is involved, the following error is reported and the testkit fails to cleanup the domain: libvirt error code: 3, message: this function is not supported by the connection driver: virDomainSnapshotNum Rather than erroring out, list_snapshots should be protected using eval. In the event the underlying driver does not support snapshots, an empty list is returned, and no snapshot deletion is attempted. (Note - It is the listing of snapshots that is causing the error, not the attempt to delete them.) --- lib/Sys/Virt/TCK.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Sys/Virt/TCK.pm b/lib/Sys/Virt/TCK.pm index f8fa75d..a3d06a2 100644 --- a/lib/Sys/Virt/TCK.pm +++ b/lib/Sys/Virt/TCK.pm @@ -145,7 +145,8 @@ sub reset_snapshots { my $self = shift; my $dom = shift; - my @domss = $dom->list_snapshots; + # Use eval as not all drivers support snapshots + my @domss = eval { $dom->list_snapshots }; foreach my $domss (@domss) { $domss->delete; } -- 1.8.4.5

On Mon, Jan 26, 2015 at 03:06:48PM -0700, Mike Latimer wrote:
While running TCK on qemu, lxc and xen, I've ran into a few issues worth fixing upstream. The patches in this series are mainly focused on fixing minor typos, or safeguarding against failures in non-qemu environments.
Depending on how interested people are in running TCK with xen, I can provide a few additional patches.
ACK to all. Wil push shortly Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (2)
-
Daniel P. Berrange
-
Mike Latimer