new script for testing get/set metadata
include API:
dom->get_metadata
dom->set_metadata
---
scripts/domain/310-set-get-metadata.t | 68 +++++++++++++++++++++++++++++++++
1 files changed, 68 insertions(+), 0 deletions(-)
create mode 100644 scripts/domain/310-set-get-metadata.t
diff --git a/scripts/domain/310-set-get-metadata.t
b/scripts/domain/310-set-get-metadata.t
new file mode 100644
index 0000000..d1e67a4
--- /dev/null
+++ b/scripts/domain/310-set-get-metadata.t
@@ -0,0 +1,68 @@
+# -*- perl -*-
+#
+# Copyright (C) 2009-2013 Red Hat, Inc.
+# Copyright (C) 2013 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/310-set-get-metadata.t - Domain set_metadata/set_metadata
+
+=head1 DESCRIPTION
+
+The test case validates that set_metadata and get_metadata all can worked.
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 6;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+my $description = "Test description";
+my $title = "Test Title";
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END { $tck->cleanup if $tck; }
+
+
+my $xml = $tck->generic_domain("tck")->as_xml;
+
+diag "Creating a new transient domain";
+my $dom;
+ok_domain(sub { $dom = $conn->create_domain($xml) }, "created transient domain
object");
+
+#set & get metadata for description
+lives_ok(sub
{$dom->set_metadata(Sys::Virt::Domain::METADATA_DESCRIPTION,$description,undef,undef,0)},"set
metadata for Description");
+
+is($dom->get_metadata(Sys::Virt::Domain::METADATA_DESCRIPTION,undef,0), $description,
"get metadata for Description");
+
+#set & get metadata for title
+lives_ok(sub
{$dom->set_metadata(Sys::Virt::Domain::METADATA_TITLE,$title,undef,undef,0)},"set
metadata for Title");
+
+is($dom->get_metadata(Sys::Virt::Domain::METADATA_TITLE,undef,0), $title, "get
metadata for Title");
+
+#clean
+diag "Destroying the transient domain";
+$dom->destroy;
+
+diag "Checking that transient 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
Show replies by date
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(a)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