[libvirt] [libvirt-tck 1/3] Correct typos in documents

* docs/intro.pod * docs/writing-tests.pod --- docs/intro.pod | 10 +++++----- docs/writing-tests.pod | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/intro.pod b/docs/intro.pod index 5943f3b..3684d51 100644 --- a/docs/intro.pod +++ b/docs/intro.pod @@ -16,7 +16,7 @@ =head1 libvirt TCK: Technology Compatability Kit The libvirt TCK provides a framework for performing testing -of the integration bqetween libvirt drivers, the underlying virt +of the integration between libvirt drivers, the underlying virt hypervisor technology, related operating system services and system configuration. The idea (and name) is motivated by the Java TCK @@ -51,7 +51,7 @@ to determine the level of compatability of their platform, and evaluate whether it will meet their needs, and get awareness of any regressions that may have occurred since a previous test run -In relation to other libvirt testing, the split of responsibiity +In relation to other libvirt testing, the split of responsibility will be =over 4 @@ -131,7 +131,7 @@ These are all currently available within Fedora 11, and later These modules are all well tested, actively maintained parts of Perl / CPAN, so easily available for every other operating system -in existance. +in existence. =head2 Overview of framework structure @@ -238,7 +238,7 @@ update the 'ID' field in the virDomainPtr =item * -After destroying a active domain, the remote driver did not +After destroying an active domain, the remote driver did not update the 'ID' field in the virDomainPtr =item * @@ -340,7 +340,7 @@ vs a virtual root filesystem for containers =item More helper XML helper modules -Add helpers for building network, storage and inteface XML +Add helpers for building network, storage and interface XML configs =item Broader host configuration diff --git a/docs/writing-tests.pod b/docs/writing-tests.pod index 5380f5d..3bc70b0 100644 --- a/docs/writing-tests.pod +++ b/docs/writing-tests.pod @@ -38,7 +38,7 @@ of checks that will be run in the test case. This enables the test harness to determine if a test case crashed / exited earlier than expected without running all checks. Each line starts with a word 'ok' or 'not ok' to indicate state of the check, followed -by the check number (assigned incremnetally), and a description +by the check number (assigned incrementally), and a description of the check performed. Diagnostic comments can be output using a leading '#' to assist in debugging / interpreting the results. @@ -148,7 +148,7 @@ Going line by line, this first imports the 'Sys::Virt::TCK' package and its functions. Then it creates an instance of the 'Sys::Virt::TCK' object. Then it runs the 'setup' method to obtain a libvirt connection, catching any error that may be thrown. The fourth line -willl abort the entire test if an error occurred during setup. The +will abort the entire test if an error occurred during setup. The final line registers a 'END' block which will perform cleanup when Perl exits. @@ -190,7 +190,7 @@ domain. "created a running domain", "test"); This creates a new running guest from '$xml', and checks that it -succeeeded and returns a domain object with an expected name of +succeeded and returns a domain object with an expected name of 'test'. If an exception was thrown during guest creation this will be reported as an error. If the guest has the incorrect name, that will also be reported as an error. @@ -428,6 +428,6 @@ If something went wrong, it might look like # Looks like you failed 1 test of 2 run. # Looks like your test died just after 2. -Notice that since the tst script declared upfront that it intended +Notice that since the test script declared upfront that it intended to run 5 checks, Perl was able to detect that it aborted earlier than expected. -- 1.7.1

To test daemon, qemu, lxc hook. * lib/Sys/Virt/TCK/Hooks.pm --- lib/Sys/Virt/TCK/Hooks.pm | 262 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 262 insertions(+), 0 deletions(-) create mode 100644 lib/Sys/Virt/TCK/Hooks.pm diff --git a/lib/Sys/Virt/TCK/Hooks.pm b/lib/Sys/Virt/TCK/Hooks.pm new file mode 100644 index 0000000..2f9a259 --- /dev/null +++ b/lib/Sys/Virt/TCK/Hooks.pm @@ -0,0 +1,262 @@ +# +# Copyright (C) 2010 Red Hat, Inc. +# Copyright (C) 2010 Osier Yang <jyang@redhat.com> +# +# 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 +# + +package Sys::Virt::TCK::Hooks; + +use strict; +use warnings; + +use Fcntl ':mode'; +use POSIX qw(strftime); + +my $HOOKS_CONF_DIR="/etc/libvirt/hooks"; + +sub new { + my $proto = shift; + my $class = ref($proto) || $proto; + my %params = @_; + my $self = {}; + + my $type = $params{type} ? $params{type} : die "type parameter is required"; + + $self = { + type => $type, + conf_dir => $params{conf_dir} ? $params{conf_dir} : $HOOKS_CONF_DIR, + name => $params{conf_dir}.'/'.$params{type}, + expect_result => $params{expect_result} ? $params{expect_result} : 0, + log_name => $params{log_name} ? $params{log_name} : "/tmp/$self->{type}.log", + libvirtd_status => undef, + domain_name => undef, + domain_state => undef, + expect_log => undef, + action => undef, + }; + + bless $self, $class; + + return $self; +} + +sub log_name { + my $self = shift; + my $log_name = shift; + + die "log_name parameter is required" unless $log_name; + + $self->{log_name} = $log_name; +} + +sub expect_result { + my $self = shift; + my $expect_result = shift; + + die "expect_result parameter is required" unless $expect_result; + + $self->{expect_result} = $expect_result; + + return $self; +} + +sub libvirtd_status { + my $self = shift; + my $status = `service libvirtd status`; + my $_ = $status; + + if (/running/) { + $self->{libvirtd_status} = 'running'; + } elsif (/stopped/) { + $self->{libvirtd_status} = 'stopped'; + } + + return $self; +} + +sub domain_name { + my $self = shift; + my $domain_name = shift; + + die "domain_name parameter is required" unless $domain_name; + + $self->{domain_name} = $domain_name; + + return $self; +} + +sub domain_state { + my $self = shift; + my $domain_state = shift; + + die "domain_state parameter is required" unless $domain_state; + + $self->{domain_state} = $domain_state; + + return $self; +} + +sub action { + my $self = shift; + my $action = shift; + + die "action parameter is required" unless $action; + + $self->{action} = $action; + + return $self; +} + +sub expect_log { + my $self = shift; + my $expect_log = undef; + + my $hook = $self->{name}; + my $action = $self->{action}; + my $domain_name = $self->{domain_name}; + my $domain_state = $self->{domain_state}; + my $libvirtd_status = $self->{libvirtd_status}; + + if ($self->{type} eq 'daemon') { + if ($libvirtd_status eq 'running') { + if ($action eq 'stop') { + $expect_log = "$hook - shutdown - shutdown"; + } elsif ($action eq 'restart') { + $expect_log = "$hook - shutdown - shutdown\n$hook - start - start"; + } elsif ($action eq 'reload') { + $expect_log = "$hook - reload begin SIGHUP"; + } else { + die "hooks testing doesn't support $action running libvirtd"; + } + } else { + if ($action eq 'start') { + $expect_log = "$hook - start - start"; + } else { + die "hooks testing doesn't support $action stopped libvirtd"; + } + } + } elsif ($self->{type} eq 'qemu' or $self->{type} eq 'lxc') { + if ($domain_state eq 'running') { + if ($action eq 'stop') { + $expect_log = "$hook $domain_name stopped end -"; + } else { + die "hooks testing doesn't support $action running domain"; + } + } elsif ($domain_state eq 'shut off') { + if ($action eq 'start') { + $expect_log = "$hook $domain_name start begin -"; + } else { + die "hooks testing doesn't support $action shutoff domain"; + } + + } else { + die "hooks testing doesn't support to test a domain in $domain_state state"; + } + } else { + die "hooks only support 'qemu' and 'lxc' currently"; + } + + $self->{expect_log} = $expect_log; + + return $self; +} + +sub create_hooks_dir { + my $self = shift; + + unless (-d $self->{conf_dir}) { + mkdir $self->{conf_dir} or die "failed to create $self->{conf_dir}: $!"; + } +} + +sub backup_hook { + my $self = shift; + my $date = undef; + + $date = strftime "%Y-%m-%d-%H:%M:%S", localtime; + my $orig = $self->{name}; + my $dest = $orig."-$date"; + + rename $orig, $dest; +} + +sub create_hook { + my $self = shift; + my $hook = $self->{name}; + + $self->backup_hook; + + open HOOK, "> $hook" or die "failed on opening $hook: $!"; + + my $str = <<EOF; +#! /bin/bash +echo "\$0" "\$@" >>$self->{log_name} +exit $self->{expect_result} +EOF + + print HOOK $str; + close HOOK; + + my $mode = (stat($hook))[2]; + chmod($mode | S_IXUSR, $hook) unless -x $hook; +} + +sub prepare { + my $self = shift; + + $self->create_hooks_dir; + $self->backup_hook; + $self->create_hook; + + unlink $self->{log_name} if -f $self->{log_name}; + + return $self; +} + +sub cleanup { + my $self = shift; + my $name = $self->{name}; + + unlink $name; + unlink $self->{log_name} if -f $self->{log_name}; +} + +sub service_libvirtd { + my $self = shift; + my $action = $self->{action}; + + truncate $self->{log_name}, 0 if -f $self->{log_name}; + + die "failed on $action daemon" if system "service libvirtd $action"; + + $self->libvirtd_status; +} + +sub compare_log { + my $self = shift; + + my $expect_log = $self->{expect_log}; + my $log_name = $self->{log_name}; + + open LOG, "< $log_name" or die "failed on opening $log_name: $!"; + + my @lines = <LOG>; + + return 0 unless @lines; + + chomp foreach @lines; + my $actual_log = join "\n", @lines; + + close LOG; + + ($expect_log eq $actual_log) ? 1 : 0; +} + +1; -- 1.7.1

On Mon, Oct 18, 2010 at 07:18:08AM +0800, Osier Yang wrote:
To test daemon, qemu, lxc hook.
* lib/Sys/Virt/TCK/Hooks.pm --- lib/Sys/Virt/TCK/Hooks.pm | 262 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 262 insertions(+), 0 deletions(-) create mode 100644 lib/Sys/Virt/TCK/Hooks.pm
diff --git a/lib/Sys/Virt/TCK/Hooks.pm b/lib/Sys/Virt/TCK/Hooks.pm
+sub libvirtd_status { + my $self = shift; + my $status = `service libvirtd status`; + my $_ = $status; + + if (/running/) { + $self->{libvirtd_status} = 'running'; + } elsif (/stopped/) { + $self->{libvirtd_status} = 'stopped'; + } + + return $self; +}
+sub service_libvirtd { + my $self = shift; + my $action = $self->{action}; + + truncate $self->{log_name}, 0 if -f $self->{log_name}; + + die "failed on $action daemon" if system "service libvirtd $action"; + + $self->libvirtd_status; +}
Is there any way we can avoid having to start/stop libvirtd for this testing ? The general goal of the TCK is that it is testing an existing deployment, so it should be expecting that libvirtd is already up & running in a desired configuration. If we have to stop/start libvirtd, then the test script using these APIs will need to be protected to make sure it only runs when used with 'qemu:///system' or 'lxc://'. ie is skipped with qemu:///session or vmware, or virtualbox, etc
+ +sub compare_log { + my $self = shift; + + my $expect_log = $self->{expect_log}; + my $log_name = $self->{log_name}; + + open LOG, "< $log_name" or die "failed on opening $log_name: $!"; + + my @lines = <LOG>; + + return 0 unless @lines; + + chomp foreach @lines; + my $actual_log = join "\n", @lines; + + close LOG;
Little perl black magic tip for you.... If you want to read the entire file contents into a single string, then you can do open LOG, "<$log_name"; local $/ = undef; my $actual_log = <LOG>; close LOG; '$/' is the line separator. By setting it to 'undef' we tell Perl that there is no line separator, so it will immediately read until end of file :-) BTW see 'man perlvar' for this particular example 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 :|

----- "Daniel P. Berrange" <berrange@redhat.com> wrote:
On Mon, Oct 18, 2010 at 07:18:08AM +0800, Osier Yang wrote:
To test daemon, qemu, lxc hook.
* lib/Sys/Virt/TCK/Hooks.pm --- lib/Sys/Virt/TCK/Hooks.pm | 262 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 262 insertions(+), 0 deletions(-) create mode 100644 lib/Sys/Virt/TCK/Hooks.pm
diff --git a/lib/Sys/Virt/TCK/Hooks.pm b/lib/Sys/Virt/TCK/Hooks.pm
+sub libvirtd_status { + my $self = shift; + my $status = `service libvirtd status`; + my $_ = $status; + + if (/running/) { + $self->{libvirtd_status} = 'running'; + } elsif (/stopped/) { + $self->{libvirtd_status} = 'stopped'; + } + + return $self; +}
+sub service_libvirtd { + my $self = shift; + my $action = $self->{action}; + + truncate $self->{log_name}, 0 if -f $self->{log_name}; + + die "failed on $action daemon" if system "service libvirtd $action"; + + $self->libvirtd_status; +}
Is there any way we can avoid having to start/stop libvirtd for this testing ? The general goal of the TCK is that it is testing an existing deployment, so it should be expecting that libvirtd is already up & running in a desired configuration.
If we have to stop/start libvirtd, then the test script using these APIs will need to be protected to make sure it only runs when used with 'qemu:///system' or 'lxc://'. ie is skipped with qemu:///session or vmware, or virtualbox, etc
For daemon hook testing, It's neccessary to start/stop/restart the libvirtd. Otherwise we can't see if the hook script is invoked or not. It doesn't relate to which hypervisor driver is used..
+ +sub compare_log { + my $self = shift; + + my $expect_log = $self->{expect_log}; + my $log_name = $self->{log_name}; + + open LOG, "< $log_name" or die "failed on opening $log_name: $!"; + + my @lines = <LOG>; + + return 0 unless @lines; + + chomp foreach @lines; + my $actual_log = join "\n", @lines; + + close LOG;
Little perl black magic tip for you....
If you want to read the entire file contents into a single string, then you can do
open LOG, "<$log_name"; local $/ = undef; my $actual_log = <LOG>; close LOG;
'$/' is the line separator. By setting it to 'undef' we tell Perl that there is no line separator, so it will immediately read until end of file :-) BTW see 'man perlvar' for this particular example
cool trick.. will update it.. thanks.. :-)
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 :|

Validate daemon hook is invocated correctly while start, restart, stop, reload libvirtd --- scripts/hooks/051-daemon-hook.t | 156 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 156 insertions(+), 0 deletions(-) create mode 100644 scripts/hooks/051-daemon-hook.t diff --git a/scripts/hooks/051-daemon-hook.t b/scripts/hooks/051-daemon-hook.t new file mode 100644 index 0000000..2d44e45 --- /dev/null +++ b/scripts/hooks/051-daemon-hook.t @@ -0,0 +1,156 @@ +# -*- perl -*- +# +# Copyright (C) 203 Red Hat, Inc. +# Copyright (C) 203 Osier Yang <jyang@redhat.com> +# +# 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/051-start-daemon.t - hooks testing for daemon + +=head1 DESCRIPTION + +The test case validates that the hook script is invocated while +start, stop, or reload daemon. + +=cut + +use strict; +use warnings; + +use Test::More tests => 12; + +use Sys::Virt::TCK::Hooks; + +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'); + +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}; + +# stop libvirtd +$hook->action('stop'); +$hook->expect_log; + +diag "$hook->{action} libvirtd"; +$hook->service_libvirtd; + +diag "hook script: $hook->{name}"; +system "cat $hook->{name}"; + +sleep 3; +diag "check if $hook->{name} is invocated"; +ok(-f "$hook->{name}", "$hook->{name} is invocated"); + +diag "actual log: $hook->{log_name}"; +system "cat $hook->{log_name}"; + +diag "expected log:"; +print $hook->{expect_log}."\n"; + +diag "check if the actual log is same with expected log"; +ok($hook->compare_log, "$hook->{name} is invocated correctly while $hook->{action} libvirtd"); + +diag "check if libvirtd is stopped"; +ok(`service libvirtd status` =~ /stopped/, "libvirtd is stopped"); + +# start libvirtd +$hook->action('start'); +$hook->expect_log; + +diag "$hook->{action} libvirtd"; +$hook->service_libvirtd; + +diag "hook script: $hook->{name}"; +system "cat $hook->{name}"; + +sleep 3; +diag "check if $hook->{name} is invocated"; +ok(-f "$hook->{name}", "$hook->{name} is invocated"); + +diag "actual log: $hook->{log_name}"; +system "cat $hook->{log_name}"; + +diag "expected log:"; +print $hook->{expect_log}."\n"; + +diag "check if the actual log is same with expected log"; +ok($hook->compare_log, "$hook->{name} is invocated correctly while $hook->{action} libvirtd"); + +diag "check if libvirtd is still running"; +ok(`service libvirtd status` =~ /running/, "libvirtd is running"); + +# restart libvirtd +$hook->action('restart'); +$hook->expect_log; + +diag "$hook->{action} libvirtd"; +$hook->service_libvirtd; + +diag "hook script: $hook->{name}"; +system "cat $hook->{name}"; + +sleep 3; +diag "check if $hook->{name} is invocated"; +ok(-f "$hook->{name}", "$hook->{name} is invocated"); + +diag "actual log: $hook->{log_name}"; +system "cat $hook->{log_name}"; + +diag "expected log:"; +print $hook->{expect_log}."\n"; + +diag "check if the actual log is same with expected log"; +ok($hook->compare_log, "$hook->{name} is invocated correctly while $hook->{action} libvirtd"); + +diag "check if libvirtd is still running"; +ok(`service libvirtd status` =~ /running/, "libvirtd is running"); + +# reload libvirtd +$hook->action('reload'); +$hook->expect_log; + +diag "$hook->{action} libvirtd"; +$hook->service_libvirtd; + +diag "hook script: $hook->{name}"; +system "cat $hook->{name}"; + +sleep 3; +diag "check if $hook->{name} is invocated"; +ok(-f "$hook->{name}", "$hook->{name} is invocated"); + +diag "actual log: $hook->{log_name}"; +system "cat $hook->{log_name}"; + +diag "expected log:"; +print $hook->{expect_log}."\n"; + +diag "check if the actual log is same with expected log"; +ok($hook->compare_log, "$hook->{name} is invocated correctly while $hook->{action} libvirtd"); + +diag "check if libvirtd is still running"; +ok(`service libvirtd status` =~ /running/, "libvirtd is running"); + +$hook->cleanup; + -- 1.7.1

On Mon, Oct 18, 2010 at 07:18:09AM +0800, Osier Yang wrote:
Validate daemon hook is invocated correctly while start, restart, stop, reload libvirtd --- scripts/hooks/051-daemon-hook.t | 156 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 156 insertions(+), 0 deletions(-) create mode 100644 scripts/hooks/051-daemon-hook.t
diff --git a/scripts/hooks/051-daemon-hook.t b/scripts/hooks/051-daemon-hook.t new file mode 100644 index 0000000..2d44e45 --- /dev/null +++ b/scripts/hooks/051-daemon-hook.t @@ -0,0 +1,156 @@ +# -*- perl -*- +# +# Copyright (C) 203 Red Hat, Inc. +# Copyright (C) 203 Osier Yang <jyang@redhat.com> +# +# 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/051-start-daemon.t - hooks testing for daemon + +=head1 DESCRIPTION + +The test case validates that the hook script is invocated while +start, stop, or reload daemon. + +=cut + +use strict; +use warnings; + +use Test::More tests => 12; + +use Sys::Virt::TCK::Hooks; + +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'); + +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}; + +# stop libvirtd +$hook->action('stop'); +$hook->expect_log; + +diag "$hook->{action} libvirtd"; +$hook->service_libvirtd; + +diag "hook script: $hook->{name}"; +system "cat $hook->{name}";
These 'cat' calls should all really be reported as diagnostics rather than just sent to stdout directly. We should probably just use the standard 'Slurp' module from CPAN. eg, put a 'use Slurp' at the top of the script then replace those 2 lines with my $hookdata = slurp($hook->{name}); diag "hook script: $hook->{name} '$hookdata'";
+ +sleep 3; +diag "check if $hook->{name} is invocated"; +ok(-f "$hook->{name}", "$hook->{name} is invocated");
s/invocated/invoked/ (and in a few other places later)
+ +diag "actual log: $hook->{log_name}"; +system "cat $hook->{log_name}"; + +diag "expected log:"; +print $hook->{expect_log}."\n"; + +diag "check if the actual log is same with expected log"; +ok($hook->compare_log, "$hook->{name} is invocated correctly while $hook->{action} libvirtd"); + +diag "check if libvirtd is stopped"; +ok(`service libvirtd status` =~ /stopped/, "libvirtd is stopped"); + +# start libvirtd +$hook->action('start'); +$hook->expect_log; + +diag "$hook->{action} libvirtd"; +$hook->service_libvirtd; + +diag "hook script: $hook->{name}"; +system "cat $hook->{name}"; + +sleep 3; +diag "check if $hook->{name} is invocated"; +ok(-f "$hook->{name}", "$hook->{name} is invocated"); + +diag "actual log: $hook->{log_name}"; +system "cat $hook->{log_name}"; + +diag "expected log:"; +print $hook->{expect_log}."\n"; + +diag "check if the actual log is same with expected log"; +ok($hook->compare_log, "$hook->{name} is invocated correctly while $hook->{action} libvirtd"); + +diag "check if libvirtd is still running"; +ok(`service libvirtd status` =~ /running/, "libvirtd is running"); + +# restart libvirtd +$hook->action('restart'); +$hook->expect_log; + +diag "$hook->{action} libvirtd"; +$hook->service_libvirtd; + +diag "hook script: $hook->{name}"; +system "cat $hook->{name}"; + +sleep 3; +diag "check if $hook->{name} is invocated"; +ok(-f "$hook->{name}", "$hook->{name} is invocated"); + +diag "actual log: $hook->{log_name}"; +system "cat $hook->{log_name}"; + +diag "expected log:"; +print $hook->{expect_log}."\n"; + +diag "check if the actual log is same with expected log"; +ok($hook->compare_log, "$hook->{name} is invocated correctly while $hook->{action} libvirtd"); + +diag "check if libvirtd is still running"; +ok(`service libvirtd status` =~ /running/, "libvirtd is running"); + +# reload libvirtd +$hook->action('reload'); +$hook->expect_log; + +diag "$hook->{action} libvirtd"; +$hook->service_libvirtd; + +diag "hook script: $hook->{name}"; +system "cat $hook->{name}"; + +sleep 3; +diag "check if $hook->{name} is invocated"; +ok(-f "$hook->{name}", "$hook->{name} is invocated"); + +diag "actual log: $hook->{log_name}"; +system "cat $hook->{log_name}"; + +diag "expected log:"; +print $hook->{expect_log}."\n"; + +diag "check if the actual log is same with expected log"; +ok($hook->compare_log, "$hook->{name} is invocated correctly while $hook->{action} libvirtd"); + +diag "check if libvirtd is still running"; +ok(`service libvirtd status` =~ /running/, "libvirtd is running"); + +$hook->cleanup;
As mentioned in the previous patch, it is probably best to wrap the entire test block in a SKIP: { my $uri = $conn->get_uri(); skip 12, "Not using QEMU/LXC driver" unless $uri eq "qemu:///system" or $uri eq "lxc:///"; ....all test cases... } 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 :|

On 10/18/2010 10:18 AM, Osier Yang wrote:
-Notice that since the tst script declared upfront that it intended +Notice that since the test script declared upfront that it intended
(missing the "is") ...script *is* declared up front ... Didn't look at the rest though, just noticed this as I was switching emails. ;)

----- "Justin Clift" <jclift@redhat.com> wrote:
On 10/18/2010 10:18 AM, Osier Yang wrote:
-Notice that since the tst script declared upfront that it intended +Notice that since the test script declared upfront that it intended
(missing the "is")
yup, need danpb's ACK.. :-) - Osier
...script *is* declared up front ...
Didn't look at the rest though, just noticed this as I was switching emails. ;)

On Mon, Oct 18, 2010 at 07:18:07AM +0800, Osier Yang wrote:
* docs/intro.pod * docs/writing-tests.pod --- docs/intro.pod | 10 +++++----- docs/writing-tests.pod | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-)
ACK 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 :|

On Mon, Oct 18, 2010 at 05:45:12PM +0100, Daniel P. Berrange wrote:
On Mon, Oct 18, 2010 at 07:18:07AM +0800, Osier Yang wrote:
* docs/intro.pod * docs/writing-tests.pod --- docs/intro.pod | 10 +++++----- docs/writing-tests.pod | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-)
ACK
Okay I pushed the 5 patches ACK'ed on this thread, Thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

Thanks a lot :-) - Osier ----- "Daniel Veillard" <veillard@redhat.com> wrote:
On Mon, Oct 18, 2010 at 05:45:12PM +0100, Daniel P. Berrange wrote:
On Mon, Oct 18, 2010 at 07:18:07AM +0800, Osier Yang wrote:
* docs/intro.pod * docs/writing-tests.pod --- docs/intro.pod | 10 +++++----- docs/writing-tests.pod | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-)
ACK
Okay I pushed the 5 patches ACK'ed on this thread,
Thanks !
Daniel
-- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (5)
-
Daniel P. Berrange
-
Daniel Veillard
-
Justin Clift
-
Osier
-
Osier Yang