Commit 73e93d60 authored by Xiaowu Zhang's avatar Xiaowu Zhang

stack/erp5: simplify setting when run selenium test on remote server

parent 0f5b52f2
......@@ -66,7 +66,7 @@ md5sum = 0969fbb25b05c02ef3c2d437b2f4e1a0
[template-run-zelenium]
filename = run-zelenium-test.py.in
md5sum = c64f35f825200fe35328641b2b8e0fdd
md5sum = 99004d9571b2574bb05058140d170013
[template]
filename = instance.cfg.in
......@@ -78,7 +78,7 @@ md5sum = d41d8cd98f00b204e9800998ecf8427e
[template-erp5]
filename = instance-erp5.cfg.in
md5sum = ff5e0d8d1ca167399fb438e890baf370
md5sum = 4fe42a1fe78ce9531d8e9c9837f4a784
[template-zeo]
filename = instance-zeo.cfg.in
......@@ -86,7 +86,7 @@ md5sum = 10a01b85c966ad9fe13bc981f1ddabe8
[template-zope]
filename = instance-zope.cfg.in
md5sum = 593a421b5de155756d5c483a2f7b9982
md5sum = 5eba2aa53af7ee74959745e6225ea0a7
[template-balancer]
filename = instance-balancer.cfg.in
......
......@@ -187,7 +187,7 @@ config-cloudooo-url = {{ dumps(slapparameter_dict.get('cloudooo-url', default_cl
config-caucase-url = {{ dumps(caucase_url) }}
config-deadlock-debugger-password = ${publish-early:deadlock-debugger-password}
config-developer-list = {{ dumps(slapparameter_dict.get('developer-list', [inituser_login])) }}
config-saucelabs-dict = {{ dumps(slapparameter_dict.get('saucelabs-dict', {})) }}
config-selenium-server-configuration-dict = {{ dumps(slapparameter_dict.get('selenium-server-configuration-dict', {})) }}
config-hosts-dict = {{ dumps(slapparameter_dict.get('hosts-dict', {})) }}
config-hostalias-dict = {{ dumps(slapparameter_dict.get('hostalias-dict', {})) }}
config-id-store-interval = {{ dumps(slapparameter_dict.get('id-store-interval')) }}
......
......@@ -6,7 +6,7 @@
{% set zodb_dict = slapparameter_dict['zodb-dict'] -%}
{% set instance_index_list = range(slapparameter_dict['instance-count']) -%}
{% set node_id_base = slapparameter_dict['name'] -%}
{% set saucelabs_dict = slapparameter_dict.get('saucelabs-dict', None) -%}
{% set selenium_server_configuration_dict = slapparameter_dict.get('selenium-server-configuration-dict', None) -%}
{% set node_id_index_format = '-%%0%ii' % (len(str(instance_index_list[-1])), ) -%}
{% set part_list = [] -%}
{% set publish_list = [] -%}
......@@ -405,9 +405,9 @@ wrapper-path = ${buildout:bin-directory}/${:_buildout_section_name_}
{% do test_runner_address_list.append((ipv4, next_port())) %}
{% endfor %}
{% if saucelabs_dict -%}
{% if selenium_server_configuration_dict -%}
[test-zelenium-runner-parameter]
configuration = {{ dumps(saucelabs_dict) }}
configuration = {{ dumps(selenium_server_configuration_dict) }}
user = {{ dumps(slapparameter_dict['inituser-login']) }}
password = {{ dumps(slapparameter_dict['inituser-password']) }}
bin-path = {{ bin_directory }}/{{ parameter_dict['egg-interpreter'] }}
......
......@@ -26,94 +26,35 @@ def main():
parser.add_argument('--node_quantity', help='ignored', type=int)
parser.add_argument('--master_url',
help='The Url of Master controling many suites')
parser.add_argument('--remote_access_url',
help='The access url',
default = parser_configuration.get('remote-access-url')
)
parser.add_argument('--target',
help='Target OS to run tests on',
default = parser_configuration.get('target')
)
parser.add_argument('--target_version',
help='Target OS version to use',
default = parser_configuration.get('target-version')
)
parser.add_argument('--target_browser',
help='The desired browser of the target OS to be used. Example: Firefox if target is Android.',
default = parser_configuration.get('target-browser')
)
parser.add_argument('--target_device',
help='The desired device running the target OS. Example: iPad Simulator, if target is iOS.',
default = parser_configuration.get('target-device')
)
parser.add_argument('--appium_server_auth',
help='Combination of user and token to access SauceLabs service. (i.e. user:token)',
default = parser_configuration.get('appium-server-auth')
)
parser.add_argument('--run_only',
help='zuite to run',
default = parser_configuration.get('run-only')
)
parser.add_argument('--max_duration',
type=int,
help='max duration for running test en second',
default = parser_configuration.get('max-duration', 1800)
)
args = parser.parse_args()
test_line_dict = {}
test_suite_title = args.test_suite_title or args.test_suite
test_suite = args.test_suite
revision = args.revision
# curl https://saucelabs.com/rest/v1/info/platforms/all
# https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/
if args.target in ['iOS', 'Android']:
# parameters for mobile emulators have different names then parameters for
# desktop OSes
capabilities = {
'platformName': args.target,
'platformVersion': args.target_version,
'deviceName': args.target_device,
'browserName': args.target_browser,
'maxDuration': args.max_duration,
'name': test_suite_title
}
elif 'Windows' in args.target or 'OS X' in args.target:
capabilities = {
'browserName': args.target_browser,
'platform': args.target,
'version': args.target_version,
'maxDuration': args.max_duration,
'name': test_suite_title
}
if not args.appium_server_auth or not args.remote_access_url:
if not parser_configuration['server-url'] or not parser_configuration['remote-access-url']:
sys.exit(-1)
#Authentication over HTTPS is not supported in saucelab
#https://wiki.saucelabs.com/display/DOCS/Instant+Selenium+Python+Tests
appium_url = "http://%s@ondemand.saucelabs.com/wd/hub" % (args.appium_server_auth)
# adjust make path to access url
# Do not store any test result in the ZMI
if args.run_only:
if parser_configuration['run-only']:
url = "%s/erp5/portal_tests/%s/core/TestRunner.html" \
"?test=../test_suite_html" \
"&auto=on" \
"&resultsUrl=../getId" \
"&__ac_name=%s" \
"&__ac_password=%s" % (args.remote_access_url, args.run_only, {{ repr(user) }}, {{ repr(password) }})
"&__ac_password=%s" % (parser_configuration['remote-access-url'], parser_configuration['run-only'], {{ repr(user) }}, {{ repr(password) }})
else:
url = "%s/erp5/portal_tests/core/TestRunner.html" \
"?test=../test_suite_html" \
"&auto=on" \
"&resultsUrl=../getId" \
"&__ac_name=%s" \
"&__ac_password=%s" % (args.remote_access_url, {{ repr(user) }}, {{ repr(password) }})
"&__ac_password=%s" % (parser_configuration['remote-access-url'], {{ repr(user) }}, {{ repr(password) }})
# Wait until all activities are finished...
wait_url = "%s/erp5/ActivityTool_getSqlStatisticList" \
"?__ac_name=%s" \
"&__ac_password=%s" % (args.remote_access_url, {{ repr(user) }}, {{ repr(password) }})
"&__ac_password=%s" % (parser_configuration['remote-access-url'], {{ repr(user) }}, {{ repr(password) }})
while 1:
try:
response = urlopen(wait_url)
......@@ -136,7 +77,7 @@ def main():
time.sleep(600)
tool = taskdistribution.TaskDistributor(portal_url=args.master_url)
browser = webdriver.Remote(appium_url, capabilities)
browser = webdriver.Remote(parser_configuration['server-url'] , parser_configuration['desired-capabilities'] )
try:
agent = browser.execute_script("return navigator.userAgent")
......@@ -158,7 +99,7 @@ def main():
# Wait for test to be executed
while 1:
try:
WebDriverWait(browser, args.max_duration).until(EC.presence_of_element_located((
WebDriverWait(browser, parser_configuration['max-duration']).until(EC.presence_of_element_located((
By.XPATH, '//td[@id="testRuns" and contains(text(), "%i")]' % test_count
)))
break
......@@ -276,4 +217,4 @@ def main():
raise EnvironmentError(result)
if __name__ == "__main__":
main()
\ No newline at end of file
main()
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