~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_pack_repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-10-31 04:02:53 UTC
  • mfrom: (3801.1.21 autopack-rpc)
  • Revision ID: pqm@pqm.ubuntu.com-20081031040253-lqwvq5xf6rhnumii
Add 'PackRepository.autopack' RPC. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    upgrade,
38
38
    workingtree,
39
39
    )
 
40
from bzrlib.smart import (
 
41
    client,
 
42
    server,
 
43
    )
40
44
from bzrlib.tests import (
41
45
    TestCase,
42
46
    TestCaseWithTransport,
627
631
        self.assertTrue(large_pack_name in pack_names)
628
632
 
629
633
 
 
634
class TestSmartServerAutopack(TestCaseWithTransport):
 
635
 
 
636
    def setUp(self):
 
637
        super(TestSmartServerAutopack, self).setUp()
 
638
        # Create a smart server that publishes whatever the backing VFS server
 
639
        # does.
 
640
        self.smart_server = server.SmartTCPServer_for_testing()
 
641
        self.smart_server.setUp(self.get_server())
 
642
        self.addCleanup(self.smart_server.tearDown)
 
643
        # Log all HPSS calls into self.hpss_calls.
 
644
        client._SmartClient.hooks.install_named_hook(
 
645
            'call', self.capture_hpss_call, None)
 
646
        self.hpss_calls = []
 
647
 
 
648
    def capture_hpss_call(self, params):
 
649
        self.hpss_calls.append(params.method)
 
650
 
 
651
    def get_format(self):
 
652
        return bzrdir.format_registry.make_bzrdir(self.format_name)
 
653
 
 
654
    def test_autopack_rpc_is_used_when_using_hpss(self):
 
655
        # Make local and remote repos
 
656
        tree = self.make_branch_and_tree('local', format=self.get_format())
 
657
        self.make_branch_and_tree('remote', format=self.get_format())
 
658
        remote_branch_url = self.smart_server.get_url() + 'remote'
 
659
        remote_branch = bzrdir.BzrDir.open(remote_branch_url).open_branch()
 
660
        # Make 9 local revisions, and push them one at a time to the remote
 
661
        # repo to produce 9 pack files.
 
662
        for x in range(9):
 
663
            tree.commit('commit %s' % x)
 
664
            tree.branch.push(remote_branch)
 
665
        # Make one more push to trigger an autopack
 
666
        self.hpss_calls = []
 
667
        tree.commit('commit triggering pack')
 
668
        tree.branch.push(remote_branch)
 
669
        self.assertTrue('PackRepository.autopack' in self.hpss_calls)
 
670
 
 
671
 
630
672
def load_tests(basic_tests, module, test_loader):
631
673
    # these give the bzrdir canned format name, and the repository on-disk
632
674
    # format string