Mercurial > p > roundup > code
diff test/db_test_base.py @ 4448:2784c239e6c8
clear the cache on commit for rdbms backends:
Don't carry over cached values from one transaction to the next (there
may be other changes from other transactions) see new ConcurrentDBTest
for a read-modify-update cycle that fails with the old caching
behavior.
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Fri, 22 Oct 2010 14:14:26 +0000 |
| parents | 67bef70ab9b9 |
| children | 34dce76bb202 |
line wrap: on
line diff
--- a/test/db_test_base.py Thu Oct 21 20:31:13 2010 +0000 +++ b/test/db_test_base.py Fri Oct 22 14:14:26 2010 +0000 @@ -2172,4 +2172,36 @@ except OSError, error: if error.errno not in (errno.ENOENT, errno.ESRCH): raise +class ConcurrentDBTest(ClassicInitTest): + def testConcurrency(self): + # The idea here is a read-modify-update cycle in the presence of + # a cache that has to be properly handled. The same applies if + # we extend a String or otherwise modify something that depends + # on the previous value. + + # set up and open a tracker + tracker = setupTracker(self.dirname, self.backend) + # open the database + self.db = tracker.open('admin') + + prio = '1' + self.assertEqual(self.db.priority.get(prio, 'order'), 1.0) + def inc(db): + db.priority.set(prio, order=db.priority.get(prio, 'order') + 1) + + inc(self.db) + + db2 = tracker.open("admin") + self.assertEqual(db2.priority.get(prio, 'order'), 1.0) + db2.commit() + self.db.commit() + self.assertEqual(self.db.priority.get(prio, 'order'), 2.0) + + inc(db2) + db2.commit() + db2.clearCache() + self.assertEqual(db2.priority.get(prio, 'order'), 3.0) + db2.close() + + # vim: set et sts=4 sw=4 :
