Skip to content
Snippets Groups Projects
Commit 49870745 authored by Philippe Pepiot's avatar Philippe Pepiot
Browse files

Add a helper method for running exchange benchmarks

Commands are almost the same, so extract this in a run() helper.
This will help for implementing ssh/http exchange benchmarks
parent 540974ee
No related branches found
No related tags found
No related merge requests found
...@@ -126,6 +126,16 @@ ...@@ -126,6 +126,16 @@
timer = timeit.default_timer timer = timeit.default_timer
sample_time = 10 sample_time = 10
def run(self, local_repo, command, remote_repo, expected_return_code=None):
if not isinstance(command, (list, tuple)):
command = [command]
cmd = [self.hgpath, '--cwd', local_repo] + command + [remote_repo]
if self.rev:
cmd.extend(['-r', self.rev])
if expected_return_code is None:
expected_return_code = 1 if self.strip == "same" else 0
self._single_execute(cmd, expected_return_code=expected_return_code)
def setup(self, repo_name, strip, revset): def setup(self, repo_name, strip, revset):
super(BaseExchangeTimeSuite, self).setup(repo_name) super(BaseExchangeTimeSuite, self).setup(repo_name)
self.clone_path = os.path.join(REPOS_DIR, '.cache', 'partial-{}-{}'.format( self.clone_path = os.path.join(REPOS_DIR, '.cache', 'partial-{}-{}'.format(
...@@ -136,8 +146,9 @@ ...@@ -136,8 +146,9 @@
], env=self.environ).strip() ], env=self.environ).strip()
else: else:
self.rev = None self.rev = None
self.strip = strip
class ExchangeTimeSuite(BaseExchangeTimeSuite): class ExchangeTimeSuite(BaseExchangeTimeSuite):
def time_incoming(self, repo_name, strip, revset): def time_incoming(self, repo_name, strip, revset):
...@@ -139,11 +150,8 @@ ...@@ -139,11 +150,8 @@
class ExchangeTimeSuite(BaseExchangeTimeSuite): class ExchangeTimeSuite(BaseExchangeTimeSuite):
def time_incoming(self, repo_name, strip, revset): def time_incoming(self, repo_name, strip, revset):
cmd = [self.hgpath, '--cwd', self.clone_path, 'incoming', self.repo_path] self.run(self.clone_path, 'incoming', self.repo_path)
if self.rev:
cmd.extend(['-r', self.rev])
self._single_execute(cmd, expected_return_code=1 if strip == "same" else 0)
def time_outgoing(self, repo_name, strip, revset): def time_outgoing(self, repo_name, strip, revset):
...@@ -148,9 +156,6 @@ ...@@ -148,9 +156,6 @@
def time_outgoing(self, repo_name, strip, revset): def time_outgoing(self, repo_name, strip, revset):
cmd = [self.hgpath, '--cwd', self.repo_path, 'outgoing', self.clone_path] self.run(self.repo_path, 'outgoing', self.clone_path)
if self.rev:
cmd.extend(['-r', self.rev])
self._single_execute(cmd, expected_return_code=1 if strip == "same" else 0)
class DiscoveryTimeSuite(BaseExchangeTimeSuite): class DiscoveryTimeSuite(BaseExchangeTimeSuite):
...@@ -161,8 +166,8 @@ ...@@ -161,8 +166,8 @@
[None]] [None]]
def time_debugdiscovery(self, repo_name, strip, revset): def time_debugdiscovery(self, repo_name, strip, revset):
cmd = [self.hgpath, '--cwd', self.clone_path, 'debugdiscovery', self.repo_path] self.run(self.clone_path, 'debugdiscovery', self.repo_path,
self._single_execute(cmd) expected_return_code=0)
class PushPullTimeSuite(BaseExchangeTimeSuite): class PushPullTimeSuite(BaseExchangeTimeSuite):
...@@ -192,10 +197,6 @@ ...@@ -192,10 +197,6 @@
self._single_execute(['sync']) self._single_execute(['sync'])
def time_push(self, repo_name, strip, revset): def time_push(self, repo_name, strip, revset):
cmd = [self.hgpath, '--cwd', self.repo_path, 'push', '-f', self.run(self.repo_path, ['push', '-f'], self.tmp_clone_path)
self.tmp_clone_path]
if self.rev:
cmd.extend(['-r', self.rev])
self._single_execute(cmd, expected_return_code=1 if strip == "same" else 0)
def time_pull(self, repo_name, strip, revset): def time_pull(self, repo_name, strip, revset):
...@@ -200,10 +201,7 @@ ...@@ -200,10 +201,7 @@
def time_pull(self, repo_name, strip, revset): def time_pull(self, repo_name, strip, revset):
cmd = [self.hgpath, '--cwd', self.tmp_clone_path, 'pull', self.run(self.tmp_clone_path, 'pull', self.repo_path,
self.repo_path] expected_return_code=0)
if self.rev:
cmd.extend(['-r', self.rev])
self._single_execute(cmd)
class CloneTimeSuite(BaseExchangeTimeSuite): class CloneTimeSuite(BaseExchangeTimeSuite):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment