[Zope-Checkins] CVS: Zope2 - testCatalog.py:1.1.4.7
Andreas Jung
andreas@dhcp165.digicool.com
Tue, 13 Mar 2001 11:51:09 -0500
Update of /mnt/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:
code cleanup
--- Updated File testCatalog.py in package test --
--- testCatalog.py 2001/03/13 14:37:40 1.1.4.6
+++ testCatalog.py 2001/03/13 16:51:07 1.1.4.7
@@ -7,6 +7,9 @@
Andreas Jung, andreas@digicool.com
$Log$
+ Revision 1.1.4.7 2001/03/13 16:51:07 andreas
+ code cleanup
+
Revision 1.1.4.6 2001/03/13 14:37:40 andreas
prelimary version for integration into the Zope testsuites
@@ -206,12 +209,12 @@
l = list(s)
l.reverse()
return string.join(l,"")
-
def __del__(self):
pass
+
class BuildEnv(dispatcher.Dispatcher,unittest.TestCase):
""" build environment """
@@ -404,15 +407,11 @@
rg.append(m,n)
- results = []
- for i in range(searchIterations):
- results.append( cat.searchResults( {"length" : rg[i],"length_usage" : "range:min:max" } ))
-
-
for i in range(searchIterations):
- for r in results[i]:
+ for r in cat.searchResults( {"length" : rg[i],"length_usage" : "range:min:max" } ):
size = r.length
assert rg[i][0]<=size and size<=rg[i][1] , "Filesize of %s is out of range (%d,%d) %d" % (r.file_id,rg[i][0],rg[i][1],size)
+
self.th_teardown(env)
@@ -442,6 +441,7 @@
results = []
for i in range(len(self.keywords)):
results.append( cat.searchResults( {"keywords":self.keywords[i], "length" : rg[i],"length_usage" : "range:min:max" } ))
+
self.th_teardown(env)
@@ -785,9 +785,9 @@
def main():
- global dataDir
+ global dataDir,maxFiles
- opts,args = getopt.getopt(sys.argv[1:],"hiabn:f:xp",['help'])
+ opts,args = getopt.getopt(sys.argv[1:],"hiabf:xp",['help'])
opts.sort()
optsLst = map(lambda x: x[0],opts)
@@ -796,86 +796,26 @@
for k,v in opts:
if k in ['-h','--help'] : usage(os.path.basename(sys.argv[0])); sys.exit(0)
- if k == "-n": numThreads = string.atoi(v)
if k == "-f": maxFiles = string.atoi(v)
dataDir = os.path.join("data",str(maxFiles))
if '-i' in optsLst:
+ unittest.TextTestRunner().run(get_tests('init'))
- tests = [ BuildEnv("buildTestEnvironment",dataDir,maxFiles) ]
-
- testsuite = unittest.TestSuite()
- for x in tests: testsuite.addTest(x)
-
- runner = unittest.TextTestRunner()
- runner.run(testsuite)
-
- sys.exit(0)
-
if '-b' in optsLst:
+ unittest.TextTestRunner().run(get_tests('bench1'))
- # Chris' tests
- s1 = unittest.makeSuite(TestAddDelIndexes, 'check')
- s2 = unittest.makeSuite(TestCatalogObject, 'check')
- s3 = unittest.makeSuite(TestAddDelColumn, 'check')
- s4 = unittest.makeSuite(TestZCatalogObject, 'check')
-
- testsuite = unittest.TestSuite((s1,s2,s3,s4,))
-
- runner = unittest.TextTestRunner()
- runner.run(testsuite)
-
- # andreas' tests
-
- basic_tests = [
- testSearches("testFulltextIndex",numThreads=1),
- testSearches("testFulltextIndex",numThreads= 4),
- testSearches("testFieldIndex",numThreads= 1),
- testSearches("testFieldIndex",numThreads= 4),
- testSearches("testFieldRangeIndex",numThreads=1),
- testSearches("testFieldRangeIndex",numThreads= 4),
- testSearches("testKeywordIndex",numThreads= 1),
- testSearches("testKeywordIndex",numThreads= 4),
- testSearches("testKeywordRangeIndex",numThreads= 1),
- testSearches("testKeywordRangeIndex",numThreads=4)
- ]
-
- testsuite1 = unittest.TestSuite()
- for x in basic_tests: testsuite1.addTest(x)
-
- runner = unittest.TextTestRunner()
- runner.run(testsuite1)
if '-a' in optsLst:
+ unittest.TextTestRunner().run(get_tests('bench2'))
- basic_tests = [
- testSearches("testReindexing",numThreads=1),
- testSearches("testIncrementalIndexing",numThreads=1),
- testSearches("testUpdates",numThreads=2,numUpdates=200),
- testSearches("testUpdates",numThreads=4,numUpdates=200)
- ]
-
- testsuite1 = TestSuite()
- for x in basic_tests: testsuite1.addTest(x)
-
- runner = TextTestRunner()
- runner.run(testsuite1)
if '-x' in optsLst:
+ unittest.TextTestRunner().run(get_tests('exp'))
- basic_tests = [
-# testSearches("testReindexing",numThreads=1),
-# testSearches("testReindexingAndModify",numThreads=1),
- testSearches("testUpdates",numThreads=10,numUpdates=100),
- ]
-
- testsuite1 = TestSuite()
- for x in basic_tests: testsuite1.addTest(x)
- runner = TextTestRunner()
- runner.run(testsuite1)
if '-p' in optsLst:
unittest.TextTestRunner().run(test_suite())
@@ -886,9 +826,11 @@
def get_tests(what):
+ global dataDir,maxFiles
- maxFiles = 100
- dataDir = 'data/%d' % maxFiles
+ if what=='basic':
+ maxFiles = 100
+ dataDir = 'data/%d' % maxFiles
ts_cm= (
unittest.makeSuite(TestAddDelIndexes, 'check'),
@@ -906,10 +848,47 @@
testSearches("testKeywordRangeIndex",numThreads= 1)
)
+ bench1_tests = (
+ testSearches("testFulltextIndex",numThreads=1),
+ testSearches("testFulltextIndex",numThreads= 4),
+ testSearches("testFieldIndex",numThreads= 1),
+ testSearches("testFieldIndex",numThreads= 4),
+ testSearches("testFieldRangeIndex",numThreads=1),
+ testSearches("testFieldRangeIndex",numThreads= 4),
+ testSearches("testKeywordIndex",numThreads= 1),
+ testSearches("testKeywordIndex",numThreads= 4),
+ testSearches("testKeywordRangeIndex",numThreads= 1),
+ testSearches("testKeywordRangeIndex",numThreads=4)
+ )
+
+ bench2_tests = (
+ testSearches("testReindexing",numThreads=1),
+ testSearches("testIncrementalIndexing",numThreads=1),
+ testSearches("testUpdates",numThreads=2,numUpdates=200),
+ testSearches("testUpdates",numThreads=4,numUpdates=200)
+ )
+
+ exp_tests = (
+# testSearches("testReindexing",numThreads=1),
+# testSearches("testReindexingAndModify",numThreads=1),
+ testSearches("testUpdates",numThreads=10,numUpdates=100),
+ )
+
+ init_tests = (
+ BuildEnv("buildTestEnvironment",dataDir,maxFiles) ,
+ )
+
if what=='basic':
ts = unittest.TestSuite(ts_cm)
for x in t_aj: ts.addTest(x)
return ts
+
+ else:
+ ts = unittest.TestSuite()
+ for x in eval('%s_tests' % what): ts.addTest(x)
+ return ts
+
+ return
--- Updated File testCatalog.py in package Zope2 --
--- testCatalog.py 2001/03/13 14:37:40 1.1.4.6
+++ testCatalog.py 2001/03/13 16:51:07 1.1.4.7
@@ -7,6 +7,9 @@
Andreas Jung, andreas@digicool.com
$Log$
+ Revision 1.1.4.7 2001/03/13 16:51:07 andreas
+ code cleanup
+
Revision 1.1.4.6 2001/03/13 14:37:40 andreas
prelimary version for integration into the Zope testsuites
@@ -206,12 +209,12 @@
l = list(s)
l.reverse()
return string.join(l,"")
-
def __del__(self):
pass
+
class BuildEnv(dispatcher.Dispatcher,unittest.TestCase):
""" build environment """
@@ -404,15 +407,11 @@
rg.append(m,n)
- results = []
- for i in range(searchIterations):
- results.append( cat.searchResults( {"length" : rg[i],"length_usage" : "range:min:max" } ))
-
-
for i in range(searchIterations):
- for r in results[i]:
+ for r in cat.searchResults( {"length" : rg[i],"length_usage" : "range:min:max" } ):
size = r.length
assert rg[i][0]<=size and size<=rg[i][1] , "Filesize of %s is out of range (%d,%d) %d" % (r.file_id,rg[i][0],rg[i][1],size)
+
self.th_teardown(env)
@@ -442,6 +441,7 @@
results = []
for i in range(len(self.keywords)):
results.append( cat.searchResults( {"keywords":self.keywords[i], "length" : rg[i],"length_usage" : "range:min:max" } ))
+
self.th_teardown(env)
@@ -785,9 +785,9 @@
def main():
- global dataDir
+ global dataDir,maxFiles
- opts,args = getopt.getopt(sys.argv[1:],"hiabn:f:xp",['help'])
+ opts,args = getopt.getopt(sys.argv[1:],"hiabf:xp",['help'])
opts.sort()
optsLst = map(lambda x: x[0],opts)
@@ -796,86 +796,26 @@
for k,v in opts:
if k in ['-h','--help'] : usage(os.path.basename(sys.argv[0])); sys.exit(0)
- if k == "-n": numThreads = string.atoi(v)
if k == "-f": maxFiles = string.atoi(v)
dataDir = os.path.join("data",str(maxFiles))
if '-i' in optsLst:
+ unittest.TextTestRunner().run(get_tests('init'))
- tests = [ BuildEnv("buildTestEnvironment",dataDir,maxFiles) ]
-
- testsuite = unittest.TestSuite()
- for x in tests: testsuite.addTest(x)
-
- runner = unittest.TextTestRunner()
- runner.run(testsuite)
-
- sys.exit(0)
-
if '-b' in optsLst:
+ unittest.TextTestRunner().run(get_tests('bench1'))
- # Chris' tests
- s1 = unittest.makeSuite(TestAddDelIndexes, 'check')
- s2 = unittest.makeSuite(TestCatalogObject, 'check')
- s3 = unittest.makeSuite(TestAddDelColumn, 'check')
- s4 = unittest.makeSuite(TestZCatalogObject, 'check')
-
- testsuite = unittest.TestSuite((s1,s2,s3,s4,))
-
- runner = unittest.TextTestRunner()
- runner.run(testsuite)
-
- # andreas' tests
-
- basic_tests = [
- testSearches("testFulltextIndex",numThreads=1),
- testSearches("testFulltextIndex",numThreads= 4),
- testSearches("testFieldIndex",numThreads= 1),
- testSearches("testFieldIndex",numThreads= 4),
- testSearches("testFieldRangeIndex",numThreads=1),
- testSearches("testFieldRangeIndex",numThreads= 4),
- testSearches("testKeywordIndex",numThreads= 1),
- testSearches("testKeywordIndex",numThreads= 4),
- testSearches("testKeywordRangeIndex",numThreads= 1),
- testSearches("testKeywordRangeIndex",numThreads=4)
- ]
-
- testsuite1 = unittest.TestSuite()
- for x in basic_tests: testsuite1.addTest(x)
-
- runner = unittest.TextTestRunner()
- runner.run(testsuite1)
if '-a' in optsLst:
+ unittest.TextTestRunner().run(get_tests('bench2'))
- basic_tests = [
- testSearches("testReindexing",numThreads=1),
- testSearches("testIncrementalIndexing",numThreads=1),
- testSearches("testUpdates",numThreads=2,numUpdates=200),
- testSearches("testUpdates",numThreads=4,numUpdates=200)
- ]
-
- testsuite1 = TestSuite()
- for x in basic_tests: testsuite1.addTest(x)
-
- runner = TextTestRunner()
- runner.run(testsuite1)
if '-x' in optsLst:
+ unittest.TextTestRunner().run(get_tests('exp'))
- basic_tests = [
-# testSearches("testReindexing",numThreads=1),
-# testSearches("testReindexingAndModify",numThreads=1),
- testSearches("testUpdates",numThreads=10,numUpdates=100),
- ]
-
- testsuite1 = TestSuite()
- for x in basic_tests: testsuite1.addTest(x)
- runner = TextTestRunner()
- runner.run(testsuite1)
if '-p' in optsLst:
unittest.TextTestRunner().run(test_suite())
@@ -886,9 +826,11 @@
def get_tests(what):
+ global dataDir,maxFiles
- maxFiles = 100
- dataDir = 'data/%d' % maxFiles
+ if what=='basic':
+ maxFiles = 100
+ dataDir = 'data/%d' % maxFiles
ts_cm= (
unittest.makeSuite(TestAddDelIndexes, 'check'),
@@ -906,10 +848,47 @@
testSearches("testKeywordRangeIndex",numThreads= 1)
)
+ bench1_tests = (
+ testSearches("testFulltextIndex",numThreads=1),
+ testSearches("testFulltextIndex",numThreads= 4),
+ testSearches("testFieldIndex",numThreads= 1),
+ testSearches("testFieldIndex",numThreads= 4),
+ testSearches("testFieldRangeIndex",numThreads=1),
+ testSearches("testFieldRangeIndex",numThreads= 4),
+ testSearches("testKeywordIndex",numThreads= 1),
+ testSearches("testKeywordIndex",numThreads= 4),
+ testSearches("testKeywordRangeIndex",numThreads= 1),
+ testSearches("testKeywordRangeIndex",numThreads=4)
+ )
+
+ bench2_tests = (
+ testSearches("testReindexing",numThreads=1),
+ testSearches("testIncrementalIndexing",numThreads=1),
+ testSearches("testUpdates",numThreads=2,numUpdates=200),
+ testSearches("testUpdates",numThreads=4,numUpdates=200)
+ )
+
+ exp_tests = (
+# testSearches("testReindexing",numThreads=1),
+# testSearches("testReindexingAndModify",numThreads=1),
+ testSearches("testUpdates",numThreads=10,numUpdates=100),
+ )
+
+ init_tests = (
+ BuildEnv("buildTestEnvironment",dataDir,maxFiles) ,
+ )
+
if what=='basic':
ts = unittest.TestSuite(ts_cm)
for x in t_aj: ts.addTest(x)
return ts
+
+ else:
+ ts = unittest.TestSuite()
+ for x in eval('%s_tests' % what): ts.addTest(x)
+ return ts
+
+ return