Mercurial > cpython-lru_cache-weakref
annotate Lib/bsddb/test/test_thread.py @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | 96a241d4a0ab |
| children | 83fd64c97296 |
| 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 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
|
25 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
|
26 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
27 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
|
28 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
29 |
|
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 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
|
33 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
|
34 dbopenflags = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
35 dbsetflags = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
36 envflags = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
37 |
|
59902
96a241d4a0ab
pybsddb 4.8.4 integration. Please, comment in issue #8156
Jesus Cea <jcea@jcea.es>
parents:
58639
diff
changeset
|
38 if sys.version_info < (2, 4) : |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
39 def assertTrue(self, expr, msg=None): |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
40 self.failUnless(expr,msg=msg) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
41 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
42 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
|
43 if verbose: |
|
0c7cb2746d86
Merge with bsddb3 2002.11.23.10.42.36
Martin v. Löwis <martin@v.loewis.de>
parents:
26288
diff
changeset
|
44 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
|
45 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
46 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
|
47 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
|
48 self.setEnvOpts() |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
49 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
|
50 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
57 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
|
58 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
|
59 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
|
60 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
|
61 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
62 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
|
63 pass |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
64 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
65 def makeData(self, key): |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
66 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
|
67 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
68 |
|
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 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
|
73 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
|
74 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
|
75 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
|
76 writers = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
77 records = 1000 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
78 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
79 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
|
80 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
81 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
|
82 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
|
83 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
|
84 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
85 keys=range(self.records) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
86 import random |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
87 random.shuffle(keys) |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
88 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
|
89 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
|
90 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
|
91 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
|
92 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
|
93 readers = [] |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
94 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
95 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
|
96 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
|
97 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
|
98 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
|
99 )#verbose = verbose) |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
100 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
|
101 rt.setDaemon(True) |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
102 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
103 rt.daemon = True |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
104 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
|
105 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
106 writers=[] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
107 for x in xrange(self.writers): |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
108 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
|
109 a.sort() # Generate conflicts |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
110 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
|
111 wt = Thread(target = self.writerThread, |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
112 args = (self.d, a, b), |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
113 name = 'writer %d' % x, |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
114 )#verbose = verbose) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
115 writers.append(wt) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
116 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
117 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
|
118 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
|
119 t.setDaemon(True) |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
120 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
121 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
|
122 t.start() |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
123 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
124 for t in writers: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
125 t.join() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
126 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
|
127 t.join() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
128 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
129 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
|
130 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
|
131 name = currentThread().getName() |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
132 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
133 name = currentThread().name |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
134 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
135 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
136 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
|
137 |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
138 count=len(keys)//len(readers) |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
139 count2=count |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
140 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
|
141 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
|
142 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
|
143 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
|
144 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
|
145 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
|
146 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
147 count2-=1 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
148 if not count2 : |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
149 readers.pop().start() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
150 count2=count |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
151 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
152 if verbose: |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
153 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
|
154 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
155 if verbose: |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
156 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
|
157 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
158 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
|
159 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
|
160 name = currentThread().getName() |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
161 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
162 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
|
163 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
164 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
|
165 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
|
166 count = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
167 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
|
168 while rec: |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
169 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
|
170 key, data = rec |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
171 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
|
172 rec = c.next() |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
173 if verbose: |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
174 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
|
175 c.close() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
176 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
177 if verbose: |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
178 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
|
179 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
180 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
181 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
|
182 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
|
183 writers = 2 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
184 readers = 10 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
185 records = 1000 |
|
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 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
188 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
|
189 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
|
190 writers = 2 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
191 readers = 10 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
192 records = 1000 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
193 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
194 |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
195 #---------------------------------------------------------------------- |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
196 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
197 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
|
198 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
|
199 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
|
200 readers = 10 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
201 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
|
202 records = 1000 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
203 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
204 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
|
205 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
|
206 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
207 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
|
208 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
209 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
|
210 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
|
211 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
212 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
213 keys=range(self.records) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
214 import random |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
215 random.shuffle(keys) |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
216 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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
222 readers = [] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
223 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
|
224 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
|
225 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
|
226 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
|
227 )#verbose = verbose) |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
228 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
|
229 rt.setDaemon(True) |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
230 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
231 rt.daemon = True |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
232 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
|
233 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
234 writers = [] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
235 for x in xrange(self.writers): |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
236 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
|
237 a.sort() # Generate conflicts |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
238 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
|
239 wt = Thread(target = self.writerThread, |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
240 args = (self.d, a, b), |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
241 name = 'writer %d' % x, |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
242 )#verbose = verbose) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
243 writers.append(wt) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
244 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
245 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
|
246 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
|
247 t.setDaemon(True) |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
248 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
249 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
|
250 t.start() |
|
46984
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: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
253 t.join() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
254 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
|
255 t.join() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
256 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
257 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
|
258 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
|
259 name = currentThread().getName() |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
260 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
261 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
|
262 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
263 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
|
264 |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
265 count=len(keys)//len(readers) |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
266 count2=count |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
267 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
|
268 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
|
269 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
|
270 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
|
271 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
272 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
|
273 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
|
274 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
275 count2-=1 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
276 if not count2 : |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
277 readers.pop().start() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
278 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
|
279 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
280 if verbose: |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
281 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
|
282 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
283 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
|
284 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
|
285 name = currentThread().getName() |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
286 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
287 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
|
288 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
289 c = d.cursor() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
290 count = 0 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
291 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
|
292 while rec: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
293 count += 1 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
294 key, data = rec |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
295 self.assertEqual(self.makeData(key), data) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
296 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
|
297 if verbose: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
298 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
|
299 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
|
300 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
301 if verbose: |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
302 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
|
303 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
304 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
305 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
|
306 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
|
307 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
308 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
309 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
|
310 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
|
311 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
312 |
|
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 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
316 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
|
317 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
|
318 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
|
319 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
|
320 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
|
321 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
|
322 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
|
323 ) |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
324 readers = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
325 writers = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
326 records = 2000 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
327 txnFlag = 0 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
328 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
329 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
|
330 #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
|
331 pass |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
332 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
333 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
|
334 if verbose: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
335 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
|
336 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
|
337 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
|
338 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
339 keys=range(self.records) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
340 import random |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
341 random.shuffle(keys) |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
342 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
|
343 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
|
344 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
|
345 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
|
346 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
|
347 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
348 readers=[] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
349 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
|
350 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
|
351 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
|
352 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
|
353 )#verbose = verbose) |
|
48910
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
354 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
|
355 rt.setDaemon(True) |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
356 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
357 rt.daemon = True |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
358 readers.append(rt) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
359 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
360 writers = [] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
361 for x in xrange(self.writers): |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
362 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
|
363 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
|
364 wt = Thread(target = self.writerThread, |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
365 args = (self.d, a, b), |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
366 name = 'writer %d' % x, |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
367 )#verbose = verbose) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
368 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
|
369 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
370 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
|
371 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
|
372 dt.setDaemon(True) |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
373 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
374 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
|
375 dt.start() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
376 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
377 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
|
378 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
|
379 t.setDaemon(True) |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
380 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
381 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
|
382 t.start() |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
383 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
384 for t in writers: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
385 t.join() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
386 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
|
387 t.join() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
388 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
389 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
|
390 dt.join() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
391 |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
392 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
|
393 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
|
394 name = currentThread().getName() |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
395 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
396 name = currentThread().name |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
397 |
|
48054
10f41adc0d24
bsddb module updated to version 4.7.2devel9.
Jesus Cea <jcea@jcea.es>
parents:
46984
diff
changeset
|
398 count=len(keys)//len(readers) |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
399 while len(keys): |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
400 try: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
401 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
|
402 keys2=keys[:count] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
403 for x in keys2 : |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
404 key = '%04d' % x |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
405 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
|
406 if verbose and x % 100 == 0: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
407 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
|
408 txn.commit() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
409 keys=keys[count:] |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
410 readers.pop().start() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
411 except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
412 if verbose: |
|
59902
96a241d4a0ab
pybsddb 4.8.4 integration. Please, comment in issue #8156
Jesus Cea <jcea@jcea.es>
parents:
58639
diff
changeset
|
413 if sys.version_info < (2, 6) : |
|
96a241d4a0ab
pybsddb 4.8.4 integration. Please, comment in issue #8156
Jesus Cea <jcea@jcea.es>
parents:
58639
diff
changeset
|
414 print "%s: Aborting transaction (%s)" % (name, val[1]) |
|
96a241d4a0ab
pybsddb 4.8.4 integration. Please, comment in issue #8156
Jesus Cea <jcea@jcea.es>
parents:
58639
diff
changeset
|
415 else : |
|
96a241d4a0ab
pybsddb 4.8.4 integration. Please, comment in issue #8156
Jesus Cea <jcea@jcea.es>
parents:
58639
diff
changeset
|
416 print "%s: Aborting transaction (%s)" % (name, |
|
96a241d4a0ab
pybsddb 4.8.4 integration. Please, comment in issue #8156
Jesus Cea <jcea@jcea.es>
parents:
58639
diff
changeset
|
417 val.args[1]) |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
418 txn.abort() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
419 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
420 if verbose: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
421 print "%s: thread finished" % name |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
422 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
423 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
|
424 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
|
425 name = currentThread().getName() |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
426 else : |
|
81a1a1545172
Update bsddb code to version 4.7.3pre2. This code should
Jesus Cea <jcea@jcea.es>
parents:
48054
diff
changeset
|
427 name = currentThread().name |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
428 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
429 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
|
430 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
|
431 try: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
432 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
|
433 c = d.cursor(txn) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
434 count = 0 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
435 rec = c.first() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
436 while rec: |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
437 count += 1 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
438 key, data = rec |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
439 self.assertEqual(self.makeData(key), data) |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
440 rec = c.next() |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
441 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
|
442 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
|
443 txn.commit() |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
444 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
|
445 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
|
446 if verbose: |
|
59902
96a241d4a0ab
pybsddb 4.8.4 integration. Please, comment in issue #8156
Jesus Cea <jcea@jcea.es>
parents:
58639
diff
changeset
|
447 if sys.version_info < (2, 6) : |
|
96a241d4a0ab
pybsddb 4.8.4 integration. Please, comment in issue #8156
Jesus Cea <jcea@jcea.es>
parents:
58639
diff
changeset
|
448 print "%s: Aborting transaction (%s)" % (name, val[1]) |
|
96a241d4a0ab
pybsddb 4.8.4 integration. Please, comment in issue #8156
Jesus Cea <jcea@jcea.es>
parents:
58639
diff
changeset
|
449 else : |
|
96a241d4a0ab
pybsddb 4.8.4 integration. Please, comment in issue #8156
Jesus Cea <jcea@jcea.es>
parents:
58639
diff
changeset
|
450 print "%s: Aborting transaction (%s)" % (name, |
|
96a241d4a0ab
pybsddb 4.8.4 integration. Please, comment in issue #8156
Jesus Cea <jcea@jcea.es>
parents:
58639
diff
changeset
|
451 val.args[1]) |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
452 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
|
453 txn.abort() |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
454 |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
455 if verbose: |
|
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
456 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
|
457 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
458 def deadlockThread(self): |
|
27202
ae122675df1e
Cleanups, and conversion of assert to assertEqual()
Barry Warsaw <barry@python.org>
parents:
26878
diff
changeset
|
459 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
|
460 while self.doLockDetect: |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
461 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
|
462 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
|
463 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
|
464 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
|
465 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
|
466 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
|
467 % aborted |
|
26288
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
468 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
|
469 pass |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
470 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
471 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
472 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
|
473 dbtype = db.DB_BTREE |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
474 writers = 2 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
475 readers = 10 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
476 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
|
477 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
478 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
|
479 dbtype = db.DB_HASH |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
480 writers = 2 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
481 readers = 10 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
482 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
|
483 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
484 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
|
485 dbtype = db.DB_BTREE |
|
46984
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
486 writers = 2 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
487 readers = 10 |
|
e4e3b3eba226
Testsuite for bsddb module, version 4.6.4
Jesus Cea <jcea@jcea.es>
parents:
45662
diff
changeset
|
488 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
|
489 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
|
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 HashThreadedNoWaitTransactions(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_HASH |
|
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 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
499 #---------------------------------------------------------------------- |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
500 |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
501 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
|
502 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
|
503 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
504 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
|
505 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
|
506 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
|
507 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
|
508 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
|
509 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
|
510 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
|
511 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
|
512 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
|
513 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
514 else: |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
515 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
|
516 |
|
26878
c249607ef535
Port BerkeleyDB 4.1 support from the pybsddb project. bsddb is now at
Barry Warsaw <barry@python.org>
parents:
26367
diff
changeset
|
517 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
|
518 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
519 |
|
b0b608598170
Importing test suite from bsddb3 3.4.0 (with modifications).
Martin v. Löwis <martin@v.loewis.de>
parents:
diff
changeset
|
520 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
|
521 unittest.main(defaultTest='test_suite') |
