/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 breezy/tests/blackbox/test_branch.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-06-01 21:57:00 UTC
  • mfrom: (7490.39.3 move-launchpad)
  • Revision ID: breezy.the.bot@gmail.com-20200601215700-joxuzo6w172gq74v
Move launchpad hoster support to the launchpad plugin.

Merged from https://code.launchpad.net/~jelmer/brz/move-launchpad/+merge/384931

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
    HardlinkFeature,
39
39
    )
40
40
from breezy.tests.blackbox import test_switch
 
41
from breezy.tests.matchers import ContainsNoVfsCalls
41
42
from breezy.tests.test_sftp_transport import TestCaseWithSFTPServer
42
43
from breezy.tests.script import run_script
43
44
from breezy.urlutils import local_path_to_url, strip_trailing_slash
551
552
            err)
552
553
 
553
554
 
 
555
class TestSmartServerBranching(tests.TestCaseWithTransport):
 
556
 
 
557
    def test_branch_from_trivial_branch_to_same_server_branch_acceptance(self):
 
558
        self.setup_smart_server_with_call_log()
 
559
        t = self.make_branch_and_tree('from')
 
560
        for count in range(9):
 
561
            t.commit(message='commit %d' % count)
 
562
        self.reset_smart_call_log()
 
563
        out, err = self.run_bzr(['branch', self.get_url('from'),
 
564
                                 self.get_url('target')])
 
565
        # This figure represent the amount of work to perform this use case. It
 
566
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
567
        # being too low. If rpc_count increases, more network roundtrips have
 
568
        # become necessary for this use case. Please do not adjust this number
 
569
        # upwards without agreement from bzr's network support maintainers.
 
570
        self.assertLength(2, self.hpss_connections)
 
571
        self.assertLength(34, self.hpss_calls)
 
572
        self.expectFailure(
 
573
            "branching to the same branch requires VFS access",
 
574
            self.assertThat, self.hpss_calls, ContainsNoVfsCalls)
 
575
 
 
576
    def test_branch_from_trivial_branch_streaming_acceptance(self):
 
577
        self.setup_smart_server_with_call_log()
 
578
        t = self.make_branch_and_tree('from')
 
579
        for count in range(9):
 
580
            t.commit(message='commit %d' % count)
 
581
        self.reset_smart_call_log()
 
582
        out, err = self.run_bzr(['branch', self.get_url('from'),
 
583
                                 'local-target'])
 
584
        # This figure represent the amount of work to perform this use case. It
 
585
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
586
        # being too low. If rpc_count increases, more network roundtrips have
 
587
        # become necessary for this use case. Please do not adjust this number
 
588
        # upwards without agreement from bzr's network support maintainers.
 
589
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
590
        self.assertLength(11, self.hpss_calls)
 
591
        self.assertLength(1, self.hpss_connections)
 
592
 
 
593
    def test_branch_from_trivial_stacked_branch_streaming_acceptance(self):
 
594
        self.setup_smart_server_with_call_log()
 
595
        t = self.make_branch_and_tree('trunk')
 
596
        for count in range(8):
 
597
            t.commit(message='commit %d' % count)
 
598
        tree2 = t.branch.controldir.sprout('feature', stacked=True
 
599
                                           ).open_workingtree()
 
600
        local_tree = t.branch.controldir.sprout(
 
601
            'local-working').open_workingtree()
 
602
        local_tree.commit('feature change')
 
603
        local_tree.branch.push(tree2.branch)
 
604
        self.reset_smart_call_log()
 
605
        out, err = self.run_bzr(['branch', self.get_url('feature'),
 
606
                                 'local-target'])
 
607
        # This figure represent the amount of work to perform this use case. It
 
608
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
609
        # being too low. If rpc_count increases, more network roundtrips have
 
610
        # become necessary for this use case. Please do not adjust this number
 
611
        # upwards without agreement from bzr's network support maintainers.
 
612
        self.assertLength(16, self.hpss_calls)
 
613
        self.assertLength(1, self.hpss_connections)
 
614
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
615
 
 
616
    def test_branch_from_branch_with_tags(self):
 
617
        self.setup_smart_server_with_call_log()
 
618
        builder = self.make_branch_builder('source')
 
619
        source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev(
 
620
            builder)
 
621
        source.get_config_stack().set('branch.fetch_tags', True)
 
622
        source.tags.set_tag('tag-a', rev2)
 
623
        source.tags.set_tag('tag-missing', b'missing-rev')
 
624
        # Now source has a tag not in its ancestry.  Make a branch from it.
 
625
        self.reset_smart_call_log()
 
626
        out, err = self.run_bzr(['branch', self.get_url('source'), 'target'])
 
627
        # This figure represent the amount of work to perform this use case. It
 
628
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
629
        # being too low. If rpc_count increases, more network roundtrips have
 
630
        # become necessary for this use case. Please do not adjust this number
 
631
        # upwards without agreement from bzr's network support maintainers.
 
632
        self.assertLength(11, self.hpss_calls)
 
633
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
634
        self.assertLength(1, self.hpss_connections)
 
635
 
 
636
    def test_branch_to_stacked_from_trivial_branch_streaming_acceptance(self):
 
637
        self.setup_smart_server_with_call_log()
 
638
        t = self.make_branch_and_tree('from')
 
639
        for count in range(9):
 
640
            t.commit(message='commit %d' % count)
 
641
        self.reset_smart_call_log()
 
642
        out, err = self.run_bzr(['branch', '--stacked', self.get_url('from'),
 
643
                                 'local-target'])
 
644
        # XXX: the number of hpss calls for this case isn't deterministic yet,
 
645
        # so we can't easily assert about the number of calls.
 
646
        #self.assertLength(XXX, self.hpss_calls)
 
647
        # We can assert that none of the calls were readv requests for rix
 
648
        # files, though (demonstrating that at least get_parent_map calls are
 
649
        # not using VFS RPCs).
 
650
        readvs_of_rix_files = [
 
651
            c for c in self.hpss_calls
 
652
            if c.call.method == 'readv' and c.call.args[-1].endswith('.rix')]
 
653
        self.assertLength(1, self.hpss_connections)
 
654
        self.assertLength(0, readvs_of_rix_files)
 
655
        self.expectFailure("branching to stacked requires VFS access",
 
656
                           self.assertThat, self.hpss_calls, ContainsNoVfsCalls)
 
657
 
 
658
    def test_branch_from_branch_with_ghosts(self):
 
659
        self.setup_smart_server_with_call_log()
 
660
        t = self.make_branch_and_tree('from')
 
661
        for count in range(9):
 
662
            t.commit(message='commit %d' % count)
 
663
        t.set_parent_ids([t.last_revision(), b'ghost'])
 
664
        t.commit(message='add commit with parent')
 
665
        self.reset_smart_call_log()
 
666
        out, err = self.run_bzr(['branch', self.get_url('from'),
 
667
                                 'local-target'])
 
668
        # This figure represent the amount of work to perform this use case. It
 
669
        # is entirely ok to reduce this number if a test fails due to rpc_count
 
670
        # being too low. If rpc_count increases, more network roundtrips have
 
671
        # become necessary for this use case. Please do not adjust this number
 
672
        # upwards without agreement from bzr's network support maintainers.
 
673
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
674
        self.assertLength(12, self.hpss_calls)
 
675
        self.assertLength(1, self.hpss_connections)
 
676
 
 
677
 
554
678
class TestRemoteBranch(TestCaseWithSFTPServer):
555
679
 
556
680
    def setUp(self):