[libvirt] [libvirt-tck][PATCH] Add new api get_all_domain_stats testing

Jim Fehlig jfehlig at suse.com
Thu Mar 5 20:31:57 UTC 2015


Zhe Peng wrote:
> $vmm->get_all_domain_stats
> Sys::Virt::GET_ALL_STATS_ACTIVE
> Sys::Virt::GET_ALL_STATS_INACTIVE
> Sys::Virt::GET_ALL_STATS_OTHER
> Sys::Virt::GET_ALL_STATS_PAUSED
> Sys::Virt::GET_ALL_STATS_PERSISTENT
> Sys::Virt::GET_ALL_STATS_RUNNING
> Sys::Virt::GET_ALL_STATS_SHUTOFF
> Sys::Virt::GET_ALL_STATS_TRANSIENT
> Sys::Virt::GET_ALL_STATS_ENFORCE_STATS
>
> Signed-off-by: Zhe Peng <zpeng at redhat.com>
> ---
>  scripts/domain/800-get-all-stats.t | 137 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 137 insertions(+)
>  create mode 100644 scripts/domain/800-get-all-stats.t
>   

Same comment for this patch.  Can we ensure the test is skipped, rather
than failing, if virConnectGetAllDomainsStats returns "not supported"?

Regards,
Jim

> diff --git a/scripts/domain/800-get-all-stats.t b/scripts/domain/800-get-all-stats.t
> new file mode 100644
> index 0000000..4ff4bf3
> --- /dev/null
> +++ b/scripts/domain/800-get-all-stats.t
> @@ -0,0 +1,137 @@
> +# -*- perl -*-
> +#
> +# Copyright (C) 2014 Red Hat, Inc.
> +# Copyright (C) 2014 Zhe Peng
> +#
> +# 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
> +
> +domain/800-get-all-stats.t
> +
> +=head1 DESCRIPTION
> +
> +The test case validates that:
> +$vmm->get_all_domain_stats
> +Sys::Virt::GET_ALL_STATS_ACTIVE
> +Sys::Virt::GET_ALL_STATS_INACTIVE
> +Sys::Virt::GET_ALL_STATS_OTHER
> +Sys::Virt::GET_ALL_STATS_PAUSED
> +Sys::Virt::GET_ALL_STATS_PERSISTENT
> +Sys::Virt::GET_ALL_STATS_RUNNING
> +Sys::Virt::GET_ALL_STATS_SHUTOFF
> +Sys::Virt::GET_ALL_STATS_TRANSIENT
> +Sys::Virt::GET_ALL_STATS_ENFORCE_STATS
> +
> +=cut
> +
> +use strict;
> +use warnings;
> +
> +use Test::More tests => 11;
> +
> +use Sys::Virt::TCK;
> +use Test::Exception;
> +
> +my $tck = Sys::Virt::TCK->new();
> +my $conn = eval { $tck->setup(); };
> +BAIL_OUT "failed to setup test harness: $@" if $@;
> +END {
> +    $tck->cleanup if $tck;
> +}
> +
> +my @doms = ("tck1", "tck2", "tck3", "tck4");
> +
> +#create two persistent domain, tck1 and tck2
> +
> +my $xml = $tck->generic_domain(name => "tck1")->as_xml;
> +
> +diag "Defining an inactive domain config";
> +
> +my $dom1;
> +
> +ok_domain(sub { $dom1 = $conn->define_domain($xml) }, "defined persistent domain config");
> +
> +my $xml2 = $tck->generic_domain(name => "tck2")->as_xml;
> +
> +diag "Defining an inactive domain config";
> +
> +my $dom2;
> +
> +ok_domain(sub { $dom2 = $conn->define_domain($xml2) }, "defined persistent domain config");
> +
> +my $stats_persistent = Sys::Virt::Domain::GET_ALL_STATS_PERSISTENT|Sys::Virt::Domain::GET_ALL_STATS_INACTIVE;
> +my @dom_persistent = $conn->get_all_domain_stats(Sys::Virt::Domain::STATS_STATE, undef, $stats_persistent);
> +
> +is($#dom_persistent+1, 2, "list all persistent domain");
> +
> +#create two transient domain, tck3 and tck4
> +
> +my $xml3 = $tck->generic_domain(name => "tck3")->as_xml;
> +
> +diag "Creating a new transient domain";
> +my $dom3;
> +ok_domain(sub { $dom3 = $conn->create_domain($xml3) }, "created transient domain object");
> +
> +my $xml4 = $tck->generic_domain(name => "tck4")->as_xml;
> +
> +diag "Creating a new transient domain";
> +my $dom4;
> +ok_domain(sub { $dom4 = $conn->create_domain($xml4) }, "created transient domain object");
> +
> +my $stats_transient = Sys::Virt::Domain::GET_ALL_STATS_TRANSIENT|Sys::Virt::Domain::GET_ALL_STATS_RUNNING;
> +
> +my @dom_transient = $conn->get_all_domain_stats(Sys::Virt::Domain::STATS_STATE, undef, $stats_transient);
> +
> +is($#dom_transient+1, 2, "list all transient domain");
> +
> +#start & pause persistent domain 2 and  one transient dom
> +$dom2->create();
> +$dom2->suspend();
> +$dom3->suspend();
> +
> +my $stats_pause = Sys::Virt::Domain::GET_ALL_STATS_PAUSED;
> +
> +my @dom_pause = $conn->get_all_domain_stats(Sys::Virt::Domain::STATS_STATE, undef, $stats_pause);
> +
> +is($#dom_pause+1, 2, "list all pause domain");
> +
> +#resume dom2 and dom3
> +$dom2->resume();
> +$dom3->resume();
> +
> +my $stats_active = Sys::Virt::Domain::GET_ALL_STATS_ACTIVE;
> +
> +my at dom_active = $conn->get_all_domain_stats(Sys::Virt::Domain::STATS_STATE, undef, $stats_active);
> +
> +is($#dom_active+1, 3, "list all active domain");
> +
> +my $stats_shutoff = Sys::Virt::Domain::GET_ALL_STATS_SHUTOFF;
> +
> +my @dom_shutoff = $conn->get_all_domain_stats(Sys::Virt::Domain::STATS_STATE, undef, $stats_shutoff);
> +
> +is($#dom_shutoff+1, 1, "list all shutoff domain");
> +
> +my $stats_other = Sys::Virt::Domain::GET_ALL_STATS_OTHER;
> +
> +my @dom_other = $conn->get_all_domain_stats(Sys::Virt::Domain::STATS_STATE, undef, $stats_other);
> +
> +is($#dom_other+1, 0, "list all other domain");
> +
> +my $stats_enforce = Sys::Virt::Domain::GET_ALL_STATS_ENFORCE_STATS;
> +
> +my @dom_enforce = $conn->get_all_domain_stats(Sys::Virt::Domain::STATS_STATE, undef, $stats_enforce);
> +
> +is($#dom_enforce+1, 4, "list all enforce domain");
> +
> +
> +
>   




More information about the libvir-list mailing list