Mercurial > cpython-lru_cache-weakref
annotate Lib/bsddb/test/test_thread.py @ 54294:dba767bc3155 legacy-trunk
remove mention of old ctypes version
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Sat, 23 May 2009 20:59:09 +0000 |
| parents | 81a1a1545172 |
| children | d051779c5bbd |
| rev | line source |
|---|---|
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
1 """TestCases for multi-threaded access to a DB. |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
2 """ |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
3 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
4 import os |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
5 import sys |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
6 import time |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
7 import errno |
|
33037
233c223858f7
Purged Berkeley code of references to the long-obsolete whrandom.
Tim Peters <tim.peters@gmail.com>
parents:
30475
diff
changeset
|
8 from random import random |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
9 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
10 DASH = '-' |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
11 |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
12 try: |
|
38126
90dd57fcd24e
Handle ERROR_ALREADY_EXISTS.
Martin v. Löwis <martin@v.loewis.de>
parents:
33037
diff
changeset
|
13 WindowsError |
|
90dd57fcd24e
Handle ERROR_ALREADY_EXISTS.
Martin v. Löwis <martin@v.loewis.de>
parents:
33037
diff
changeset
|
14 except NameError: |
|
90dd57fcd24e
Handle ERROR_ALREADY_EXISTS.
Martin v. Löwis <martin@v.loewis.de>
parents:
33037
diff
changeset
|
15 class WindowsError(Exception): |
|
90dd57fcd24e
Handle ERROR_ALREADY_EXISTS.
Martin v. Löwis <martin@v.loewis.de>
parents:
33037
diff
changeset
|
16 pass |
|
90dd57fcd24e
Handle ERROR_ALREADY_EXISTS.
Martin v. Löwis <martin@v.loewis.de>
parents:
33037
diff
changeset
|
17 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
18 import unittest |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
19 from test_all import db, dbutils, test_support, verbose, have_threads, \ |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
20 get_new_environment_path, get_new_database_path |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
21 |
|
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
22 if have_threads : |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
23 from threading import Thread |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
24 import sys |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
25 if sys.version_info[0] < 3 : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
26 from threading import currentThread |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
27 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
28 from threading import current_thread as currentThread |
|
45617
5ccb6eb202ff
Modify import of test_support so that the code can also be used with a
Gregory P. Smith <greg@mad-scientist.com>
parents:
45506
diff
changeset
|
29 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
30 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
31 #---------------------------------------------------------------------- |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
32 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
33 class BaseThreadedTestCase(unittest.TestCase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
34 dbtype = db.DB_UNKNOWN # must be set in derived class |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
35 dbopenflags = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
36 dbsetflags = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
37 envflags = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
38 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
39 import sys |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
40 if sys.version_info[:3] < (2, 4, 0): |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
41 def assertTrue(self, expr, msg=None): |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
42 self.failUnless(expr,msg=msg) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
43 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
44 def setUp(self): |
|
26367
0c7cb2746d86
Merge with bsddb3 2002.11.23.10.42.36
Martin v. Löwis <martin@v.loewis.de>
parents:
26288
diff
changeset
|
45 if verbose: |
|
0c7cb2746d86
Merge with bsddb3 2002.11.23.10.42.36
Martin v. Löwis <martin@v.loewis.de>
parents:
26288
diff
changeset
|
46 dbutils._deadlock_VerboseFile = sys.stdout |
|
0c7cb2746d86
Merge with bsddb3 2002.11.23.10.42.36
Martin v. Löwis <martin@v.loewis.de>
parents:
26288
diff
changeset
|
47 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
48 self.homeDir = get_new_environment_path() |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
49 self.env = db.DBEnv() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
50 self.setEnvOpts() |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
51 self.env.open(self.homeDir, self.envflags | db.DB_CREATE) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
52 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
53 self.filename = self.__class__.__name__ + '.db' |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
54 self.d = db.DB(self.env) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
55 if self.dbsetflags: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
56 self.d.set_flags(self.dbsetflags) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
57 self.d.open(self.filename, self.dbtype, self.dbopenflags|db.DB_CREATE) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
58 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
59 def tearDown(self): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
60 self.d.close() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
61 self.env.close() |
|
45662
30fa6777096f
Remove the files/dirs after closing the DB so the tests work on Windows.
Neal Norwitz <nnorwitz@gmail.com>
parents:
45617
diff
changeset
|
62 test_support.rmtree(self.homeDir) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
63 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
64 def setEnvOpts(self): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
65 pass |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
66 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
67 def makeData(self, key): |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
68 return DASH.join([key] * 5) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
69 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
70 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
71 #---------------------------------------------------------------------- |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
72 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
73 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
74 class ConcurrentDataStoreBase(BaseThreadedTestCase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
75 dbopenflags = db.DB_THREAD |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
76 envflags = db.DB_THREAD | db.DB_INIT_CDB | db.DB_INIT_MPOOL |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
77 readers = 0 # derived class should set |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
78 writers = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
79 records = 1000 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
80 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
81 def test01_1WriterMultiReaders(self): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
82 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
83 print '\n', '-=' * 30 |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
84 print "Running %s.test01_1WriterMultiReaders..." % \ |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
85 self.__class__.__name__ |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
86 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
87 keys=range(self.records) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
88 import random |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
89 random.shuffle(keys) |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
90 records_per_writer=self.records//self.writers |
|
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
91 readers_per_writer=self.readers//self.writers |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
92 self.assertEqual(self.records,self.writers*records_per_writer) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
93 self.assertEqual(self.readers,self.writers*readers_per_writer) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
94 self.assertTrue((records_per_writer%readers_per_writer)==0) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
95 readers = [] |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
96 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
97 for x in xrange(self.readers): |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
98 rt = Thread(target = self.readerThread, |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
99 args = (self.d, x), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
100 name = 'reader %d' % x, |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
101 )#verbose = verbose) |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
102 import sys |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
103 if sys.version_info[0] < 3 : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
104 rt.setDaemon(True) |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
105 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
106 rt.daemon = True |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
107 readers.append(rt) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
108 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
109 writers=[] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
110 for x in xrange(self.writers): |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
111 a=keys[records_per_writer*x:records_per_writer*(x+1)] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
112 a.sort() # Generate conflicts |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
113 b=readers[readers_per_writer*x:readers_per_writer*(x+1)] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
114 wt = Thread(target = self.writerThread, |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
115 args = (self.d, a, b), |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
116 name = 'writer %d' % x, |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
117 )#verbose = verbose) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
118 writers.append(wt) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
119 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
120 for t in writers: |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
121 import sys |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
122 if sys.version_info[0] < 3 : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
123 t.setDaemon(True) |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
124 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
125 t.daemon = True |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
126 t.start() |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
127 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
128 for t in writers: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
129 t.join() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
130 for t in readers: |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
131 t.join() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
132 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
133 def writerThread(self, d, keys, readers): |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
134 import sys |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
135 if sys.version_info[0] < 3 : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
136 name = currentThread().getName() |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
137 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
138 name = currentThread().name |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
139 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
140 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
141 print "%s: creating records %d - %d" % (name, start, stop) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
142 |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
143 count=len(keys)//len(readers) |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
144 count2=count |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
145 for x in keys : |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
146 key = '%04d' % x |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
147 dbutils.DeadlockWrap(d.put, key, self.makeData(key), |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
148 max_retries=12) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
149 if verbose and x % 100 == 0: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
150 print "%s: records %d - %d finished" % (name, start, x) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
151 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
152 count2-=1 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
153 if not count2 : |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
154 readers.pop().start() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
155 count2=count |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
156 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
157 if verbose: |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
158 print "%s: finished creating records" % name |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
159 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
160 if verbose: |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
161 print "%s: thread finished" % name |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
162 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
163 def readerThread(self, d, readerNum): |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
164 import sys |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
165 if sys.version_info[0] < 3 : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
166 name = currentThread().getName() |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
167 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
168 name = currentThread().name |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
169 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
170 for i in xrange(5) : |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
171 c = d.cursor() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
172 count = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
173 rec = c.first() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
174 while rec: |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
175 count += 1 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
176 key, data = rec |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
177 self.assertEqual(self.makeData(key), data) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
178 rec = c.next() |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
179 if verbose: |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
180 print "%s: found %d records" % (name, count) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
181 c.close() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
182 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
183 if verbose: |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
184 print "%s: thread finished" % name |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
185 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
186 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
187 class BTreeConcurrentDataStore(ConcurrentDataStoreBase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
188 dbtype = db.DB_BTREE |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
189 writers = 2 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
190 readers = 10 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
191 records = 1000 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
192 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
193 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
194 class HashConcurrentDataStore(ConcurrentDataStoreBase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
195 dbtype = db.DB_HASH |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
196 writers = 2 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
197 readers = 10 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
198 records = 1000 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
199 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
200 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
201 #---------------------------------------------------------------------- |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
202 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
203 class SimpleThreadedBase(BaseThreadedTestCase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
204 dbopenflags = db.DB_THREAD |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
205 envflags = db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
206 readers = 10 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
207 writers = 2 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
208 records = 1000 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
209 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
210 def setEnvOpts(self): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
211 self.env.set_lk_detect(db.DB_LOCK_DEFAULT) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
212 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
213 def test02_SimpleLocks(self): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
214 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
215 print '\n', '-=' * 30 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
216 print "Running %s.test02_SimpleLocks..." % self.__class__.__name__ |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
217 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
218 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
219 keys=range(self.records) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
220 import random |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
221 random.shuffle(keys) |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
222 records_per_writer=self.records//self.writers |
|
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
223 readers_per_writer=self.readers//self.writers |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
224 self.assertEqual(self.records,self.writers*records_per_writer) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
225 self.assertEqual(self.readers,self.writers*readers_per_writer) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
226 self.assertTrue((records_per_writer%readers_per_writer)==0) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
227 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
228 readers = [] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
229 for x in xrange(self.readers): |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
230 rt = Thread(target = self.readerThread, |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
231 args = (self.d, x), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
232 name = 'reader %d' % x, |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
233 )#verbose = verbose) |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
234 import sys |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
235 if sys.version_info[0] < 3 : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
236 rt.setDaemon(True) |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
237 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
238 rt.daemon = True |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
239 readers.append(rt) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
240 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
241 writers = [] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
242 for x in xrange(self.writers): |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
243 a=keys[records_per_writer*x:records_per_writer*(x+1)] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
244 a.sort() # Generate conflicts |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
245 b=readers[readers_per_writer*x:readers_per_writer*(x+1)] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
246 wt = Thread(target = self.writerThread, |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
247 args = (self.d, a, b), |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
248 name = 'writer %d' % x, |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
249 )#verbose = verbose) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
250 writers.append(wt) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
251 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
252 for t in writers: |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
253 import sys |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
254 if sys.version_info[0] < 3 : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
255 t.setDaemon(True) |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
256 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
257 t.daemon = True |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
258 t.start() |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
259 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
260 for t in writers: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
261 t.join() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
262 for t in readers: |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
263 t.join() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
264 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
265 def writerThread(self, d, keys, readers): |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
266 import sys |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
267 if sys.version_info[0] < 3 : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
268 name = currentThread().getName() |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
269 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
270 name = currentThread().name |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
271 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
272 print "%s: creating records %d - %d" % (name, start, stop) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
273 |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
274 count=len(keys)//len(readers) |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
275 count2=count |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
276 for x in keys : |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
277 key = '%04d' % x |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
278 dbutils.DeadlockWrap(d.put, key, self.makeData(key), |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
279 max_retries=12) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
280 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
281 if verbose and x % 100 == 0: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
282 print "%s: records %d - %d finished" % (name, start, x) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
283 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
284 count2-=1 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
285 if not count2 : |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
286 readers.pop().start() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
287 count2=count |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
288 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
289 if verbose: |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
290 print "%s: thread finished" % name |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
291 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
292 def readerThread(self, d, readerNum): |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
293 import sys |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
294 if sys.version_info[0] < 3 : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
295 name = currentThread().getName() |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
296 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
297 name = currentThread().name |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
298 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
299 c = d.cursor() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
300 count = 0 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
301 rec = dbutils.DeadlockWrap(c.first, max_retries=10) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
302 while rec: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
303 count += 1 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
304 key, data = rec |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
305 self.assertEqual(self.makeData(key), data) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
306 rec = dbutils.DeadlockWrap(c.next, max_retries=10) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
307 if verbose: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
308 print "%s: found %d records" % (name, count) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
309 c.close() |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
310 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
311 if verbose: |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
312 print "%s: thread finished" % name |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
313 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
314 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
315 class BTreeSimpleThreaded(SimpleThreadedBase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
316 dbtype = db.DB_BTREE |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
317 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
318 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
319 class HashSimpleThreaded(SimpleThreadedBase): |
|
26367
0c7cb2746d86
Merge with bsddb3 2002.11.23.10.42.36
Martin v. Löwis <martin@v.loewis.de>
parents:
26288
diff
changeset
|
320 dbtype = db.DB_HASH |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
321 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
322 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
323 #---------------------------------------------------------------------- |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
324 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
325 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
326 class ThreadedTransactionsBase(BaseThreadedTestCase): |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
327 dbopenflags = db.DB_THREAD | db.DB_AUTO_COMMIT |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
328 envflags = (db.DB_THREAD | |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
329 db.DB_INIT_MPOOL | |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
330 db.DB_INIT_LOCK | |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
331 db.DB_INIT_LOG | |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
332 db.DB_INIT_TXN |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
333 ) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
334 readers = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
335 writers = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
336 records = 2000 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
337 txnFlag = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
338 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
339 def setEnvOpts(self): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
340 #self.env.set_lk_detect(db.DB_LOCK_DEFAULT) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
341 pass |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
342 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
343 def test03_ThreadedTransactions(self): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
344 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
345 print '\n', '-=' * 30 |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
346 print "Running %s.test03_ThreadedTransactions..." % \ |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
347 self.__class__.__name__ |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
348 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
349 keys=range(self.records) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
350 import random |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
351 random.shuffle(keys) |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
352 records_per_writer=self.records//self.writers |
|
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
353 readers_per_writer=self.readers//self.writers |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
354 self.assertEqual(self.records,self.writers*records_per_writer) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
355 self.assertEqual(self.readers,self.writers*readers_per_writer) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
356 self.assertTrue((records_per_writer%readers_per_writer)==0) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
357 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
358 readers=[] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
359 for x in xrange(self.readers): |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
360 rt = Thread(target = self.readerThread, |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
361 args = (self.d, x), |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
362 name = 'reader %d' % x, |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
363 )#verbose = verbose) |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
364 import sys |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
365 if sys.version_info[0] < 3 : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
366 rt.setDaemon(True) |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
367 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
368 rt.daemon = True |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
369 readers.append(rt) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
370 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
371 writers = [] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
372 for x in xrange(self.writers): |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
373 a=keys[records_per_writer*x:records_per_writer*(x+1)] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
374 b=readers[readers_per_writer*x:readers_per_writer*(x+1)] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
375 wt = Thread(target = self.writerThread, |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
376 args = (self.d, a, b), |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
377 name = 'writer %d' % x, |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
378 )#verbose = verbose) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
379 writers.append(wt) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
380 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
381 dt = Thread(target = self.deadlockThread) |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
382 import sys |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
383 if sys.version_info[0] < 3 : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
384 dt.setDaemon(True) |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
385 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
386 dt.daemon = True |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
387 dt.start() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
388 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
389 for t in writers: |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
390 import sys |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
391 if sys.version_info[0] < 3 : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
392 t.setDaemon(True) |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
393 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
394 t.daemon = True |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
395 t.start() |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
396 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
397 for t in writers: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
398 t.join() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
399 for t in readers: |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
400 t.join() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
401 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
402 self.doLockDetect = False |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
403 dt.join() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
404 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
405 def writerThread(self, d, keys, readers): |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
406 import sys |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
407 if sys.version_info[0] < 3 : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
408 name = currentThread().getName() |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
409 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
410 name = currentThread().name |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
411 |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
412 count=len(keys)//len(readers) |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
413 while len(keys): |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
414 try: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
415 txn = self.env.txn_begin(None, self.txnFlag) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
416 keys2=keys[:count] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
417 for x in keys2 : |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
418 key = '%04d' % x |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
419 d.put(key, self.makeData(key), txn) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
420 if verbose and x % 100 == 0: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
421 print "%s: records %d - %d finished" % (name, start, x) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
422 txn.commit() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
423 keys=keys[count:] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
424 readers.pop().start() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
425 except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
426 if verbose: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
427 print "%s: Aborting transaction (%s)" % (name, val[1]) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
428 txn.abort() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
429 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
430 if verbose: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
431 print "%s: thread finished" % name |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
432 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
433 def readerThread(self, d, readerNum): |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
434 import sys |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
435 if sys.version_info[0] < 3 : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
436 name = currentThread().getName() |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
437 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
438 name = currentThread().name |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
439 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
440 finished = False |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
441 while not finished: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
442 try: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
443 txn = self.env.txn_begin(None, self.txnFlag) |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
444 c = d.cursor(txn) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
445 count = 0 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
446 rec = c.first() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
447 while rec: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
448 count += 1 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
449 key, data = rec |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
450 self.assertEqual(self.makeData(key), data) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
451 rec = c.next() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
452 if verbose: print "%s: found %d records" % (name, count) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
453 c.close() |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
454 txn.commit() |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
455 finished = True |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
456 except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
457 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
458 print "%s: Aborting transaction (%s)" % (name, val[1]) |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
459 c.close() |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
460 txn.abort() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
461 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
462 if verbose: |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
463 print "%s: thread finished" % name |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
464 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
465 def deadlockThread(self): |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
466 self.doLockDetect = True |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
467 while self.doLockDetect: |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
468 time.sleep(0.05) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
469 try: |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
470 aborted = self.env.lock_detect( |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
471 db.DB_LOCK_RANDOM, db.DB_LOCK_CONFLICT) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
472 if verbose and aborted: |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
473 print "deadlock: Aborted %d deadlocked transaction(s)" \ |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
474 % aborted |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
475 except db.DBError: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
476 pass |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
477 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
478 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
479 class BTreeThreadedTransactions(ThreadedTransactionsBase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
480 dbtype = db.DB_BTREE |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
481 writers = 2 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
482 readers = 10 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
483 records = 1000 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
484 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
485 class HashThreadedTransactions(ThreadedTransactionsBase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
486 dbtype = db.DB_HASH |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
487 writers = 2 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
488 readers = 10 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
489 records = 1000 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
490 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
491 class BTreeThreadedNoWaitTransactions(ThreadedTransactionsBase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
492 dbtype = db.DB_BTREE |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
493 writers = 2 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
494 readers = 10 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
495 records = 1000 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
496 txnFlag = db.DB_TXN_NOWAIT |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
497 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
498 class HashThreadedNoWaitTransactions(ThreadedTransactionsBase): |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
499 dbtype = db.DB_HASH |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
500 writers = 2 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
501 readers = 10 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
502 records = 1000 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
503 txnFlag = db.DB_TXN_NOWAIT |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
504 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
505 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
506 #---------------------------------------------------------------------- |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
507 |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
508 def test_suite(): |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
509 suite = unittest.TestSuite() |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
510 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
511 if have_threads: |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
512 suite.addTest(unittest.makeSuite(BTreeConcurrentDataStore)) |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
513 suite.addTest(unittest.makeSuite(HashConcurrentDataStore)) |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
514 suite.addTest(unittest.makeSuite(BTreeSimpleThreaded)) |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
515 suite.addTest(unittest.makeSuite(HashSimpleThreaded)) |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
516 suite.addTest(unittest.makeSuite(BTreeThreadedTransactions)) |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
517 suite.addTest(unittest.makeSuite(HashThreadedTransactions)) |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
518 suite.addTest(unittest.makeSuite(BTreeThreadedNoWaitTransactions)) |
|
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
519 suite.addTest(unittest.makeSuite(HashThreadedNoWaitTransactions)) |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
520 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
521 else: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
522 print "Threads not available, skipping thread tests." |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
523 |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
524 return suite |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
525 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
526 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
527 if __name__ == '__main__': |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
528 unittest.main(defaultTest='test_suite') |
