Change in vdsm[master]: API: move diskSizeExtend logic from BindingXMLRPC
by derez@redhat.com
Daniel Erez has uploaded a new change for review.
Change subject: API: move diskSizeExtend logic from BindingXMLRPC
......................................................................
API: move diskSizeExtend logic from BindingXMLRPC
In order to make cold extend disk usable
with JSON-RPC, move logic verifying specified
VM id from 'BindingXMLRPC -> diskSizeExtend' into
'API (VM class) -> diskSizeExtend'
[since there's no other mediator for this logic
to both xml/json rpc protocols].
Change-Id: I9014154f376609d8bd547b7c008954981785b551
Bug-Url: https://bugzilla.redhat.com/1178499
Signed-off-by: Daniel Erez <derez(a)redhat.com>
---
M vdsm/API.py
M vdsm/rpc/BindingXMLRPC.py
2 files changed, 13 insertions(+), 15 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/90/36590/1
diff --git a/vdsm/API.py b/vdsm/API.py
index 2aeaac0..6c5db7e 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -590,10 +590,17 @@
return v.diskReplicateFinish(srcDisk, dstDisk)
def diskSizeExtend(self, driveSpecs, newSize):
- v = self._cif.vmContainer.get(self._UUID)
- if not v:
- return errCode['noVM']
- return v.diskSizeExtend(driveSpecs, newSize)
+ if self._UUID == VM.BLANK_UUID:
+ try:
+ volume = Volume(
+ driveSpecs['volumeID'], driveSpecs['poolID'],
+ driveSpecs['domainID'], driveSpecs['imageID'])
+ except KeyError:
+ return errCode['imageErr']
+ return volume.updateSize(newSize)
+ else:
+ v = self._cif.vmContainer.get(self._UUID)
+ return v.diskSizeExtend(driveSpecs, newSize)
def pause(self):
v = self._cif.vmContainer.get(self._UUID)
diff --git a/vdsm/rpc/BindingXMLRPC.py b/vdsm/rpc/BindingXMLRPC.py
index 759ed78..a6b75f3 100644
--- a/vdsm/rpc/BindingXMLRPC.py
+++ b/vdsm/rpc/BindingXMLRPC.py
@@ -543,17 +543,8 @@
return api.getDiskAlignment(driveSpecs)
def diskSizeExtend(self, vmId, driveSpecs, newSize):
- if vmId == API.VM.BLANK_UUID:
- try:
- volume = API.Volume(
- driveSpecs['volumeID'], driveSpecs['poolID'],
- driveSpecs['domainID'], driveSpecs['imageID'])
- except KeyError:
- return errCode['imageErr']
- return volume.updateSize(newSize)
- else:
- vm = API.VM(vmId)
- return vm.diskSizeExtend(driveSpecs, newSize)
+ api = API.VM(vmId)
+ return api.diskSizeExtend(driveSpecs, newSize)
def addNetwork(self, bridge, vlan=None, bond=None, nics=None,
options=None):
--
To view, visit http://gerrit.ovirt.org/36590
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9014154f376609d8bd547b7c008954981785b551
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Daniel Erez <derez(a)redhat.com>
9 years, 4 months
Change in vdsm[master]: ip route: parse unreachable routes
by Dan Kenigsberg
Dan Kenigsberg has uploaded a new change for review.
Change subject: ip route: parse unreachable routes
......................................................................
ip route: parse unreachable routes
Currently I do not understand why routes like
unreachable ::ffff:0.0.0.0/96 dev lo metric 1024 error -101
show up on my host, but failure to parse them leads to test failures.
Change-Id: Ia0a882aa1b57dc0c7b26095205b884ae9eff0173
Signed-off-by: Dan Kenigsberg <danken(a)redhat.com>
---
M lib/vdsm/ipwrapper.py
1 file changed, 6 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/71/35971/1
diff --git a/lib/vdsm/ipwrapper.py b/lib/vdsm/ipwrapper.py
index 31affaa..ed00fb7 100644
--- a/lib/vdsm/ipwrapper.py
+++ b/lib/vdsm/ipwrapper.py
@@ -343,6 +343,10 @@
"""
route = text.split()
+ unreachable = route[0] == 'unreachable'
+ if unreachable:
+ route = route[1:]
+
network = route[0]
if network == 'local':
params = route[2:]
@@ -351,6 +355,8 @@
data = dict(params[i:i + 2] for i in range(0, len(params), 2))
data['network'] = '0.0.0.0/0' if network == 'default' else network
+ if unreachable:
+ data['unreachable'] = True
return data
@classmethod
--
To view, visit http://gerrit.ovirt.org/35971
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia0a882aa1b57dc0c7b26095205b884ae9eff0173
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken(a)redhat.com>
9 years, 4 months
Change in vdsm[master]: Add tests for getAllVolumes
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: Add tests for getAllVolumes
......................................................................
Add tests for getAllVolumes
Profiling show that FileStorageDomain.getAllVolumes is too slow, taking more
then 30% of cpu time when running 20 vms. Each call on the test machine took 39
seconds of cpu time. This patch adds tests before we optimize this.
Change-Id: Ia43d8970ffc9bb8ee7679232ff3ee95cb2cda36c
Relates-To: https://bugzilla.redhat.com/1177634
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M tests/Makefile.am
A tests/fileSDTests.py
2 files changed, 153 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/89/36589/1
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f644799..356e08a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -32,6 +32,7 @@
configNetworkTests.py \
domainMonitorTests.py \
domainDescriptorTests.py \
+ fileSDTests.py \
fileVolumeTests.py \
fileUtilTests.py \
fuserTests.py \
diff --git a/tests/fileSDTests.py b/tests/fileSDTests.py
new file mode 100644
index 0000000..0949ba2
--- /dev/null
+++ b/tests/fileSDTests.py
@@ -0,0 +1,152 @@
+#
+# Copyright 2014 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+import fnmatch
+import os
+import time
+import uuid
+
+from testlib import VdsmTestCase as TestCaseBase
+from testValidation import brokentest
+
+from storage import fileSD
+from storage import sd
+
+
+class TestingFileStorageDomain(fileSD.FileStorageDomain):
+
+ stat = None # Accessed in __del__
+
+ def __init__(self, uuid, mountpoint, oop):
+ self.sdUUID = uuid
+ self.mountpoint = mountpoint
+ self._oop = oop
+
+ @property
+ def oop(self):
+ return self._oop
+
+
+class FakeGlob(object):
+
+ def __init__(self, files):
+ self.files = files
+
+ def glob(self, pattern):
+ return fnmatch.filter(self.files, pattern)
+
+
+class FakeOOP(object):
+
+ def __init__(self, glob=None):
+ self.glob = glob
+
+
+class GetAllVolumesTests(TestCaseBase):
+
+ MOUNTPOINT = "/rhev/data-center/%s" % uuid.uuid4()
+ SD_UUID = str(uuid.uuid4())
+ IMAGES_DIR = os.path.join(MOUNTPOINT, SD_UUID, sd.DOMAIN_IMAGES)
+
+ def test_no_volumes(self):
+ oop = FakeOOP(FakeGlob([]))
+ dom = TestingFileStorageDomain(self.SD_UUID, self.MOUNTPOINT, oop)
+ res = dom.getAllVolumes()
+ self.assertEqual(res, {})
+
+ def test_no_templates(self):
+ oop = FakeOOP(FakeGlob([
+ os.path.join(self.IMAGES_DIR, "image-1", "volume-1.meta"),
+ os.path.join(self.IMAGES_DIR, "image-1", "volume-2.meta"),
+ os.path.join(self.IMAGES_DIR, "image-1", "volume-3.meta"),
+ os.path.join(self.IMAGES_DIR, "image-2", "volume-4.meta"),
+ os.path.join(self.IMAGES_DIR, "image-2", "volume-5.meta"),
+ os.path.join(self.IMAGES_DIR, "image-3", "volume-6.meta"),
+ ]))
+ print oop.glob.files
+ dom = TestingFileStorageDomain(self.SD_UUID, self.MOUNTPOINT, oop)
+ res = dom.getAllVolumes()
+
+ # These volumes should have parent uuid, but the implemenetation does
+ # not read the meta data files, so this info is not available (None).
+ self.assertEqual(res, {
+ "volume-1": (("image-1",), None),
+ "volume-2": (("image-1",), None),
+ "volume-3": (("image-1",), None),
+ "volume-4": (("image-2",), None),
+ "volume-5": (("image-2",), None),
+ "volume-6": (("image-3",), None),
+ })
+
+ def test_with_template(self):
+ oop = FakeOOP(FakeGlob([
+ os.path.join(self.IMAGES_DIR, "template-1", "volume-1.meta"),
+ os.path.join(self.IMAGES_DIR, "image-1", "volume-1.meta"),
+ os.path.join(self.IMAGES_DIR, "image-1", "volume-2.meta"),
+ os.path.join(self.IMAGES_DIR, "image-1", "volume-3.meta"),
+ os.path.join(self.IMAGES_DIR, "image-2", "volume-1.meta"),
+ os.path.join(self.IMAGES_DIR, "image-2", "volume-4.meta"),
+ ]))
+ dom = TestingFileStorageDomain(self.SD_UUID, self.MOUNTPOINT, oop)
+ res = dom.getAllVolumes()
+
+ # For template volumes, we have parent uuid
+ self.assertEqual(len(res), 4)
+ self.assertEqual(sorted(res["volume-1"].imgs),
+ ["image-1", "image-2", "template-1"])
+ self.assertEqual(res["volume-1"].parent, sd.BLANK_UUID)
+
+ self.assertEqual(res["volume-2"], (("image-1",), None))
+ self.assertEqual(res["volume-3"], (("image-1",), None))
+ self.assertEqual(res["volume-4"], (("image-2",), None))
+
+ @brokentest("too slow in current code")
+ def test_scale(self):
+ # For this test we want real world strings
+ images_count = 5000
+ template_image_uuid = str(uuid.uuid4())
+ template_volume_uuid = str(uuid.uuid4())
+
+ files = []
+ template_volume = os.path.join(self.IMAGES_DIR, template_image_uuid,
+ template_volume_uuid + ".meta")
+ files.append(template_volume)
+
+ for i in range(images_count):
+ image_uuid = str(uuid.uuid4())
+ volume_uuid = str(uuid.uuid4())
+ template_volume = os.path.join(self.IMAGES_DIR, image_uuid,
+ template_volume_uuid + ".meta")
+ files.append(template_volume)
+ new_volume = os.path.join(self.IMAGES_DIR, image_uuid,
+ volume_uuid + ".meta")
+ files.append(new_volume)
+
+ oop = FakeOOP(FakeGlob(files))
+ dom = TestingFileStorageDomain(self.SD_UUID, self.MOUNTPOINT, oop)
+
+ start = time.time()
+ res = dom.getAllVolumes()
+ elapsed = time.time() - start
+ print "%f seconds" % elapsed
+
+ # This task should take no time using decent algorithm, using one
+ # second to make sure it will not fail on a overloaded test slave.
+ self.assertTrue(elapsed < 1.0)
--
To view, visit http://gerrit.ovirt.org/36589
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia43d8970ffc9bb8ee7679232ff3ee95cb2cda36c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
9 years, 4 months
Change in vdsm[master]: contrib: add useful zsh functions to assist in vdsm development
by phoracek@redhat.com
Petr Horáček has posted comments on this change.
Change subject: contrib: add useful zsh functions to assist in vdsm development
......................................................................
Patch Set 3:
(1 comment)
http://gerrit.ovirt.org/#/c/36344/3/contrib/zshrc
File contrib/zshrc:
Line 31: }
Line 32:
Line 33: vdsm_remove() {
Line 34: sudo yum erase -y `rpm -qa | grep vdsm | perl -pe 's|-[0-9].*||' | paste -sd " "` && \
Line 35: git clean -fdx
cd would help
Line 36: }
Line 37:
Line 38: vdsm_install() {
Line 39: VERSION=`ls ~/rpmbuild/RPMS/x86_64/ -t -w 1 | head -1 | perl -pe 's|^.*?git|git|' | perl -pe 's|\..*$||'`
--
To view, visit http://gerrit.ovirt.org/36344
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ide4131db838640a5836fd029696849bced267308
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <toni(a)midokura.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Ido Barkan <ibarkan(a)redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: Ondřej Svoboda <osvoboda(a)redhat.com>
Gerrit-Reviewer: Petr Horáček <phoracek(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
9 years, 4 months
Change in vdsm[master]: contrib: add useful zsh functions to assist in vdsm development
by phoracek@redhat.com
Petr Horáček has posted comments on this change.
Change subject: contrib: add useful zsh functions to assist in vdsm development
......................................................................
Patch Set 3:
(4 comments)
http://gerrit.ovirt.org/#/c/36344/3/contrib/zshrc
File contrib/zshrc:
Line 82: del_dummies() {
Line 83: for nic in `ip l | awk '{print $2;}' | egrep "^dummy"`; do
Line 84: sudo ip link del dev ${nic[0,-2]}
Line 85: done
Line 86: sudo rm /etc/sysconfig/network-scripts/ifcfg-dummy*
* without \
Line 87: }
Line 88:
Line 89: del_bonds() {
Line 90: for nic in `ip l | awk '{print $2;}' | egrep "^bond"`; do
Line 89: del_bonds() {
Line 90: for nic in `ip l | awk '{print $2;}' | egrep "^bond"`; do
Line 91: sudo echo "-${nic[0,-2]} "> /sys/class/net/bonding_masters
Line 92: done
Line 93: sudo rm /etc/sysconfig/network-scripts/ifcfg-bond\*
* with \
Line 94: }
Line 95:
Line 96: del_bridges() {
Line 97: for bridge in `brctl show | awk '{print $1;}' | grep test-network`; do
Line 151: }
Line 152:
Line 153: vdsm_pep8() {
Line 154: PEP8_BLACKLIST=config.py,constants.py,crossImportsTests.py,vdsm.py
Line 155: /usr/bin/pep8 --exclude=$PEP8_BLACKLIST --filename '*.py,*.py.in' .
would be better with cd ~/code/vdsm, like vdsm_unit()
Line 156: }
Line 157:
Line 158: vdsm_unit () {
Line 159: cd ~/code/vdsm && \
Line 155: /usr/bin/pep8 --exclude=$PEP8_BLACKLIST --filename '*.py,*.py.in' .
Line 156: }
Line 157:
Line 158: vdsm_unit () {
Line 159: cd ~/code/vdsm && \
vdsm folder could be stored in an variable
Line 160: ./autogen.sh --system && make && \
Line 161: cd tests && sudo ./run_tests_local.sh $1
Line 162: }
Line 163:
--
To view, visit http://gerrit.ovirt.org/36344
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ide4131db838640a5836fd029696849bced267308
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <toni(a)midokura.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Ido Barkan <ibarkan(a)redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: Ondřej Svoboda <osvoboda(a)redhat.com>
Gerrit-Reviewer: Petr Horáček <phoracek(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
9 years, 4 months
Change in vdsm[master]: contrib: add useful zsh functions to assist in vdsm development
by ibarkan@redhat.com
Ido Barkan has posted comments on this change.
Change subject: contrib: add useful zsh functions to assist in vdsm development
......................................................................
Patch Set 3:
Petr, I agree, but why choose? Can make the changes and post as another patch?
--
To view, visit http://gerrit.ovirt.org/36344
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ide4131db838640a5836fd029696849bced267308
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <toni(a)midokura.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Ido Barkan <ibarkan(a)redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: Ondřej Svoboda <osvoboda(a)redhat.com>
Gerrit-Reviewer: Petr Horáček <phoracek(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: No
9 years, 4 months
Change in vdsm[master]: contrib: add useful zsh functions to assist in vdsm development
by phoracek@redhat.com
Petr Horáček has posted comments on this change.
Change subject: contrib: add useful zsh functions to assist in vdsm development
......................................................................
Patch Set 3:
Zsh is awesome, bud wouldn't be better to do it with bash? It needs just minimal changes (few apostrophes and alternative for asterisks).
--
To view, visit http://gerrit.ovirt.org/36344
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ide4131db838640a5836fd029696849bced267308
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <toni(a)midokura.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Ido Barkan <ibarkan(a)redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: Ondřej Svoboda <osvoboda(a)redhat.com>
Gerrit-Reviewer: Petr Horáček <phoracek(a)redhat.com>
Gerrit-Reviewer: automation(a)ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: No
9 years, 4 months
Change in vdsm[master]: profiling: avoid to crash VDSM if yappi is missing
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: profiling: avoid to crash VDSM if yappi is missing
......................................................................
profiling: avoid to crash VDSM if yappi is missing
Add protection around lazy yappi import
to avoid crashing VDSM in presence of inconsistent
configuration: profiling enabled but yappi package
not installed.
Provide error message explaining the failure, and
add consistency with more complex memory profiling
which benefits of this protection, and has
a more complex setup.
Change-Id: I8272b25afe507038f930929f4b51d6d8f5b73495
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M lib/vdsm/profiling/cpu.py
1 file changed, 13 insertions(+), 9 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/12/36012/1
diff --git a/lib/vdsm/profiling/cpu.py b/lib/vdsm/profiling/cpu.py
index 916892c..137e6a2 100644
--- a/lib/vdsm/profiling/cpu.py
+++ b/lib/vdsm/profiling/cpu.py
@@ -94,20 +94,24 @@
global yappi
logging.debug("Starting CPU profiling")
with _lock:
- import yappi
- # yappi start semantics are a bit too liberal, returning success if
- # yappi is already started, happily having too different code paths
- # that thinks they own the single process profiler.
- if yappi.is_running():
- raise Error('CPU profiler is already running')
- yappi.set_clock_type(clock)
- yappi.start(builtins=builtins, profile_threads=threads)
+ try:
+ import yappi
+ except ImportError as e:
+ logging.warning("Error starting cpu profiler: %s", e)
+ else:
+ # yappi start semantics are a bit too liberal, returning success
+ # if yappi is already started, happily having too different code
+ # paths that thinks they own the single process profiler.
+ if yappi.is_running():
+ raise Error('Profiler is already running')
+ yappi.set_clock_type(clock)
+ yappi.start(builtins=builtins, profile_threads=threads)
def _stop_profiling(filename, format):
logging.debug("Stopping CPU profiling")
with _lock:
- if yappi.is_running():
+ if yappi is not None and yappi.is_running():
yappi.stop()
stats = yappi.get_func_stats()
stats.save(filename, format)
--
To view, visit http://gerrit.ovirt.org/36012
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8272b25afe507038f930929f4b51d6d8f5b73495
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
9 years, 4 months
Change in vdsm[master]: tests: profile: use make_config from testlib
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: tests: profile: use make_config from testlib
......................................................................
tests: profile: use make_config from testlib
Recently a generic utility to build new
custom instances of VDSM config was added to testlib.
This function is equivalent, but more generic, to the
one previously bundled with profileTests.
This patch makes profileTests use the code from testlib.
Change-Id: Iee786163d9e8543109b3e6de9863d892e34ae903
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M tests/profileTests.py
1 file changed, 41 insertions(+), 28 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/79/36579/1
diff --git a/tests/profileTests.py b/tests/profileTests.py
index 95bcfb1..e618062 100644
--- a/tests/profileTests.py
+++ b/tests/profileTests.py
@@ -30,7 +30,7 @@
from monkeypatch import MonkeyPatch
from nose.plugins.skip import SkipTest
-from testlib import VdsmTestCase
+from testlib import VdsmTestCase, make_config
yappi = None
try:
@@ -39,13 +39,6 @@
pass
FILENAME = __file__ + '.prof'
-
-
-def make_config(enable='false'):
- cfg = ConfigParser.ConfigParser()
- config.set_defaults(cfg)
- cfg.set('devel', 'profile_enable', enable)
- return cfg
def requires_yappi():
@@ -65,7 +58,8 @@
class ApplicationProfileTests(ProfileTests):
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
@MonkeyPatch(profile, '_FILENAME', FILENAME)
@MonkeyPatch(profile, '_FORMAT', 'pstat')
def test_pstats_format(self):
@@ -75,7 +69,8 @@
profile.stop()
self.assertNotRaises(pstats.Stats, FILENAME)
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
@MonkeyPatch(profile, '_FILENAME', FILENAME)
@MonkeyPatch(profile, '_FORMAT', 'ystat')
def test_ystats_format(self):
@@ -85,7 +80,8 @@
profile.stop()
self.assertNotRaises(open_ystats, FILENAME)
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
@MonkeyPatch(profile, '_FILENAME', FILENAME)
@MonkeyPatch(profile, '_FORMAT', 'ystat')
@MonkeyPatch(profile, '_BUILTINS', True)
@@ -97,7 +93,8 @@
stats = open_ystats(FILENAME)
self.assertTrue(find_module(stats, '__builtin__'))
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
@MonkeyPatch(profile, '_FILENAME', FILENAME)
@MonkeyPatch(profile, '_FORMAT', 'ystat')
@MonkeyPatch(profile, '_BUILTINS', False)
@@ -109,7 +106,8 @@
stats = open_ystats(FILENAME)
self.assertFalse(find_module(stats, '__builtin__'))
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
@MonkeyPatch(profile, '_FILENAME', FILENAME)
@MonkeyPatch(profile, '_FORMAT', 'ystat')
@MonkeyPatch(profile, '_CLOCK', 'cpu')
@@ -123,7 +121,8 @@
func = find_function(stats, __file__, name)
self.assertTrue(func.ttot < 0.1)
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
@MonkeyPatch(profile, '_FILENAME', FILENAME)
@MonkeyPatch(profile, '_FORMAT', 'ystat')
@MonkeyPatch(profile, '_CLOCK', 'wall')
@@ -137,7 +136,8 @@
func = find_function(stats, __file__, name)
self.assertTrue(func.ttot > 0.1)
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
@MonkeyPatch(profile, '_FILENAME', FILENAME)
def test_is_running(self):
requires_yappi()
@@ -149,13 +149,15 @@
profile.stop()
self.assertFalse(profile.is_running())
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
def test_is_enabled(self):
requires_yappi()
self.assertTrue(profile.is_enabled())
# This must succeed even if yappi is not installed
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_disabled(self):
profile.start()
try:
@@ -170,7 +172,8 @@
class FunctionProfileTests(ProfileTests):
# Function profile must succeed if profile is disabled in config.
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_profile_disabled(self):
requires_yappi()
self.profiled_function()
@@ -178,7 +181,8 @@
# Function profile must fail if profile is enabled in config - we cannot
# use application wide profile and function profile in the same time.
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
@MonkeyPatch(profile, '_FILENAME', FILENAME)
def test_fail_if_Profile_is_running(self):
requires_yappi()
@@ -189,32 +193,37 @@
profile.stop()
# It is not possible to call a profiled function from a profiled function.
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_fail_recursive_profile(self):
requires_yappi()
self.assertRaises(profile.Error, self.recursive_profile)
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_ystat_format(self):
requires_yappi()
self.ystat_format()
self.assertNotRaises(open_ystats, FILENAME)
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_with_builtins(self):
requires_yappi()
self.with_builtins()
stats = open_ystats(FILENAME)
self.assertTrue(find_module(stats, '__builtin__'))
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_without_builtins(self):
requires_yappi()
self.without_builtins()
stats = open_ystats(FILENAME)
self.assertFalse(find_module(stats, '__builtin__'))
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_cpu_clock(self):
requires_yappi()
self.cpu_clock()
@@ -223,7 +232,8 @@
func = find_function(stats, __file__, name)
self.assertTrue(func.ttot < 0.1)
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_wall_clock(self):
requires_yappi()
self.wall_clock()
@@ -268,7 +278,8 @@
self.ready = threading.Event()
self.resume = threading.Event()
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_new_threads(self):
# The easy case - threads started after yappi was started
requires_yappi()
@@ -278,7 +289,8 @@
func = find_function(stats, __file__, name)
self.assertEquals(func.ncall, 1)
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_running_threads(self):
# The harder case - threads started before yappi was started
requires_yappi()
@@ -289,7 +301,8 @@
func = find_function(stats, __file__, name)
self.assertEquals(func.ncall, 1)
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profile, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_without_threads(self):
requires_yappi()
self.without_threads()
--
To view, visit http://gerrit.ovirt.org/36579
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iee786163d9e8543109b3e6de9863d892e34ae903
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
9 years, 4 months
Change in vdsm[master]: profile: transform into a subpackage
by fromani@redhat.com
Francesco Romani has uploaded a new change for review.
Change subject: profile: transform into a subpackage
......................................................................
profile: transform into a subpackage
this patch tranforms the profile module into the
profiling subpackage, to make room for the memory
profiling module.
No code change besides moving around and fixing imports.
Change-Id: Idfd925e566a9af69d4b42a70fa835b072bb1f7a0
Signed-off-by: Francesco Romani <fromani(a)redhat.com>
---
M configure.ac
M debian/vdsm-python.install
M lib/vdsm/Makefile.am
A lib/vdsm/profiling/Makefile.am
A lib/vdsm/profiling/__init__.py
R lib/vdsm/profiling/cpu.py
M tests/profileTests.py
M vdsm.spec.in
M vdsm/vdsm
9 files changed, 171 insertions(+), 93 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/10/36010/1
diff --git a/configure.ac b/configure.ac
index 71901ac..9d99373 100644
--- a/configure.ac
+++ b/configure.ac
@@ -340,6 +340,7 @@
lib/Makefile
lib/vdsm/Makefile
lib/vdsm/netlink/Makefile
+ lib/vdsm/profiling/Makefile
lib/vdsm/tool/Makefile
lib/vdsm/tool/configurators/Makefile
lib/yajsonrpc/Makefile
diff --git a/debian/vdsm-python.install b/debian/vdsm-python.install
index f633e54..6a4b90f 100644
--- a/debian/vdsm-python.install
+++ b/debian/vdsm-python.install
@@ -14,7 +14,8 @@
./usr/lib/python2.7/dist-packages/vdsm/netlink/addr.py
./usr/lib/python2.7/dist-packages/vdsm/netlink/link.py
./usr/lib/python2.7/dist-packages/vdsm/netlink/route.py
-./usr/lib/python2.7/dist-packages/vdsm/profile.py
+./usr/lib/python2.7/dist-packages/vdsm/profiling/__init__.py
+./usr/lib/python2.7/dist-packages/vdsm/profiling/cpu.py
./usr/lib/python2.7/dist-packages/vdsm/qemuimg.py
./usr/lib/python2.7/dist-packages/vdsm/sslutils.py
./usr/lib/python2.7/dist-packages/vdsm/tool/__init__.py
diff --git a/lib/vdsm/Makefile.am b/lib/vdsm/Makefile.am
index b862e71..3423e3c 100644
--- a/lib/vdsm/Makefile.am
+++ b/lib/vdsm/Makefile.am
@@ -19,7 +19,7 @@
#
include $(top_srcdir)/build-aux/Makefile.subs
-SUBDIRS=netlink tool infra
+SUBDIRS=netlink tool infra profiling
dist_vdsmpylib_PYTHON = \
__init__.py \
@@ -30,7 +30,6 @@
libvirtconnection.py \
netconfpersistence.py \
netinfo.py \
- profile.py \
qemuimg.py \
sslutils.py \
utils.py \
diff --git a/lib/vdsm/profiling/Makefile.am b/lib/vdsm/profiling/Makefile.am
new file mode 100644
index 0000000..78f80be
--- /dev/null
+++ b/lib/vdsm/profiling/Makefile.am
@@ -0,0 +1,26 @@
+#
+# Copyright 2014 Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+include $(top_srcdir)/build-aux/Makefile.subs
+
+vdsmprofilingdir = $(vdsmpylibdir)/profiling
+dist_vdsmprofiling_PYTHON = \
+ __init__.py \
+ cpu.py \
+ $(NULL)
diff --git a/lib/vdsm/profiling/__init__.py b/lib/vdsm/profiling/__init__.py
new file mode 100644
index 0000000..c27471a
--- /dev/null
+++ b/lib/vdsm/profiling/__init__.py
@@ -0,0 +1,37 @@
+#
+# Copyright 2014 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+import cpu
+
+
+def start():
+ cpu.start()
+
+
+def stop():
+ cpu.stop()
+
+
+def is_enabled():
+ return cpu.is_enabled()
+
+
+def is_running():
+ return cpu.is_running()
diff --git a/lib/vdsm/profile.py b/lib/vdsm/profiling/cpu.py
similarity index 97%
rename from lib/vdsm/profile.py
rename to lib/vdsm/profiling/cpu.py
index 9710225..7ee3240 100644
--- a/lib/vdsm/profile.py
+++ b/lib/vdsm/profiling/cpu.py
@@ -86,6 +86,7 @@
finally:
_stop_profiling(filename, format)
return wrapper
+ print 'called(%s, %s)' % (filename, format)
return decorator
diff --git a/tests/profileTests.py b/tests/profileTests.py
index 95bcfb1..91f316c 100644
--- a/tests/profileTests.py
+++ b/tests/profileTests.py
@@ -25,12 +25,11 @@
import time
import threading
-from vdsm import profile
-from vdsm import config
+from vdsm import profiling
from monkeypatch import MonkeyPatch
from nose.plugins.skip import SkipTest
-from testlib import VdsmTestCase
+from testlib import VdsmTestCase, make_config
yappi = None
try:
@@ -39,13 +38,6 @@
pass
FILENAME = __file__ + '.prof'
-
-
-def make_config(enable='false'):
- cfg = ConfigParser.ConfigParser()
- config.set_defaults(cfg)
- cfg.set('devel', 'profile_enable', enable)
- return cfg
def requires_yappi():
@@ -65,103 +57,112 @@
class ApplicationProfileTests(ProfileTests):
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
- @MonkeyPatch(profile, '_FILENAME', FILENAME)
- @MonkeyPatch(profile, '_FORMAT', 'pstat')
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
+ @MonkeyPatch(profiling.cpu, '_FILENAME', FILENAME)
+ @MonkeyPatch(profiling.cpu, '_FORMAT', 'pstat')
def test_pstats_format(self):
requires_yappi()
- profile.start()
- profile.is_running() # Let if profile something
- profile.stop()
+ profiling.cpu.start()
+ profiling.cpu.is_running() # Let if profile something
+ profiling.cpu.stop()
self.assertNotRaises(pstats.Stats, FILENAME)
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
- @MonkeyPatch(profile, '_FILENAME', FILENAME)
- @MonkeyPatch(profile, '_FORMAT', 'ystat')
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
+ @MonkeyPatch(profiling.cpu, '_FILENAME', FILENAME)
+ @MonkeyPatch(profiling.cpu, '_FORMAT', 'ystat')
def test_ystats_format(self):
requires_yappi()
- profile.start()
- profile.is_running() # Let if profile something
- profile.stop()
+ profiling.cpu.start()
+ profiling.cpu.is_running() # Let if profile something
+ profiling.cpu.stop()
self.assertNotRaises(open_ystats, FILENAME)
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
- @MonkeyPatch(profile, '_FILENAME', FILENAME)
- @MonkeyPatch(profile, '_FORMAT', 'ystat')
- @MonkeyPatch(profile, '_BUILTINS', True)
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
+ @MonkeyPatch(profiling.cpu, '_FILENAME', FILENAME)
+ @MonkeyPatch(profiling.cpu, '_FORMAT', 'ystat')
+ @MonkeyPatch(profiling.cpu, '_BUILTINS', True)
def test_with_builtins(self):
requires_yappi()
- profile.start()
+ profiling.cpu.start()
dict()
- profile.stop()
+ profiling.cpu.stop()
stats = open_ystats(FILENAME)
self.assertTrue(find_module(stats, '__builtin__'))
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
- @MonkeyPatch(profile, '_FILENAME', FILENAME)
- @MonkeyPatch(profile, '_FORMAT', 'ystat')
- @MonkeyPatch(profile, '_BUILTINS', False)
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
+ @MonkeyPatch(profiling.cpu, '_FILENAME', FILENAME)
+ @MonkeyPatch(profiling.cpu, '_FORMAT', 'ystat')
+ @MonkeyPatch(profiling.cpu, '_BUILTINS', False)
def test_without_builtins(self):
requires_yappi()
- profile.start()
+ profiling.cpu.start()
dict()
- profile.stop()
+ profiling.cpu.stop()
stats = open_ystats(FILENAME)
self.assertFalse(find_module(stats, '__builtin__'))
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
- @MonkeyPatch(profile, '_FILENAME', FILENAME)
- @MonkeyPatch(profile, '_FORMAT', 'ystat')
- @MonkeyPatch(profile, '_CLOCK', 'cpu')
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
+ @MonkeyPatch(profiling.cpu, '_FILENAME', FILENAME)
+ @MonkeyPatch(profiling.cpu, '_FORMAT', 'ystat')
+ @MonkeyPatch(profiling.cpu, '_CLOCK', 'cpu')
def test_cpu_clock(self):
requires_yappi()
- profile.start()
+ profiling.cpu.start()
self.sleep(0.1)
- profile.stop()
+ profiling.cpu.stop()
stats = open_ystats(FILENAME)
name = function_name(self.sleep)
func = find_function(stats, __file__, name)
self.assertTrue(func.ttot < 0.1)
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
- @MonkeyPatch(profile, '_FILENAME', FILENAME)
- @MonkeyPatch(profile, '_FORMAT', 'ystat')
- @MonkeyPatch(profile, '_CLOCK', 'wall')
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
+ @MonkeyPatch(profiling.cpu, '_FILENAME', FILENAME)
+ @MonkeyPatch(profiling.cpu, '_FORMAT', 'ystat')
+ @MonkeyPatch(profiling.cpu, '_CLOCK', 'wall')
def test_wall_clock(self):
requires_yappi()
- profile.start()
+ profiling.cpu.start()
self.sleep(0.1)
- profile.stop()
+ profiling.cpu.stop()
stats = open_ystats(FILENAME)
name = function_name(self.sleep)
func = find_function(stats, __file__, name)
self.assertTrue(func.ttot > 0.1)
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
- @MonkeyPatch(profile, '_FILENAME', FILENAME)
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
+ @MonkeyPatch(profiling.cpu, '_FILENAME', FILENAME)
def test_is_running(self):
requires_yappi()
- self.assertFalse(profile.is_running())
- profile.start()
+ self.assertFalse(profiling.cpu.is_running())
+ profiling.cpu.start()
try:
- self.assertTrue(profile.is_running())
+ self.assertTrue(profiling.cpu.is_running())
finally:
- profile.stop()
- self.assertFalse(profile.is_running())
+ profiling.cpu.stop()
+ self.assertFalse(profiling.cpu.is_running())
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
def test_is_enabled(self):
requires_yappi()
- self.assertTrue(profile.is_enabled())
+ self.assertTrue(profiling.cpu.is_enabled())
# This must succeed even if yappi is not installed
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_disabled(self):
- profile.start()
+ profiling.cpu.start()
try:
- self.assertFalse(profile.is_running())
+ self.assertFalse(profiling.cpu.is_running())
finally:
- profile.stop()
+ profiling.cpu.stop()
def sleep(self, seconds):
time.sleep(seconds)
@@ -170,7 +171,8 @@
class FunctionProfileTests(ProfileTests):
# Function profile must succeed if profile is disabled in config.
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_profile_disabled(self):
requires_yappi()
self.profiled_function()
@@ -178,43 +180,49 @@
# Function profile must fail if profile is enabled in config - we cannot
# use application wide profile and function profile in the same time.
- @MonkeyPatch(profile, 'config', make_config(enable='true'))
- @MonkeyPatch(profile, '_FILENAME', FILENAME)
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'true')]))
+ @MonkeyPatch(profiling.cpu, '_FILENAME', FILENAME)
def test_fail_if_Profile_is_running(self):
requires_yappi()
- profile.start()
+ profiling.cpu.start()
try:
- self.assertRaises(profile.Error, self.profiled_function)
+ self.assertRaises(profiling.cpu.Error, self.profiled_function)
finally:
- profile.stop()
+ profiling.cpu.stop()
# It is not possible to call a profiled function from a profiled function.
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_fail_recursive_profile(self):
requires_yappi()
- self.assertRaises(profile.Error, self.recursive_profile)
+ self.assertRaises(profiling.cpu.Error, self.recursive_profile)
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_ystat_format(self):
requires_yappi()
self.ystat_format()
self.assertNotRaises(open_ystats, FILENAME)
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_with_builtins(self):
requires_yappi()
self.with_builtins()
stats = open_ystats(FILENAME)
self.assertTrue(find_module(stats, '__builtin__'))
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_without_builtins(self):
requires_yappi()
self.without_builtins()
stats = open_ystats(FILENAME)
self.assertFalse(find_module(stats, '__builtin__'))
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_cpu_clock(self):
requires_yappi()
self.cpu_clock()
@@ -223,7 +231,8 @@
func = find_function(stats, __file__, name)
self.assertTrue(func.ttot < 0.1)
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_wall_clock(self):
requires_yappi()
self.wall_clock()
@@ -232,31 +241,31 @@
func = find_function(stats, __file__, name)
self.assertTrue(func.ttot > 0.1)
- @profile.profile(FILENAME)
+ @profiling.cpu.profile(FILENAME)
def profiled_function(self):
- self.assertTrue(profile.is_running())
+ self.assertTrue(profiling.cpu.is_running())
- @profile.profile(FILENAME)
+ @profiling.cpu.profile(FILENAME)
def recursive_profile(self):
self.profiled_function()
- @profile.profile(FILENAME, format="ystat")
+ @profiling.cpu.profile(FILENAME, format="ystat")
def ystat_format(self):
pass
- @profile.profile(FILENAME, format="ystat", builtins=False)
+ @profiling.cpu.profile(FILENAME, format="ystat", builtins=False)
def without_builtins(self):
pass
- @profile.profile(FILENAME, format="ystat", builtins=True)
+ @profiling.cpu.profile(FILENAME, format="ystat", builtins=True)
def with_builtins(self):
pass
- @profile.profile(FILENAME, format="ystat", clock="cpu")
+ @profiling.cpu.profile(FILENAME, format="ystat", clock="cpu")
def cpu_clock(self):
time.sleep(0.1)
- @profile.profile(FILENAME, format="ystat", clock="wall")
+ @profiling.cpu.profile(FILENAME, format="ystat", clock="wall")
def wall_clock(self):
time.sleep(0.1)
@@ -268,7 +277,8 @@
self.ready = threading.Event()
self.resume = threading.Event()
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_new_threads(self):
# The easy case - threads started after yappi was started
requires_yappi()
@@ -278,7 +288,8 @@
func = find_function(stats, __file__, name)
self.assertEquals(func.ncall, 1)
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_running_threads(self):
# The harder case - threads started before yappi was started
requires_yappi()
@@ -289,7 +300,8 @@
func = find_function(stats, __file__, name)
self.assertEquals(func.ncall, 1)
- @MonkeyPatch(profile, 'config', make_config(enable='false'))
+ @MonkeyPatch(profiling.cpu, 'config',
+ make_config([('devel', 'profile_enable', 'false')]))
def test_without_threads(self):
requires_yappi()
self.without_threads()
@@ -297,16 +309,16 @@
name = function_name(self.worker_function)
self.assertRaises(NotFound, find_function, stats, __file__, name)
- @profile.profile(FILENAME, format="ystat", threads=True)
+ @profiling.cpu.profile(FILENAME, format="ystat", threads=True)
def new_threads(self):
self.start_thread()
self.join_thread()
- @profile.profile(FILENAME, format="ystat", threads=True)
+ @profiling.cpu.profile(FILENAME, format="ystat", threads=True)
def running_threads(self):
self.join_thread()
- @profile.profile(FILENAME, format="ystat", threads=False)
+ @profiling.cpu.profile(FILENAME, format="ystat", threads=False)
def without_threads(self):
self.start_thread()
self.join_thread()
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 6efd54b..dffadff 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1263,7 +1263,8 @@
%{python_sitelib}/%{vdsm_name}/netlink/addr.py*
%{python_sitelib}/%{vdsm_name}/netlink/link.py*
%{python_sitelib}/%{vdsm_name}/netlink/route.py*
-%{python_sitelib}/%{vdsm_name}/profile.py*
+%{python_sitelib}/%{vdsm_name}/profiling/__init__.py*
+%{python_sitelib}/%{vdsm_name}/profiling/cpu.py*
%{python_sitelib}/%{vdsm_name}/qemuimg.py*
%{python_sitelib}/%{vdsm_name}/netconfpersistence.py*
%{python_sitelib}/%{vdsm_name}/sslutils.py*
diff --git a/vdsm/vdsm b/vdsm/vdsm
index 5c1ab71..b67d9c2 100755
--- a/vdsm/vdsm
+++ b/vdsm/vdsm
@@ -34,7 +34,7 @@
from vdsm import utils
from vdsm.config import config
from vdsm import libvirtconnection
-from vdsm import profile
+from vdsm import profiling
from storage.dispatcher import Dispatcher
from storage.hsm import HSM
@@ -75,7 +75,7 @@
signal.signal(signal.SIGUSR1, sigusr1Handler)
zombiereaper.registerSignalHandler()
- profile.start()
+ profiling.start()
libvirtconnection.start_event_loop()
@@ -92,7 +92,7 @@
while running[0]:
signal.pause()
- profile.stop()
+ profiling.stop()
finally:
cif.prepareForShutdown()
--
To view, visit http://gerrit.ovirt.org/36010
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idfd925e566a9af69d4b42a70fa835b072bb1f7a0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Francesco Romani <fromani(a)redhat.com>
9 years, 4 months