[PATCH][TCK] Add test for memory set and get

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

 



Add test for memory/maxmem set and get
---
 scripts/domain/310-memory-set-get.t |   98 +++++++++++++++++++++++++++++++++++
 1 files changed, 98 insertions(+), 0 deletions(-)
 create mode 100644 scripts/domain/310-memory-set-get.t

diff --git a/scripts/domain/310-memory-set-get.t b/scripts/domain/310-memory-set-get.t
new file mode 100644
index 0000000..b4dde65
--- /dev/null
+++ b/scripts/domain/310-memory-set-get.t
@@ -0,0 +1,98 @@
+# -*- perl -*-
+#
+# Copyright (C) 2012-2013 Red Hat, Inc.
+# Copyright (C) 2012-2013 Kyla Zhang <weizhan@xxxxxxxxxx>
+#
+# 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-memory-set-get.t: test set and get memory/max memory
+
+=head1 DESCRIPTION
+
+The test case validates that the set memory, set max memory and get
+max memory works well for domain.
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 15;
+
+use Sys::Virt::TCK;
+use Sys::Virt::TCK::NetworkHelpers;
+use Test::Exception;
+use File::Spec::Functions qw(catfile catdir rootdir);
+
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END { $tck->cleanup if $tck; }
+
+diag "Define a new real domain, default memory is 524288";
+my $dom_name ="tck310memtest";
+
+my $dom = prepare_test_disk_and_vm($tck, $conn, $dom_name);
+
+diag "Set max memory for domain";
+lives_ok(sub { $dom->set_max_memory("1048576") }, "Set max memory succeed");
+
+diag "Get max memory for domain when domain is inactive";
+is($dom->get_max_memory(), 1048576, "Get max memory is same as set value 1048576");
+
+diag "Start inactive domain";
+$dom->create;
+ok($dom->get_id() > 0, "running domain has an ID > 0");
+sleep(30);
+
+diag "Set memory for current state";
+lives_ok(sub { $dom->set_memory("624288", Sys::Virt::Domain::MEM_CONFIG) }, "Set memory succeed in persistent config");
+
+diag "get memory of running domain";
+is($dom->get_info()->{memory}, 524288, "Get current memory is 524288");
+
+diag "Get max memory for domain when domain is active";
+is($dom->get_max_memory(), 1048576, "Get max memory is same as set value 1048576");
+
+diag "Set memory for current state";
+lives_ok(sub { $dom->set_memory("724288", Sys::Virt::Domain::MEM_CURRENT) }, "Set memory succeed in current state");
+sleep(3);
+
+diag "Check memory of running domain";
+is($dom->get_info()->{memory}, 724288, "Get current memory is same as set value 724288");
+
+diag "Set memory for live state";
+lives_ok(sub { $dom->set_memory("824288", Sys::Virt::Domain::MEM_LIVE) }, "Set memory succeed in live state");
+sleep(3);
+
+diag "Check memory of running domain";
+is($dom->get_info()->{memory}, 824288, "Get current memory is same as set value 824288");
+
+diag "Try setting max memory when domain is running";
+ok_error(sub { $dom->set_max_memory("1048576") }, "not allowed to set max memory when domain is running");
+
+diag "Destroying the transient domain";
+$dom->destroy;
+
+diag "Check memory of shutdown domain";
+is($dom->get_info()->{memory}, 624288, "Get memory is 624288 when domain is shutdown");
+
+diag "Set max memory with set_memory";
+lives_ok(sub { $dom->set_memory("1148576", Sys::Virt::Domain::MEM_MAXIMUM) }, "Set max memory succeed with set_memory");
+
+diag "Get max memory for domain";
+is($dom->get_info()->{maxMem}, 1148576, "Get max memory is same as set value 1148576");
+
+diag "Try setting live state memory when domain is shutdown";
+ok_error(sub { $dom->set_memory("824288", Sys::Virt::Domain::MEM_LIVE) }, "not allowed to set live state memory when domain is shutdown");
-- 
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]