[Zope-Checkins] CVS: Zope2 - testCatalog.py:1.1.4.10
Andreas Jung
andreas@dhcp165.digicool.com
Wed, 14 Mar 2001 10:12:27 -0500
Update of /cvs-repository/Zope2/lib/python/Products/ZCatalog/tests
In directory yetix:/work/Zope2/Catalog-BTrees-Integration/lib/python/Products/ZCatalog/tests
Modified Files:
Tag: Catalog-BTrees-Integration
testCatalog.py
Log Message:
minor changes
--- Updated File testCatalog.py in package Zope2 --
--- testCatalog.py 2001/03/13 22:45:07 1.1.4.9
+++ testCatalog.py 2001/03/14 15:12:24 1.1.4.10
@@ -7,6 +7,9 @@
Andreas Jung, andreas@digicool.com
$Log$
+ Revision 1.1.4.10 2001/03/14 15:12:24 andreas
+ minor changes
+
Revision 1.1.4.9 2001/03/13 22:45:07 andreas
yet another try/except clause (zope mbox file seems to contain some sloppy
messages)
@@ -190,7 +193,7 @@
for s in sub:
if not s in self.keywords: self.keywords.append(s)
-
+
self._catalog.aq_parent = None
@@ -294,8 +297,6 @@
self.init_phase = 0
self.setlog( open("dispatcher.log","a") )
- self.logn('treads=%d searchiterations=%d' % (numThreads,searchIterations))
- self.logn('updateiterations=%d maxfiles=%d' % (updateIterations,maxFiles))
def setUp(self):
@@ -306,22 +307,28 @@
self.zodb = testZODB("data/work/Data.fs",open=0)
self.threads = {}
+ self.init_zodb_size = self.zodb_size()
kw = keywords.Keywords()
kw.reload()
self.keywords = kw.keywords()
self.logn("-" * 80)
- self.log_zodb_size("before")
+ self.logn('treads=%d searchiterations=%d' % (numThreads,searchIterations))
+ self.logn('updateiterations=%d maxfiles=%d' % (updateIterations,maxFiles))
def tearDown(self):
- self.log_zodb_size("after")
+ self.log_zodb_size("before",self.init_zodb_size)
+ self.log_zodb_size("after ",self.zodb_size())
del self.zodb
self.zodb = self.catalog = None
+
+ def log_zodb_size(self,s,n):
+ self.logn("Size of ZODB (data/work/Data.fs) %s test : %s" % (s,n) )
- def log_zodb_size(self,s):
- self.logn("Size of ZODB (data/work/Data.fs) %s test : %s" % (s,self.size2size(os.stat("data/work/Data.fs")[6])) )
+ def zodb_size(self):
+ return self.size2size(os.stat("data/work/Data.fs")[6])
def size2size(self,n):
@@ -421,7 +428,7 @@
for i in range(searchIterations):
m = whrandom.randint(0,10000)
n = m + 200
- rg.append(m,n)
+ rg.append((m,n))
for i in range(searchIterations):
@@ -561,7 +568,7 @@
def funcReindexing(self,mbox,numfiles=100,modify_doc=0):
""" test reindexing of existing data """
- conflicts = 0
+ cat_conflicts = 0
cat,msg_ids = self.get_catalog()
env = self.th_setup()
@@ -579,13 +586,13 @@
cat.catalogObject(obj,mid)
get_transaction().commit()
except:
- conflicts = conflicts + 1
+ cat_conflicts = cat_conflicts + 1
msg = mb.next()
i = i+1
if i%100==0: print i
- env = self.th_teardown(env,conflicts=conflicts)
+ self.th_teardown(env,cat_conflicts=cat_conflicts)
#############################################################
@@ -793,6 +800,40 @@
self._catalog.uncatalogObject(`x`)
+class objRS(ExtensionClass.Base):
+
+ def __init__(self,num):
+ self.number = num
+
+class testRS(unittest.TestCase):
+
+ def setUp(self):
+ self._vocabulary = Vocabulary.Vocabulary('Vocabulary','Vocabulary', globbing=1)
+ self._catalog = Catalog.Catalog()
+ self._catalog.addIndex('number', 'FieldIndex')
+ self._catalog.addColumn('number')
+
+ for i in range(50000):
+ if i%1000==0: print i
+ obj = objRS(whrandom.randint(0,20000))
+ self._catalog.catalogObject(obj,i)
+
+ self._catalog.aq_parent = objRS(200)
+
+ def testRangeSearch(self):
+ for i in range(1000000):
+
+ m = whrandom.randint(0,20000)
+ n = m + 1000
+
+ for r in self._catalog.searchResults( {"number" : (m,n) ,"length_usage" : "range:min:max" } ):
+ size = r.number
+ assert m<=size and size<=n , "%d vs [%d,%d]" % (r.number,m,n)
+
+
+
+
+
def usage(program):
print "Usage: "
print
@@ -887,9 +928,10 @@
)
exp_tests = (
+# testRS("testRangeSearch"),
# testSearches("testReindexing",numThreads=1),
-# testSearches("testReindexingAndModify",numThreads=1),
- testSearches("testUpdates",numThreads=10,numUpdates=100),
+ testSearches("testReindexingAndModify",numThreads=1),
+# testSearches("testUpdates",numThreads=10,numUpdates=100),
)
init_tests = (