Rev 4018: Add BzrDirFormatMeta1 test for the amount of rpc calls made initializing over the network. in http://people.ubuntu.com/~robertc/baz2.0/push.roundtrips

Robert Collins robertc at robertcollins.net
Thu Feb 19 01:41:47 GMT 2009


At http://people.ubuntu.com/~robertc/baz2.0/push.roundtrips

------------------------------------------------------------
revno: 4018
revision-id: robertc at robertcollins.net-20090219014143-wv42sc7z71wbhht0
parent: pqm at pqm.ubuntu.com-20090218132708-okubrahz9exvae9r
committer: Robert Collins <robertc at robertcollins.net>
branch nick: push.roundtrips
timestamp: Thu 2009-02-19 12:41:43 +1100
message:
  Add BzrDirFormatMeta1 test for the amount of rpc calls made initializing over the network.
=== modified file 'bzrlib/bzrdir.py'
--- a/bzrlib/bzrdir.py	2009-02-18 03:25:21 +0000
+++ b/bzrlib/bzrdir.py	2009-02-19 01:41:43 +0000
@@ -188,8 +188,8 @@
         """
         transport.ensure_base()
         require_stacking = (stacked_on is not None)
-        metadir = self.cloning_metadir(require_stacking)
-        result = metadir.initialize_on_transport(transport)
+        format = self.cloning_metadir(require_stacking)
+        result = format.initialize_on_transport(transport)
         repository_policy = None
         try:
             local_repo = self.find_repository()

=== modified file 'bzrlib/tests/__init__.py'
--- a/bzrlib/tests/__init__.py	2009-02-12 06:24:08 +0000
+++ b/bzrlib/tests/__init__.py	2009-02-19 01:41:43 +0000
@@ -76,6 +76,7 @@
 from bzrlib.merge import merge_inner
 import bzrlib.merge3
 import bzrlib.plugin
+from bzrlib.smart import client, server
 import bzrlib.store
 from bzrlib import symbol_versioning
 from bzrlib.symbol_versioning import (
@@ -2041,6 +2042,19 @@
         self.__server = None
         self.reduceLockdirTimeout()
 
+    def setup_smart_server_with_call_log(self):
+        """Sets up a smart server as the transport server with a call log."""
+        self.transport_server = server.SmartTCPServer_for_testing
+        self.hpss_calls = []
+        def capture_hpss_call(params):
+            import traceback
+            self.hpss_calls.append((params, traceback.format_stack()))
+        client._SmartClient.hooks.install_named_hook(
+            'call', capture_hpss_call, None)
+
+    def reset_smart_call_log(self):
+        self.hpss_calls = []
+
      
 class TestCaseInTempDir(TestCaseWithMemoryTransport):
     """Derived class that runs a test within a temporary directory.

=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py	2009-02-18 04:21:04 +0000
+++ b/bzrlib/tests/blackbox/test_push.py	2009-02-19 01:41:43 +0000
@@ -180,22 +180,11 @@
             % tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
         self.failUnlessExists('to-two')
 
-    def _reset_smart_call_log(self):
-        self.hpss_calls = []
-
-    def _setup_smart_call_log(self):
-        self.transport_server = server.SmartTCPServer_for_testing
-        self.hpss_calls = []
-        def capture_hpss_call(params):
-            self.hpss_calls.append(params)
-        client._SmartClient.hooks.install_named_hook(
-            'call', capture_hpss_call, None)
-
     def test_push_smart_non_stacked_streaming_acceptance(self):
-        self._setup_smart_call_log()
+        self.setup_smart_server_with_call_log()
         t = self.make_branch_and_tree('from')
         t.commit(allow_pointless=True, message='first commit')
-        self._reset_smart_call_log()
+        self.reset_smart_call_log()
         self.run_bzr(['push', self.get_url('to-one')], working_dir='from')
         rpc_count = len(self.hpss_calls)
         # This figure represent the amount of work to perform this use case. It
@@ -206,12 +195,12 @@
         self.assertEqual(107, rpc_count)
 
     def test_push_smart_stacked_streaming_acceptance(self):
-        self._setup_smart_call_log()
+        self.setup_smart_server_with_call_log()
         parent = self.make_branch_and_tree('parent', format='1.9')
         parent.commit(message='first commit')
         local = parent.bzrdir.sprout('local').open_workingtree()
         local.commit(message='local commit')
-        self._reset_smart_call_log()
+        self.reset_smart_call_log()
         self.run_bzr(['push', '--stacked', '--stacked-on', '../parent',
             self.get_url('public')], working_dir='local')
         rpc_count = len(self.hpss_calls)

=== modified file 'bzrlib/tests/test_bzrdir.py'
--- a/bzrlib/tests/test_bzrdir.py	2009-01-26 17:04:21 +0000
+++ b/bzrlib/tests/test_bzrdir.py	2009-02-19 01:41:43 +0000
@@ -32,6 +32,7 @@
     repository,
     osutils,
     symbol_versioning,
+    remote,
     urlutils,
     win32utils,
     workingtree,
@@ -885,6 +886,22 @@
         self.assertTrue(tree.bzrdir.needs_format_conversion(
             new_format))
 
+    def test_initialize_on_format_uses_smart_transport(self):
+        self.setup_smart_server_with_call_log()
+        new_format = bzrdir.format_registry.make_bzrdir('dirstate')
+        transport = self.get_transport('target')
+        transport.ensure_base()
+        self.reset_smart_call_log()
+        instance = new_format.initialize_on_transport(transport)
+        self.assertIsInstance(instance, remote.RemoteBzrDir)
+        rpc_count = len(self.hpss_calls)
+        # This figure represent the amount of work to perform this use case. It
+        # is entirely ok to reduce this number if a test fails due to rpc_count
+        # being too low. If rpc_count increases, more network roundtrips have
+        # become necessary for this use case. Please do not adjust this number
+        # upwards without agreement from bzr's network support maintainers.
+        self.assertEqual(15, rpc_count)
+
 
 class TestFormat5(TestCaseWithTransport):
     """Tests specific to the version 5 bzrdir format."""




More information about the bazaar-commits mailing list