From cce908ec4ae567a93cb54bd605ba8c7d08382249 Mon Sep 17 00:00:00 2001 From: jbj Date: Wed, 6 Nov 2002 16:46:54 +0000 Subject: Upgrade to bsddb3 3.4.2, include db-4.1.17 fiddles. CVS patchset: 5829 CVS date: 2002/11/06 16:46:54 --- python/test/test_dbshelve.py | 8 ++++---- python/test/test_dbtables.py | 35 +++++++++++++++++++++++++++++++++++ python/test/test_thread.py | 21 ++++++++++++--------- 3 files changed, 51 insertions(+), 13 deletions(-) (limited to 'python/test') diff --git a/python/test/test_dbshelve.py b/python/test/test_dbshelve.py index d5b974ac1..7d24813ff 100644 --- a/python/test/test_dbshelve.py +++ b/python/test/test_dbshelve.py @@ -210,7 +210,7 @@ class BTreeShelveTestCase(BasicShelveTestCase): class HashShelveTestCase(BasicShelveTestCase): - dbtype = db.DB_BTREE + dbtype = db.DB_HASH dbflags = db.DB_CREATE @@ -220,7 +220,7 @@ class ThreadBTreeShelveTestCase(BasicShelveTestCase): class ThreadHashShelveTestCase(BasicShelveTestCase): - dbtype = db.DB_BTREE + dbtype = db.DB_HASH dbflags = db.DB_CREATE | db.DB_THREAD @@ -261,7 +261,7 @@ class EnvBTreeShelveTestCase(BasicEnvShelveTestCase): class EnvHashShelveTestCase(BasicEnvShelveTestCase): envflags = 0 - dbtype = db.DB_BTREE + dbtype = db.DB_HASH dbflags = db.DB_CREATE @@ -273,7 +273,7 @@ class EnvThreadBTreeShelveTestCase(BasicEnvShelveTestCase): class EnvThreadHashShelveTestCase(BasicEnvShelveTestCase): envflags = db.DB_THREAD - dbtype = db.DB_BTREE + dbtype = db.DB_HASH dbflags = db.DB_CREATE | db.DB_THREAD diff --git a/python/test/test_dbtables.py b/python/test/test_dbtables.py index 75fc2add7..97b568a20 100644 --- a/python/test/test_dbtables.py +++ b/python/test/test_dbtables.py @@ -5,6 +5,7 @@ #----------------------------------------------------------------------- # # Copyright (C) 2000, 2001 by Autonomous Zone Industries +# Copyright (C) 2002 Gregory P. Smith # # March 20, 2000 # @@ -159,6 +160,40 @@ class TableDBTestCase(unittest.TestCase): assert values[0]['b'] == "bad" + def test04_MultiCondSelect(self): + tabname = "test04_MultiCondSelect" + try: + self.tdb.Drop(tabname) + except dbtables.TableDBError: + pass + self.tdb.CreateTable(tabname, ['a', 'b', 'c', 'd', 'e']) + + try: + self.tdb.Insert(tabname, {'a': "", 'e': pickle.dumps([{4:5, 6:7}, 'foo'], 1), 'f': "Zero"}) + assert 0 + except dbtables.TableDBError: + pass + + self.tdb.Insert(tabname, {'a': "A", 'b': "B", 'c': "C", 'd': "D", 'e': "E"}) + self.tdb.Insert(tabname, {'a': "-A", 'b': "-B", 'c': "-C", 'd': "-D", 'e': "-E"}) + self.tdb.Insert(tabname, {'a': "A-", 'b': "B-", 'c': "C-", 'd': "D-", 'e': "E-"}) + + if verbose: + self.tdb._db_print() + + # This select should return 0 rows. it is designed to test + # the bug identified and fixed in sourceforge bug # 590449 + # (Big Thanks to "Rob Tillotson (n9mtb)" for tracking this down + # and supplying a fix!! This one caused many headaches to say + # the least...) + values = self.tdb.Select(tabname, ['b', 'a', 'd'], + conditions={'e': dbtables.ExactCond('E'), + 'a': dbtables.ExactCond('A'), + 'd': dbtables.PrefixCond('-') + } ) + assert len(values) == 0, values + + def test_CreateOrExtend(self): tabname = "test_CreateOrExtend" diff --git a/python/test/test_thread.py b/python/test/test_thread.py index f8722e27d..13fd46b61 100644 --- a/python/test/test_thread.py +++ b/python/test/test_thread.py @@ -18,7 +18,7 @@ except ImportError: import unittest from test_all import verbose -from rpmdb import db +from rpmdb import db, dbutils #---------------------------------------------------------------------- @@ -31,6 +31,9 @@ class BaseThreadedTestCase(unittest.TestCase): def setUp(self): + if verbose: + dbutils._deadlock_VerboseFile = sys.stdout + homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home') self.homeDir = homeDir try: os.mkdir(homeDir) @@ -109,7 +112,7 @@ class ConcurrentDataStoreBase(BaseThreadedTestCase): for x in range(start, stop): key = '%04d' % x - d.put(key, self.makeData(key)) + dbutils.DeadlockWrap(d.put, key, self.makeData(key), max_retries=12) if verbose and x % 100 == 0: print "%s: records %d - %d finished" % (name, start, x) @@ -212,7 +215,7 @@ class SimpleThreadedBase(BaseThreadedTestCase): # create a bunch of records for x in xrange(start, stop): key = '%04d' % x - d.put(key, self.makeData(key)) + dbutils.DeadlockWrap(d.put, key, self.makeData(key), max_retries=12) if verbose and x % 100 == 0: print "%s: records %d - %d finished" % (name, start, x) @@ -221,12 +224,12 @@ class SimpleThreadedBase(BaseThreadedTestCase): if random() <= 0.05: for y in xrange(start, x): key = '%04d' % x - data = d.get(key) + data = dbutils.DeadlockWrap(d.get, key, max_retries=12) assert data == self.makeData(key) # flush them try: - d.sync() + dbutils.DeadlockWrap(d.sync, max_retries=12) except db.DBIncompleteError, val: if verbose: print "could not complete sync()..." @@ -234,12 +237,12 @@ class SimpleThreadedBase(BaseThreadedTestCase): # read them back, deleting a few for x in xrange(start, stop): key = '%04d' % x - data = d.get(key) + data = dbutils.DeadlockWrap(d.get, key, max_retries=12) if verbose and x % 100 == 0: print "%s: fetched record (%s, %s)" % (name, key, data) - assert data == self.makeData(key) + assert data == self.makeData(key), (key, data, self.makeData(key)) if random() <= 0.10: - d.delete(key) + dbutils.DeadlockWrap(d.delete, key, max_retries=12) if verbose: print "%s: deleted record %s" % (name, key) @@ -273,7 +276,7 @@ class BTreeSimpleThreaded(SimpleThreadedBase): class HashSimpleThreaded(SimpleThreadedBase): - dbtype = db.DB_BTREE + dbtype = db.DB_HASH #---------------------------------------------------------------------- -- cgit v1.2.3