Commit fcb974e6 authored by Arnaud Fontaine's avatar Arnaud Fontaine

No need to specify base URL and ERP5 site separately.

It was involving twisted conversion back and forth between
erp5.util.testbrowser which expected the URL and ERP5 site id whereas
erp5.util.benchmark which only expected the full URL.

Moreover, it was not working if there is no "real" ERP5 site ID, for example
with: http://foobar.org/.
parent 9879579a
...@@ -107,16 +107,3 @@ class ArgumentType(object): ...@@ -107,16 +107,3 @@ class ArgumentType(object):
raise argparse.ArgumentTypeError( raise argparse.ArgumentTypeError(
'expects either a strictly positive integer or a range of strictly ' 'expects either a strictly positive integer or a range of strictly '
'positive integer separated by a comma') 'positive integer separated by a comma')
@classmethod
def ERP5UrlType(cls, url):
if url[-1] == '/':
url_list = url.rsplit('/', 2)[:-1]
else:
url_list = url.rsplit('/', 1)
url_list[0] = url_list[0] + '/'
if len(url_list) != 2:
raise argparse.ArgumentTypeError("Invalid URL given")
return url_list
...@@ -133,10 +133,7 @@ class PerformanceTester(object): ...@@ -133,10 +133,7 @@ class PerformanceTester(object):
help='ERP5 publish project') help='ERP5 publish project')
# Mandatory arguments # Mandatory arguments
parser.add_argument('url', parser.add_argument('erp5_base_url', metavar='ERP5_URL')
type=ArgumentType.ERP5UrlType,
metavar='URL',
help='ERP5 base URL')
parser.add_argument('users', parser.add_argument('users',
type=ArgumentType.strictlyPositiveIntOrRangeType, type=ArgumentType.strictlyPositiveIntOrRangeType,
......
...@@ -47,8 +47,6 @@ class BenchmarkProcess(multiprocessing.Process): ...@@ -47,8 +47,6 @@ class BenchmarkProcess(multiprocessing.Process):
self._user_index = user_index self._user_index = user_index
self._current_repeat_range = current_repeat_range self._current_repeat_range = current_repeat_range
self._base_url, self._erp5_site_id = argument_namespace.url
try: try:
self._username, self._password, self._source_ip = \ self._username, self._password, self._source_ip = \
argument_namespace.user_tuple[user_index] argument_namespace.user_tuple[user_index]
...@@ -71,13 +69,12 @@ class BenchmarkProcess(multiprocessing.Process): ...@@ -71,13 +69,12 @@ class BenchmarkProcess(multiprocessing.Process):
"another process, flushing remaining results...") "another process, flushing remaining results...")
def getBrowser(self, log_file): def getBrowser(self, log_file):
return Browser(base_url=self._base_url, return Browser(self._argument_namespace.erp5_base_url,
erp5_site_id=self._erp5_site_id, self._username,
username=self._username, self._password,
password=self._password, log_file,
is_debug=self._argument_namespace.enable_debug, self._argument_namespace.enable_debug,
log_file=log_file, self._argument_namespace.is_legacy_listbox)
is_legacy_listbox=self._argument_namespace.is_legacy_listbox)
def runBenchmarkSuiteList(self, result): def runBenchmarkSuiteList(self, result):
for target_idx, target in enumerate(self._argument_namespace.benchmark_suite_list): for target_idx, target in enumerate(self._argument_namespace.benchmark_suite_list):
......
...@@ -130,22 +130,17 @@ class Browser(ExtendedTestBrowser): ...@@ -130,22 +130,17 @@ class Browser(ExtendedTestBrowser):
__metaclass__ = measurementMetaClass(prefix='open') __metaclass__ = measurementMetaClass(prefix='open')
def __init__(self, def __init__(self,
base_url, erp5_base_url,
erp5_site_id,
username, username,
password, password,
log_file=None, log_file=None,
is_debug=False, is_debug=False,
is_legacy_listbox=False): is_legacy_listbox=False):
""" """
Create a browser object, allowing to log in right away with the Create a browser object.
given username and password. The base URL must contain an I{/} at
the end.
@param base_url: Base HTTP URL @param erp5_base_url: ERP5 HTTP URL
@type base_url: str @type erp5_base_url: str
@param erp5_site_id: ERP5 site name
@type erp5_site_id: str
@param username: Username to be used to log into ERP5 @param username: Username to be used to log into ERP5
@type username: str @type username: str
@param password: Password to be used to log into ERP5 @param password: Password to be used to log into ERP5
...@@ -160,11 +155,9 @@ class Browser(ExtendedTestBrowser): ...@@ -160,11 +155,9 @@ class Browser(ExtendedTestBrowser):
# has been changed # has been changed
self._main_form = None self._main_form = None
assert base_url[-1] == '/' self._erp5_base_url = erp5_base_url
if self._erp5_base_url[-1] != '/':
self._base_url = base_url self._erp5_base_url += '/'
self._erp5_site_id = erp5_site_id
self._erp5_base_url = urljoin(self._base_url, self._erp5_site_id) + '/'
self._username = username self._username = username
self._password = password self._password = password
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment