Yeela Kaplan has uploaded a new change for review.
Change subject: tests: add unit tests for IOProcess per SD
......................................................................
tests: add unit tests for IOProcess per SD
Change-Id: I904a33e45ad935856517b70f6bd3e6e5d56ca187
Signed-off-by: Yeela Kaplan <ykaplan(a)redhat.com>
---
M tests/outOfProcessTests.py
1 file changed, 48 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/78/34578/1
diff --git a/tests/outOfProcessTests.py b/tests/outOfProcessTests.py
index e49930f..94918a0 100644
--- a/tests/outOfProcessTests.py
+++ b/tests/outOfProcessTests.py
@@ -22,13 +22,61 @@
import storage.outOfProcess as oop
import os
import tempfile
+import time
+import re
+from weakref import ref
+
+from vdsm.config import config
class OopWrapperTests(TestCaseBase):
+ IOPROC_IDLE_TIME = config.getint("irs",
"max_ioprocess_idle_time")
+
def setUp(self):
oop.setDefaultImpl(oop.IOPROC)
self.pool = oop.getGlobalProcPool()
+ def testSamePoolName(self):
+ poolA = "A"
+ pids = []
+ for pool in (poolA, poolA):
+ proc = oop.getProcessPool(pool)._ioproc
+ name = proc._commthread.getName()
+ pids.append(int(re.search(r'\d+', name).group()))
+
+ self.assertEquals(pids[0], pids[1])
+
+ def testDifferentPoolName(self):
+ poolA = "A"
+ poolB = "B"
+ pools = (poolA, poolB)
+ pids = []
+ for pool in pools:
+ proc = oop.getProcessPool(pool)._ioproc
+ name = proc._commthread.name
+ pids.append(int(re.search(r'\d+', name).group()))
+
+ self.assertNotEquals(pids[0], pids[1])
+
+ def testAmountOfInstancesPerPoolName(self):
+ poolA = "A"
+ poolB = "B"
+ wrapper = ref(oop.getProcessPool(poolA))
+ ioproc = ref(oop.getProcessPool(poolA)._ioproc)
+ oop.getProcessPool(poolA)
+ time.sleep(self.IOPROC_IDLE_TIME + 1)
+ oop.getProcessPool(poolB)
+ self.assertEquals(wrapper(), None)
+ import gc
+ gc.collect()
+ time.sleep(1)
+ gc.collect()
+ print "GARBAGE: ", gc.garbage
+ refs = gc.get_referrers(ioproc())
+ print refs
+ print gc.get_referrers(*refs)
+ self.assertEquals(ioproc(), None)
+
def testEcho(self):
data = """Censorship always defeats it own purpose, for it creates
in
the end the kind of society that is incapable of exercising
--
To view, visit
http://gerrit.ovirt.org/34578
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I904a33e45ad935856517b70f6bd3e6e5d56ca187
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Yeela Kaplan <ykaplan(a)redhat.com>