Skip to content
Snippets Groups Projects
Commit 4998bff40454 authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

benchmark: add code to use roles in exchange benchmark

benchmark test can now "easily" use the new role information. A
`BaseExchangeTimeSuite` subclass can use the `role_action` and `role_subtype`
to declare the role the class is using. Then decorate the class with
`@setup_role` to make sure the parameters variants are properly set.

Finally the appropriate data can we accessed through the `role_data` property.
parent f6394b762bec
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@
median,
REPOS_DIR,
STRIP_VARIANTS_LIST,
ROLES,
REPO_DETAILS,
not_compatible_with,
)
......@@ -278,4 +279,15 @@
self.rev = None
class classproperty(object):
def __init__(self, f):
self.f = f
def __get__(self, obj, owner):
return self.f(owner)
def setup_role(cls):
"""install the right partial variants for the configured action"""
cls.params[cls._partials_idx] = list(sorted(cls.role_data))
return cls
class BaseExchangeTimeSuite(BaseExchangeMixin, BaseTestSuite):
......@@ -281,3 +293,8 @@
class BaseExchangeTimeSuite(BaseExchangeMixin, BaseTestSuite):
# the exchange action we measure
role_action = None
# the subtypes of this action we measure
role_subtype = None
param_names = BaseTestSuite.param_names + [
'repo_type', 'strip', 'revset']
......@@ -282,8 +299,9 @@
param_names = BaseTestSuite.param_names + [
'repo_type', 'strip', 'revset']
params = BaseTestSuite.params + [
['local', 'ssh', 'http'],
STRIP_VARIANTS_LIST,
[None, 'tip']]
params = BaseTestSuite.params + [['local', 'ssh', 'http']]
_partials_idx = len(params)
params += [STRIP_VARIANTS_LIST]
params += [[None, 'tip']]
timeout = 1800
......@@ -288,5 +306,14 @@
timeout = 1800
@classproperty
def role_data(cls):
"""{"partial-key" -> {"repo-key" -> {data}} map for the current role"""
if cls.role_action is None:
return None
if cls.role_subtype is None:
return None
return ROLES.get(cls.role_action, {}).get(cls.role_subtype, {})
def run(self, local_repo, command, remote_repo, expected_return_code=None):
if not isinstance(command, (list, tuple)):
command = [command]
......
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