/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_pack_repository.py

  • Committer: Aaron Bentley
  • Date: 2008-11-03 18:59:14 UTC
  • mfrom: (3818 +trunk)
  • mto: (0.16.99 shelf-ui)
  • mto: This revision was merged to the branch mainline in revision 3820.
  • Revision ID: aaron@aaronbentley.com-20081103185914-inz25vtsiowydw1p
Merge with bzr.dev

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,
395
399
        finally:
396
400
            r1.unlock()
397
401
 
 
402
    def test_concurrent_pack_triggers_reload(self):
 
403
        # create 2 packs, which we will then collapse
 
404
        tree = self.make_branch_and_tree('tree')
 
405
        tree.lock_write()
 
406
        try:
 
407
            rev1 = tree.commit('one')
 
408
            rev2 = tree.commit('two')
 
409
            r2 = repository.Repository.open('tree')
 
410
            r2.lock_read()
 
411
            try:
 
412
                # Now r2 has read the pack-names file, but will need to reload
 
413
                # it after r1 has repacked
 
414
                tree.branch.repository.pack()
 
415
                self.assertEqual({rev2:(rev1,)}, r2.get_parent_map([rev2]))
 
416
            finally:
 
417
                r2.unlock()
 
418
        finally:
 
419
            tree.unlock()
 
420
 
398
421
    def test_lock_write_does_not_physically_lock(self):
399
422
        repo = self.make_repository('.', format=self.get_format())
400
423
        repo.lock_write()
608
631
        self.assertTrue(large_pack_name in pack_names)
609
632
 
610
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
 
611
672
def load_tests(basic_tests, module, test_loader):
612
673
    # these give the bzrdir canned format name, and the repository on-disk
613
674
    # format string
630
691
                  "(bzr 1.6.1)\n",
631
692
              format_supports_external_lookups=True,
632
693
              index_class=GraphIndex),
 
694
         dict(format_name='1.9',
 
695
              format_string="Bazaar RepositoryFormatKnitPack6 (bzr 1.9)\n",
 
696
              format_supports_external_lookups=True,
 
697
              index_class=BTreeGraphIndex),
 
698
         dict(format_name='1.9-rich-root',
 
699
              format_string="Bazaar RepositoryFormatKnitPack6RichRoot "
 
700
                  "(bzr 1.9)\n",
 
701
              format_supports_external_lookups=True,
 
702
              index_class=BTreeGraphIndex),
633
703
         dict(format_name='development2',
634
704
              format_string="Bazaar development format 2 "
635
705
                  "(needs bzr.dev from before 1.8)\n",