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

[libvirt] [libvirt-tck PATCH 2/2] Add script for managed save



new script for testing managed save
include API:
dom->has_managed_save_image
dom->managed_save_remove
---
 scripts/domain/320-managed_save_lifecycle.t |   74 +++++++++++++++++++++++++++
 1 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644 scripts/domain/320-managed_save_lifecycle.t

diff --git a/scripts/domain/320-managed_save_lifecycle.t b/scripts/domain/320-managed_save_lifecycle.t
new file mode 100644
index 0000000..d0989f9
--- /dev/null
+++ b/scripts/domain/320-managed_save_lifecycle.t
@@ -0,0 +1,74 @@
+# -*- perl -*-
+#
+# Copyright (C) 2013 Red Hat, Inc.
+# Copyright (C) 2013 Zhe Peng <zpeng 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/320-managed_save_lifecycle.t - Test API include
+dom->has_managed_save_image
+dom->managed_save_remove
+
+=head1 DESCRIPTION
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 9;
+
+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 $xml = $tck->generic_domain("tck")->as_xml;
+
+# Creating a new persistent domain
+my $dom;
+ok_domain(sub { $dom = $conn->define_domain($xml) }, "Define persistent domain object", "tck");
+
+diag "Start domain";
+$dom->create;
+ok($dom->get_id() > 0, "running domain has an ID > 0");
+
+#Check managed save before save
+is($dom->has_managed_save_image,"0","No managed save for domain tck");
+
+#Managed save domain
+lives_ok(sub {$dom->managed_save;}, "Managed save domain tck");
+
+ok_domain(sub {$conn->list_all_domains(Sys::Virt::Domain::LIST_MANAGEDSAVE);}, "List all managed save domain", "tck");
+
+#Check managed save after save
+is($dom->has_managed_save_image,"1","Have managed save for domain tck");
+
+#Remove managed save for domain
+lives_ok(sub {$dom->managed_save_remove}, "Remove managed save for domain tck");
+
+#Check managed save after remove
+is($dom->has_managed_save_image,"0","No managed save for domain tck");
+
+diag "Undefining the inactive domain config";
+$dom->undefine;
+
+diag "Checking that persistent domain has gone away";
+ok_error(sub { $conn->get_domain_by_name("tck") }, "NO_DOMAIN error raised from missing domain",
+	 Sys::Virt::Error::ERR_NO_DOMAIN);
+
+# end
-- 
1.7.7.6


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