Rev 4153: Add specific tests for fetch streaming in the bzr protocol client. in http://people.ubuntu.com/~robertc/baz2.0/pending/branch.stacked.streams
Robert Collins
robertc at robertcollins.net
Tue Mar 17 03:02:38 GMT 2009
At http://people.ubuntu.com/~robertc/baz2.0/pending/branch.stacked.streams
------------------------------------------------------------
revno: 4153
revision-id: robertc at robertcollins.net-20090317030232-y7nhlxwe1i1q3xec
parent: pqm at pqm.ubuntu.com-20090317005047-1qd1zwlgpc5y8t1i
committer: Robert Collins <robertc at robertcollins.net>
branch nick: branch.stacked.streams
timestamp: Tue 2009-03-17 14:02:32 +1100
message:
Add specific tests for fetch streaming in the bzr protocol client.
=== modified file 'bzrlib/tests/test_remote.py'
--- a/bzrlib/tests/test_remote.py 2009-03-16 08:26:29 +0000
+++ b/bzrlib/tests/test_remote.py 2009-03-17 03:02:32 +0000
@@ -2222,13 +2222,13 @@
# revision, then open it over hpss - we should be able to see that
# revision.
base_transport = self.get_transport()
- base_builder = self.make_branch_builder('base', format='1.6')
+ base_builder = self.make_branch_builder('base', format='1.9')
base_builder.start_series()
base_revid = base_builder.build_snapshot('rev-id', None,
[('add', ('', None, 'directory', None))],
'message')
base_builder.finish_series()
- stacked_branch = self.make_branch('stacked', format='1.6')
+ stacked_branch = self.make_branch('stacked', format='1.9')
stacked_branch.set_stacked_on_url('../base')
# start a server looking at this
smart_server = server.SmartTCPServer_for_testing()
@@ -2255,30 +2255,90 @@
remote_repo.unlock()
def prepare_stacked_remote_branch(self):
+ """Get stacked_upon and stacked branches with content in each."""
smart_server = server.SmartTCPServer_for_testing()
smart_server.setUp()
self.addCleanup(smart_server.tearDown)
- tree1 = self.make_branch_and_tree('tree1')
+ tree1 = self.make_branch_and_tree('tree1', format='1.9')
tree1.commit('rev1', rev_id='rev1')
- tree2 = self.make_branch_and_tree('tree2', format='1.6')
- tree2.branch.set_stacked_on_url(tree1.branch.base)
+ tree2 = tree1.branch.bzrdir.sprout('tree2', stacked=True
+ ).open_workingtree()
+ tree2.commit('local changes make me feel good.')
branch2 = Branch.open(smart_server.get_url() + '/tree2')
branch2.lock_read()
self.addCleanup(branch2.unlock)
- return branch2
+ return tree1.branch, branch2
def test_stacked_get_parent_map(self):
# the public implementation of get_parent_map obeys stacking
- branch = self.prepare_stacked_remote_branch()
+ _, branch = self.prepare_stacked_remote_branch()
repo = branch.repository
self.assertEqual(['rev1'], repo.get_parent_map(['rev1']).keys())
def test_unstacked_get_parent_map(self):
# _unstacked_provider.get_parent_map ignores stacking
- branch = self.prepare_stacked_remote_branch()
+ _, branch = self.prepare_stacked_remote_branch()
provider = branch.repository._unstacked_provider
self.assertEqual([], provider.get_parent_map(['rev1']).keys())
+ def fetch_stream_to_rev_order(self, stream):
+ result = []
+ for kind, substream in stream:
+ if not kind == 'revisions':
+ list(substream)
+ else:
+ for content in substream:
+ result.append(content.key[-1])
+ return result
+
+ def get_ordered_revs(self, format, order):
+ """Get a list of the revisions in a stream to format format.
+
+ :param format: The format of the target.
+ :param order: the order that target should have requested.
+ :result: The revision ids in the stream, in the order seen,
+ the topological order of revisions in the source.
+ """
+ unordered_format = bzrdir.format_registry.get(format)()
+ target_repository_format = unordered_format.repository_format
+ # Cross check
+ self.assertEqual(order, target_repository_format._fetch_order)
+ trunk, stacked = self.prepare_stacked_remote_branch()
+ source = stacked.repository._get_source(target_repository_format)
+ tip = stacked.last_revision()
+ revs = stacked.repository.get_ancestry(tip)
+ search = graph.PendingAncestryResult([tip], stacked.repository)
+ stream = source.get_stream(search)
+ if None in revs:
+ revs.remove(None)
+ # We trust that if a revision is in the stream the rest of the new
+ # content for it is too, as per our main fetch tests; here we are
+ # checking that the revisions are actually included at all, and their
+ # order.
+ return self.fetch_stream_to_rev_order(stream), revs
+
+ def test_stacked_get_stream_unordered(self):
+ # Repository._get_source.get_stream() from a stacked repository with
+ # unordered yields the full data from both stacked and stacked upon
+ # sources.
+ rev_ord, expected_revs = self.get_ordered_revs('1.9', 'unordered')
+ self.assertEqual(set(rev_ord), set(expected_revs))
+
+ def test_stacked_get_stream_topological(self):
+ # Repository._get_source.get_stream() from a stacked repository with
+ # topological sorting yields the full data from both stacked and
+ # stacked upon sources in topological order.
+ rev_ord, expected_revs = self.get_ordered_revs('knit', 'topological')
+ self.assertEqual(rev_ord, expected_revs)
+
+ def test_stacked_get_stream_groupcompress(self):
+ # Repository._get_source.get_stream() from a stacked repository with
+ # groupcompress sorting yields the full data from both stacked and
+ # stacked upon sources in groupcompress order.
+ raise tests.TestSkipped('No groupcompress ordered format available')
+ rev_ord, expected_revs = self.get_ordered_revs('dev5', 'groupcompress')
+ self.assertEqual(reversed(rev_ord), expected_revs)
+
class TestRemoteBranchEffort(tests.TestCaseWithTransport):
More information about the bazaar-commits
mailing list