1
# Copyright (C) 2006 by Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License version 2 as published by
5
# the Free Software Foundation.
7
# This program is distributed in the hope that it will be useful,
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
# GNU General Public License for more details.
12
# You should have received a copy of the GNU General Public License
13
# along with this program; if not, write to the Free Software
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
"""Tests for bzr performance over SFTP"""
23
from bzrlib.benchmarks import Benchmark
24
from bzrlib.tests import test_sftp_transport, TestSkipped
28
paramiko_loaded = True
30
paramiko_loaded = False
33
class SFTPBenchmark(Benchmark):
34
"""Benchmark branch, push and pull across a local sftp connection."""
37
super(SFTPBenchmark, self).setUp()
38
if not paramiko_loaded:
39
raise TestSkipped('you must have paramiko to run this test')
40
test_sftp_transport.set_test_transport_to_sftp(self)
42
def test_branch(self):
44
tree, files = self.create_with_commits(100, 100, "a")
45
self.time(bzrdir.BzrDir.open(self.get_url('a')).sprout, "b")
47
def create_commit_and_pull(self, num_pull_revisions):
49
tree, files = self.create_with_commits(100, 100, "a")
50
rbzrdir = bzrdir.BzrDir.open(self.get_url('a'))
51
b2 = tree.bzrdir.sprout("b") # branch
52
# change a few files and commit
53
self.commit_some_revisions(tree, files, num_pull_revisions, 20)
54
self.time(b2.open_branch().pull, rbzrdir.open_branch())
56
def test_pull_1(self):
57
self.create_commit_and_pull(1)
59
def test_pull_10(self):
60
self.create_commit_and_pull(10)
62
def test_pull_100(self):
63
self.create_commit_and_pull(100)
65
def create_commit_and_push(self, num_push_revisions):
67
tree, files = self.create_with_commits(100, 100, "a")
68
rbzrdir = bzrdir.BzrDir.open(self.get_url('a'))
69
b2 = tree.bzrdir.sprout("b") # branch
70
wtree = b2.open_workingtree()
71
# change a few files and commit
72
self.commit_some_revisions(
73
wtree, ["b/%i" for i in range(100)],
74
num_commits=num_push_revisions,
75
changes_per_commit=20)
76
self.time(rbzrdir.open_branch().pull, wtree.branch)
78
def test_initial_push(self):
80
tree, files = self.create_with_commits(100, 100, "a")
81
self.time(tree.bzrdir.clone, self.get_url('b'),
82
revision_id=tree.last_revision())
84
def test_push_1(self):
85
self.create_commit_and_push(1)
87
def test_push_10(self):
88
self.create_commit_and_push(10)
90
def test_push_100(self):
91
self.create_commit_and_push(100)
94
class SFTPSlowSocketBenchmark(SFTPBenchmark):
96
super(SFTPSlowSocketBenchmark, self).setUp()
97
self.get_server().add_latency = 0.03