Rev 4442: Add a fairly broken test for StreamSource working to send data to RemoteRepo. in http://bazaar.launchpad.net/~jameinel/bzr/1.17-bug387294

John Arbash Meinel john at arbash-meinel.com
Mon Jun 15 18:18:16 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/1.17-bug387294

------------------------------------------------------------
revno: 4442
revision-id: john at arbash-meinel.com-20090615171757-eeajjvgdruabc5mu
parent: john at arbash-meinel.com-20090615171011-u7uruzpm6go01dmf
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.17-bug387294
timestamp: Mon 2009-06-15 12:17:57 -0500
message:
  Add a fairly broken test for StreamSource working to send data to RemoteRepo.
  
  It turns out we have 3 bugs.
  1) (already known) Knit formats don't work, because they try to lock the target again.
  2) RemoteRepositoryFormat has a bogus value for 'supports_chks'. This causes the code
  that is determining how to transmit inventories to get confused. (In these tests the
  two formats are identical, we just don't realize that...)
  3) The StreamSink code uses 'from_serializer == to_serializer' to determine if it
  needs to cast the fulltexts back up to Inventory objects or not. However, because
  of (2) we would have sent a full text inventory, but Sink would think we did not...
  4) Latent bug... supports_chk isn't quite enough detail given serializer
  issues. However, it is sufficient for all current formats, so we'll live with
  it.
-------------- next part --------------
=== modified file 'bzrlib/tests/per_repository/test_stream_source.py'
--- a/bzrlib/tests/per_repository/test_stream_source.py	2009-06-15 16:11:27 +0000
+++ b/bzrlib/tests/per_repository/test_stream_source.py	2009-06-15 17:17:57 +0000
@@ -18,8 +18,10 @@
 """Tests for the generic StreamSource class."""
 
 from bzrlib import (
+    errors,
     graph,
     repository,
+    tests,
     )
 from bzrlib.tests.per_repository import TestCaseWithRepository
 
@@ -61,3 +63,30 @@
         self.assertEqualDiff('content\n', rt_a.get_file_text('file-id'))
         rt_b = target.revision_tree('B-id')
         self.assertEqualDiff('new-content\n', rt_b.get_file_text('file-id'))
+
+    def test_fetch_to_smart_server(self):
+        source_b = self.make_simple_history()
+        target_trans = self.make_smart_server('target')
+        # Make it normally, but open it through the smart server
+        self.make_repository('target')
+        target = repository.Repository.open(target_trans.base)
+        target.lock_write()
+        self.addCleanup(target.unlock)
+        stream_source = repository.StreamSource(source_b.repository,
+                                                target._format)
+        search = graph.PendingAncestryResult(['B-id'], source_b.repository)
+        stream = stream_source.get_stream(search)
+        sink = target._get_sink()
+        try:
+            sink.insert_stream(stream, source_b.repository._format, [])
+        except errors.TokenLockingNotSupported:
+            # The code inside fetch() that tries to lock and then fails, also
+            # causes weird problems with 'lock_not_held' later on...
+            target.lock_read()
+            raise tests.KnownFailure('some repositories fail to fetch'
+                ' via the smart server because of locking issues.')
+        # Now that it has been inserted, check it
+        rt_a = target.revision_tree('A-id')
+        self.assertEqualDiff('content\n', rt_a.get_file_text('file-id'))
+        rt_b = target.revision_tree('B-id')
+        self.assertEqualDiff('new-content\n', rt_b.get_file_text('file-id'))



More information about the bazaar-commits mailing list