Skip to content

Commit

Permalink
Merge pull request autotest#6 from ldoktor/cgroup-kvm
Browse files Browse the repository at this point in the history
KVM test: cgroup test with KVM guest +first subtests
  • Loading branch information
lmr committed Sep 27, 2011
2 parents 49b1d9b + cd8c947 commit 6987ac1
Show file tree
Hide file tree
Showing 4 changed files with 366 additions and 6 deletions.
Empty file added client/tests/cgroup/__init__.py
Empty file.
40 changes: 34 additions & 6 deletions client/tests/cgroup/cgroup_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,20 @@ def __init__(self, module, _client):
self.module = module
self._client = _client
self.root = None
self.cgroups = []


def __del__(self):
"""
Destructor
"""
self.cgroups.sort(reverse=True)
for pwd in self.cgroups[:]:
for task in self.get_property("tasks", pwd):
if task:
self.set_root_cgroup(int(task))
self.rm_cgroup(pwd)

def initialize(self, modules):
"""
Initializes object for use.
Expand Down Expand Up @@ -57,6 +69,7 @@ def mk_cgroup(self, root=None):
except Exception, inst:
logging.error("cg.mk_cgroup(): %s" , inst)
return None
self.cgroups.append(pwd)
return pwd


Expand All @@ -70,6 +83,10 @@ def rm_cgroup(self, pwd, supress=False):
"""
try:
os.rmdir(pwd)
self.cgroups.remove(pwd)
except ValueError:
logging.warn("cg.rm_cgroup(): Removed cgroup which wasn't created"
"using this Cgroup")
except Exception, inst:
if not supress:
logging.error("cg.rm_cgroup(): %s" , inst)
Expand Down Expand Up @@ -309,6 +326,21 @@ def __init__(self):
self.modules.append([])
self.mountdir = mkdtemp(prefix='cgroup-') + '/'

def __del__(self):
"""
Unmount all cgroups and remove the mountdir
"""
for i in range(len(self.modules[0])):
if self.modules[2][i]:
try:
utils.system('umount %s -l' % self.modules[1][i])
except Exception, failure_detail:
logging.warn("CGM: Couldn't unmount %s directory: %s"
% (self.modules[1][i], failure_detail))
try:
shutil.rmtree(self.mountdir)
except:
logging.warn("CGM: Couldn't remove the %s directory", self.mountdir)

def init(self, _modules):
"""
Expand Down Expand Up @@ -356,13 +388,9 @@ def init(self, _modules):

def cleanup(self):
"""
Unmount all cgroups and remove the mountdir.
Kept for compatibility
"""
for i in range(len(self.modules[0])):
if self.modules[2][i]:
utils.system('umount %s -l' % self.modules[1][i],
ignore_status=True)
shutil.rmtree(self.mountdir)
pass


def get_pwd(self, module):
Expand Down
7 changes: 7 additions & 0 deletions client/tests/kvm/subtests.cfg.sample
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,13 @@ variants:
only Linux
type = iofuzz

- cgroup:
type = cgroup
# cgroup_tests = "re1[:loops] re2[:loops] ..."
cgroup_tests = ".*:1"
vms += " vm2"
extra_params += " -snapshot"

- virtio_console: install setup image_copy unattended_install.cdrom
only Linux
vms = ''
Expand Down
Loading

0 comments on commit 6987ac1

Please sign in to comment.