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):
raise argparse.ArgumentTypeError(
'expects either a strictly positive integer or a range of strictly '
'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):
help='ERP5 publish project')
# Mandatory arguments
parser.add_argument('url',
type=ArgumentType.ERP5UrlType,
metavar='URL',
help='ERP5 base URL')
parser.add_argument('erp5_base_url', metavar='ERP5_URL')
parser.add_argument('users',
type=ArgumentType.strictlyPositiveIntOrRangeType,
......
......@@ -47,8 +47,6 @@ class BenchmarkProcess(multiprocessing.Process):
self._user_index = user_index
self._current_repeat_range = current_repeat_range
self._base_url, self._erp5_site_id = argument_namespace.url
try:
self._username, self._password, self._source_ip = \
argument_namespace.user_tuple[user_index]
......@@ -71,13 +69,12 @@ class BenchmarkProcess(multiprocessing.Process):
"another process, flushing remaining results...")
def getBrowser(self, log_file):
return Browser(base_url=self._base_url,
erp5_site_id=self._erp5_site_id,
username=self._username,
password=self._password,
is_debug=self._argument_namespace.enable_debug,
log_file=log_file,
is_legacy_listbox=self._argument_namespace.is_legacy_listbox)
return Browser(self._argument_namespace.erp5_base_url,
self._username,
self._password,
log_file,
self._argument_namespace.enable_debug,
self._argument_namespace.is_legacy_listbox)
def runBenchmarkSuiteList(self, result):
for target_idx, target in enumerate(self._argument_namespace.benchmark_suite_list):
......
......@@ -130,22 +130,17 @@ class Browser(ExtendedTestBrowser):
__metaclass__ = measurementMetaClass(prefix='open')
def __init__(self,
base_url,
erp5_site_id,
erp5_base_url,
username,
password,
log_file=None,
is_debug=False,
is_legacy_listbox=False):
"""
Create a browser object, allowing to log in right away with the
given username and password. The base URL must contain an I{/} at
the end.
Create a browser object.
@param base_url: Base HTTP URL
@type base_url: str
@param erp5_site_id: ERP5 site name
@type erp5_site_id: str
@param erp5_base_url: ERP5 HTTP URL
@type erp5_base_url: str
@param username: Username to be used to log into ERP5
@type username: str
@param password: Password to be used to log into ERP5
......@@ -160,11 +155,9 @@ class Browser(ExtendedTestBrowser):
# has been changed
self._main_form = None
assert base_url[-1] == '/'
self._base_url = base_url
self._erp5_site_id = erp5_site_id
self._erp5_base_url = urljoin(self._base_url, self._erp5_site_id) + '/'
self._erp5_base_url = erp5_base_url
if self._erp5_base_url[-1] != '/':
self._erp5_base_url += '/'
self._username = username
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