Rev 4666: Add some comments to test_supports_unlimited_cache, as mentioned by Vincent. in http://bazaar.launchpad.net/~jameinel/bzr/2.0-cache-cix
John Arbash Meinel
john at arbash-meinel.com
Fri Oct 9 16:02:28 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/2.0-cache-cix
------------------------------------------------------------
revno: 4666
revision-id: john at arbash-meinel.com-20091009150219-aof5zp3uybrcmi1f
parent: john at arbash-meinel.com-20090909193227-fd07kyduo1ty0d81
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.0-cache-cix
timestamp: Fri 2009-10-09 10:02:19 -0500
message:
Add some comments to test_supports_unlimited_cache, as mentioned by Vincent.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_btree_index.py'
--- a/bzrlib/tests/test_btree_index.py 2009-09-09 19:32:27 +0000
+++ b/bzrlib/tests/test_btree_index.py 2009-10-09 15:02:19 +0000
@@ -1119,6 +1119,8 @@
def test_supports_unlimited_cache(self):
builder = btree_index.BTreeBuilder(reference_lists=0, key_elements=1)
+ # We need enough nodes to cause a page split (so we have both an
+ # internal node and a couple leaf nodes. 500 seems to be enough.)
nodes = self.make_nodes(500, 1, 0)
for node in nodes:
builder.add_node(*node)
@@ -1126,6 +1128,11 @@
trans = get_transport(self.get_url())
size = trans.put_file('index', stream)
index = btree_index.BTreeGraphIndex(trans, 'index', size)
+ self.assertEqual(500, index.key_count())
+ # We have an internal node
+ self.assertEqual(2, len(index._row_lengths))
+ # We have at least 2 leaf nodes
+ self.assertTrue(index._row_lengths[-1] >= 2)
self.assertIsInstance(index._leaf_node_cache, lru_cache.LRUCache)
self.assertEqual(btree_index._NODE_CACHE_SIZE,
index._leaf_node_cache._max_cache)
@@ -1143,7 +1150,9 @@
unlimited_cache=True)
self.assertIsInstance(index._leaf_node_cache, dict)
self.assertIs(type(index._internal_node_cache), dict)
- entries = set(index.iter_entries([nodes[0][1], nodes[300][0]]))
+ # Exercise the lookup code
+ entries = set(index.iter_entries([n[0] for n in nodes]))
+ self.assertEqual(500, len(entries))
class TestBTreeNodes(BTreeTestCase):
More information about the bazaar-commits
mailing list