Re: [libvirt-tck 3/3] Add test case for daemon hook testing

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

 



updated, and patch attached.

- Osier
----- "Daniel P. Berrange" <berrange@xxxxxxxxxx> wrote:

> On Tue, Oct 19, 2010 at 03:41:55AM -0400, Osier wrote:
> > attach updated patch for daemon hook testing..
> > 
> > replaced "cat" with "slurp", corrected typos.
> 
> > From 963158c860d5415117e70b67458745c2b4cf9c13 Mon Sep 17 00:00:00
> 2001
> > From: Osier Yang <jyang@xxxxxxxxxx>
> > Date: Tue, 19 Oct 2010 15:32:17 +0800
> > Subject: [libvirt-tck 4/4] Add test case for daemon hook testing
> > 
> > Validate daemon hook is invoked correctly while start, stop,
> > restart, reload libvirtd
> > ---
> >  scripts/hooks/051-daemon-hook.t |  153
> +++++++++++++++++++++++++++++++++++++++
> >  1 files changed, 153 insertions(+), 0 deletions(-)
> >  create mode 100644 scripts/hooks/051-daemon-hook.t
> 
> This still needs to skip execution if the Sys::Virt::TCK 
> connection object is not lxc:/// or qemu:///system
> 
> Regards,
> 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 :|
>From 8d2a62528a7820939c4d7c86dd10cbf16ea5d751 Mon Sep 17 00:00:00 2001
From: Osier Yang <jyang@xxxxxxxxxx>
Date: Fri, 22 Oct 2010 14:40:13 +0800
Subject: [TCK] Skip daemon hook testing if URI is not qemu:///system or lxc:///
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Skip the case execution if Sys::Virt::TCK connection object is
not qemu:///system or lxc:///
---
 scripts/hooks/051-daemon-hook.t |  178 +++++++++++++++++++++------------------
 1 files changed, 96 insertions(+), 82 deletions(-)

diff --git a/scripts/hooks/051-daemon-hook.t b/scripts/hooks/051-daemon-hook.t
index bc9714c..c378bd0 100644
--- a/scripts/hooks/051-daemon-hook.t
+++ b/scripts/hooks/051-daemon-hook.t
@@ -30,124 +30,138 @@ use warnings;
 
 use Slurp;
 
-use Test::More tests => 12;
+use Sys::Virt::TCK;
 use Sys::Virt::TCK::Hooks;
 
-my $hook = Sys::Virt::TCK::Hooks->new(type => 'daemon',
-                                      conf_dir => '/etc/libvirt/hooks',
-                                      log_name => '/tmp/daemon.log');
+use Test::More tests => 12;
+
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END { $tck->cleanup if $tck; }
+
+SKIP: {
+    my $uri = $conn->get_uri();
+    
+    skip 12, "NOT using QEMU/LXC driver" unless
+        $uri eq "qemu:///system" or $uri eq "lxc:///";
+
+    my $hook = Sys::Virt::TCK::Hooks->new(type => 'daemon',
+                                          conf_dir => '/etc/libvirt/hooks',
+                                          log_name => '/tmp/daemon.log');
 
-$hook->libvirtd_status;
-BAIL_OUT "libvirtd is not running, Exit..." 
-    if ($hook->{libvirtd_status} eq 'stopped');
+    $hook->libvirtd_status;
+    BAIL_OUT "libvirtd is not running, Exit..." 
+        if ($hook->{libvirtd_status} eq 'stopped');
 
-eval { $hook->prepare; };
-BAIL_OUT "failed to setup hooks testing ENV: $@" if $@;
+    eval { $hook->prepare; };
+    BAIL_OUT "failed to setup hooks testing ENV: $@" if $@;
 
-diag "restart libvirtd for hooks scripts taking effect";
-$hook->action('restart');
-$hook->service_libvirtd;
-unlink $hook->{log_name} unless -f $hook->{log_name};
+    diag "restart libvirtd for hooks scripts taking effect";
+    $hook->action('restart');
+    $hook->service_libvirtd;
+    unlink $hook->{log_name} unless -f $hook->{log_name};
 
-# stop libvirtd
-$hook->action('stop');
-$hook->expect_log;
+    # stop libvirtd
+    $hook->action('stop');
+    $hook->expect_log;
 
-diag "$hook->{action} libvirtd";
-$hook->service_libvirtd;
+    diag "$hook->{action} libvirtd";
+    $hook->service_libvirtd;
 
-my $hook_data = slurp($hook->{name});
-diag "hook script: $hook->{name} '$hook_data'";
+    my $hook_data = slurp($hook->{name});
+    diag "hook script: $hook->{name} '$hook_data'";
 
-sleep 3;
-diag "check if $hook->{name} is invoked";
-ok(-f "$hook->{name}", "$hook->{name} is invoked");
+    sleep 3;
+    diag "check if $hook->{name} is invoked";
+    ok(-f "$hook->{name}", "$hook->{name} is invoked");
 
-my $actual_log_data = slurp($hook->{log_name});
-diag "actual log: $hook->{log_name} '$actual_log_data'";
+    my $actual_log_data = slurp($hook->{log_name});
+    diag "actual log: $hook->{log_name} '$actual_log_data'";
 
-diag "expected log:\n$hook->{expect_log}";
+    diag "expected log:\n$hook->{expect_log}";
 
-diag "check if the actual log is same with expected log";
-ok($hook->compare_log, "$hook->{name} is invoked correctly while $hook->{action} libvirtd");
+    diag "check if the actual log is same with expected log";
+    ok($hook->compare_log, "$hook->{name} is invoked correctly while $hook->{action} libvirtd");
 
-diag "check if libvirtd is stopped";
-ok(`service libvirtd status` =~ /stopped/, "libvirtd is stopped"); 
+    diag "check if libvirtd is stopped";
+    ok(`service libvirtd status` =~ /stopped/, "libvirtd is stopped"); 
 
-# start libvirtd
-$hook->action('start');
-$hook->expect_log;
+    # start libvirtd
+    $hook->action('start');
+    $hook->expect_log;
 
-diag "$hook->{action} libvirtd";
-$hook->service_libvirtd;
+    diag "$hook->{action} libvirtd";
+    $hook->service_libvirtd;
 
-$hook_data = slurp($hook->{name});
-diag "hook script: $hook->{name} '$hook_data'";
+    $hook_data = slurp($hook->{name});
+    diag "hook script: $hook->{name} '$hook_data'";
 
-sleep 3;
-diag "check if $hook->{name} is invoked";
-ok(-f "$hook->{name}", "$hook->{name} is invoked");
+    sleep 3;
+    diag "check if $hook->{name} is invoked";
+    ok(-f "$hook->{name}", "$hook->{name} is invoked");
 
-$actual_log_data = slurp($hook->{log_name});
-diag "actual log: $hook->{log_name} '$actual_log_data'";
+    $actual_log_data = slurp($hook->{log_name});
+    diag "actual log: $hook->{log_name} '$actual_log_data'";
 
-diag "expected log: \n$hook->{expect_log}";
+    diag "expected log: \n$hook->{expect_log}";
 
-diag "check if the actual log is same with expected log";
-ok($hook->compare_log, "$hook->{name} is invoked correctly while $hook->{action} libvirtd");
+    diag "check if the actual log is same with expected log";
+    ok($hook->compare_log, "$hook->{name} is invoked correctly while $hook->{action} libvirtd");
 
-diag "check if libvirtd is still running";
-ok(`service libvirtd status` =~ /running/, "libvirtd is running"); 
+    diag "check if libvirtd is still running";
+    ok(`service libvirtd status` =~ /running/, "libvirtd is running"); 
 
-# restart libvirtd
-$hook->action('restart');
-$hook->expect_log;
+    # restart libvirtd
+    $hook->action('restart');
+    $hook->expect_log;
 
-diag "$hook->{action} libvirtd";
-$hook->service_libvirtd;
+    diag "$hook->{action} libvirtd";
+    $hook->service_libvirtd;
 
-$hook_data = slurp($hook->{name});
-diag "hook script: $hook->{name} '$hook_data'";
+    $hook_data = slurp($hook->{name});
+    diag "hook script: $hook->{name} '$hook_data'";
 
-sleep 3;
-diag "check if $hook->{name} is invoked";
-ok(-f "$hook->{name}", "$hook->{name} is invoked");
+    sleep 3;
+    diag "check if $hook->{name} is invoked";
+    ok(-f "$hook->{name}", "$hook->{name} is invoked");
 
-$actual_log_data = slurp($hook->{log_name});
-diag "actual log: $hook->{log_name} '$actual_log_data'";
+    $actual_log_data = slurp($hook->{log_name});
+    diag "actual log: $hook->{log_name} '$actual_log_data'";
 
-diag "expected log: \n$hook->{expect_log}";
+    diag "expected log: \n$hook->{expect_log}";
 
-diag "check if the actual log is same with expected log";
-ok($hook->compare_log, "$hook->{name} is invoked correctly while $hook->{action} libvirtd");
+    diag "check if the actual log is same with expected log";
+    ok($hook->compare_log, "$hook->{name} is invoked correctly while $hook->{action} libvirtd");
 
-diag "check if libvirtd is still running";
-ok(`service libvirtd status` =~ /running/, "libvirtd is running"); 
+    diag "check if libvirtd is still running";
+    ok(`service libvirtd status` =~ /running/, "libvirtd is running"); 
 
-# reload libvirtd
-$hook->action('reload');
-$hook->expect_log;
+    # reload libvirtd
+    $hook->action('reload');
+    $hook->expect_log;
 
-diag "$hook->{action} libvirtd";
-$hook->service_libvirtd;
+    diag "$hook->{action} libvirtd";
+    $hook->service_libvirtd;
 
-$hook_data = slurp($hook->{name});
-diag "hook script: $hook->{name} '$hook_data'";
+    $hook_data = slurp($hook->{name});
+    diag "hook script: $hook->{name} '$hook_data'";
 
-sleep 3;
-diag "check if $hook->{name} is invoked";
-ok(-f "$hook->{name}", "$hook->{name} is invoked");
+    sleep 3;
+    diag "check if $hook->{name} is invoked";
+    ok(-f "$hook->{name}", "$hook->{name} is invoked");
 
-$actual_log_data = slurp($hook->{log_name});
-diag "actual log: $hook->{log_name} '$actual_log_data'";
+    $actual_log_data = slurp($hook->{log_name});
+    diag "actual log: $hook->{log_name} '$actual_log_data'";
 
-diag "expected log: \n$hook->{expect_log}";
+    diag "expected log: \n$hook->{expect_log}";
 
-diag "check if the actual log is same with expected log";
-ok($hook->compare_log, "$hook->{name} is invoked correctly while $hook->{action} libvirtd");
+    diag "check if the actual log is same with expected log";
+    ok($hook->compare_log, "$hook->{name} is invoked correctly while $hook->{action} libvirtd");
 
-diag "check if libvirtd is still running";
-ok(`service libvirtd status` =~ /running/, "libvirtd is running"); 
+    diag "check if libvirtd is still running";
+    ok(`service libvirtd status` =~ /running/, "libvirtd is running"); 
 
-$hook->cleanup;
+    $hook->cleanup;
+};
 
-- 
1.7.1

--
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]