[Zodb-checkins] CVS: Zope3/src/zodb/zeo/tests - invalid.py:1.4

Tim Peters tim.one at comcast.net
Sat Jun 21 19:04:29 EDT 2003


Update of /cvs-repository/Zope3/src/zodb/zeo/tests
In directory cvs.zope.org:/tmp/cvs-serv8219/src/zodb/zeo/tests

Modified Files:
	invalid.py 
Log Message:
_check_threads():  Trying to get better clues:  Generate a complete
account of the state of the tree when the keys in the tree don't match
what the threads believe they added to the tree.  Unfortunately, this
still happens, at least in testConcurrentUpdatesInVersions().

The first failure I got after making this change revealed a surprise:
the tree consisted of a single bucket!  (This is surprising because
therefore no bucket split was involved -- we're nowhere a bucket
split.)

testConcurrentUpdatesInVersions
  (<class 'zodb.zeo.tests.test_conn.FileStorageConnectionTests'>) ...
OOBTree (0x187e220 oid=0000000000000001) with 1 children
    0 OOBucket (0x19aa470) with 19 keys
        key 0: 1 value 1
        key 1: 2 value 2
        key 2: 3 value 3
        key 3: 7 value 1
        key 4: 8 value 2
        key 5: 9 value 3
        key 6: 13 value 1
        key 7: 14 value 2
        key 8: 15 value 3
        key 9: 19 value 1
        key 10: 20 value 2
        key 11: 21 value 3
        key 12: 25 value 1
        key 13: 26 value 2
        key 14: 27 value 3
        key 15: 31 value 1
        key 16: 37 value 1
        key 17: 43 value 1
        key 18: 49 value 1
AssertionError: expected keys != actual keys
key 32 expected but not in tree

So in that case thread 2 believed it committed an add of key 32
successfully, but it's not actually in the tree.  There were lots of
commit() failures on both sides of it (since keys 28-30 and 33-36
are also missing).


=== Zope3/src/zodb/zeo/tests/invalid.py 1.3 => 1.4 ===
--- Zope3/src/zodb/zeo/tests/invalid.py:1.3	Fri Jun 20 10:14:24 2003
+++ Zope3/src/zodb/zeo/tests/invalid.py	Sat Jun 21 18:04:28 2003
@@ -210,15 +210,26 @@
     def _check_threads(self, tree, *threads):
         # Make sure the thread's view of the world is consistent with
         # the actual database state.
-        all_keys = []
+        expected_keys = []
+        errormsgs = []
+        err = errormsgs.append
         for t in threads:
-            # If the test didn't add any keys, it didn't do what we expected.
-            self.assert_(t.added_keys)
-            for key in t.added_keys:
-                self.assert_(tree.has_key(key), key)
-            all_keys.extend(t.added_keys)
-        all_keys.sort()
-        self.assertEqual(all_keys, list(tree.keys()))
+            if not t.added_keys:
+                err("thread %d didn't add any keys" % t.threadnum)
+            expected_keys.extend(t.added_keys)
+        expected_keys.sort()
+        actual_keys = list(tree.keys())
+        if expected_keys != actual_keys:
+            err("expected keys != actual keys")
+            for k in expected_keys:
+                if k not in actual_keys:
+                    err("key %s expected but not in tree" % k)
+            for k in actual_keys:
+                if k not in expected_keys:
+                    err("key %s in tree but not expected" % k)
+        if errormsgs:
+            display(tree)
+            self.fail('\n'.join(errormsgs))
 
     def go(self, stop, *threads):
         # Run the threads




More information about the Zodb-checkins mailing list