Commit b04d30a2 by Alain Takoudjou

Update Release Candidate

2 parents a0c13e56 2ac7baf6
......@@ -51,7 +51,7 @@ pycrypto = 2.6.1
pycurl = 7.43.0
slapos.recipe.download = 1.0
slapos.recipe.template = 4.3
slapos.toolbox = 0.80
slapos.toolbox = 0.81
smmap = 0.9.0
# Required by:
......
......@@ -11,7 +11,7 @@ plone.recipe.command = 1.1
pycrypto = 2.6.1
rdiff-backup = 1.0.5+SlapOSPatched001
slapos.recipe.template = 4.3
slapos.toolbox = 0.80
slapos.toolbox = 0.81
smmap = 0.9.0
numpy = 1.11.2
pyasn1 = 0.2.3
......
......@@ -11,7 +11,7 @@ plone.recipe.command = 1.1
pycrypto = 2.6.1
rdiff-backup = 1.0.5+SlapOSPatched001
slapos.recipe.template = 4.3
slapos.toolbox = 0.80
slapos.toolbox = 0.81
smmap = 0.9.0
numpy = 1.11.2
pyasn1 = 0.2.3
......
......@@ -232,6 +232,13 @@
"default": 10,
"minimum": 1
},
"disk-format": {
"title": "Type of external disk drive to create by QEMU.",
"description": "Type of QEMU disk drive, to create.",
"type": "string",
"default": "qcow2",
"enum": ["qcow2", "raw", "vdi", "vmdk", "cloop", "qed"]
},
"disk-type": {
"title": "Disk type",
"description": "Type of QEMU disk drive.",
......@@ -288,7 +295,8 @@
"cpu-model": {
"title": "CPU model.",
"description": "Select the emulated CPU model. Ex: SandyBridge,+erms,+smep,+smx,+vmx",
"type": "string"
"type": "string",
"default": "host"
},
"keyboard-layout-language": {
"title": "Use keyboard layout language",
......
......@@ -56,6 +56,7 @@ config-enable-device-hotplug = {{ dumps(kvm_parameter_dict.get('enable-device-ho
config-ram-hotplug-slot-size = {{ dumps(kvm_parameter_dict.get('ram-hotplug-slot-size', 512)) }}
config-disk-size = {{ dumps(kvm_parameter_dict.get('disk-size', 10)) }}
config-disk-type = {{ dumps(kvm_parameter_dict.get('disk-type', 'virtio')) }}
config-disk-format = {{ dumps(kvm_parameter_dict.get('disk-format', 'qcow2')) }}
config-cpu-count = {{ dumps(kvm_parameter_dict.get('cpu-count', 1)) }}
config-cpu-max-count = {{ dumps(kvm_parameter_dict.get('cpu-max-count', 24)) }}
{{ setconfig('numa', kvm_parameter_dict.get('numa', '')) }}
......
......@@ -55,6 +55,14 @@
"default": "virtio",
"enum": ["ide", "scsi", "sd", "mtd", "floppy", "pflash", "virtio"]
},
"disk-format": {
"title": "Type of disk drive to create by QEMU.",
"description": "Type of QEMU disk drive, to create.",
"type": "string",
"default": "qcow2",
"enum": ["qcow2", "raw", "vdi", "vmdk", "cloop", "qed"]
},
"disk-cache": {
"title": "Cache option to use with Disk.",
"description": "Disk cache controls how the host cache is used to access block data.",
......
......@@ -88,10 +88,11 @@ nbd2-port = ${slap-parameter:nbd2-port}
tap-interface = ${slap-network-information:network-interface}
disk-path = ${directory:srv}/virtual.qcow2
disk-size = ${slap-parameter:disk-size}
disk-type = ${slap-parameter:disk-type}
disk-format = ${slap-parameter:disk-format}
disk-device-path = ${slap-parameter:disk-device-path}
disk-path = ${directory:srv}/virtual.${slap-parameter:disk-format}
pid-file-path = ${kvm-controller-parameter-dict:pid-file}
socket-path = ${kvm-controller-parameter-dict:socket-path}
......@@ -565,6 +566,8 @@ ram-max-size = 51200
ram-hotplug-slot-size = 512
disk-size = 10
disk-type = virtio
disk-format = qcow2
disk-device-path =
cpu-count = 1
cpu-max-count = 24
......
......@@ -99,7 +99,7 @@ recipe = hexagonit.recipe.download
ignore-existing = true
url = ${:_profile_base_location_}/instance-kvm.cfg.jinja2
mode = 644
md5sum = e59ea29533d7f989ec676e14b0f29839
md5sum = dbf43756c605144f0a3cd829b588d931
download-only = true
on-update = true
......@@ -108,7 +108,7 @@ recipe = hexagonit.recipe.download
ignore-existing = true
url = ${:_profile_base_location_}/instance-kvm-cluster.cfg.jinja2.in
mode = 644
md5sum = 6d165aec7d236ea3944765236d11940f
md5sum = cccabafc001c6df35da95af6bf2ae28e
download-only = true
on-update = true
......@@ -186,7 +186,7 @@ ignore-existing = true
url = ${:_profile_base_location_}/template/template-kvm-run.in
mode = 644
filename = template-kvm-run.in
md5sum = c6f1536a3502102dadbfb9d82496cc36
md5sum = 887585f23359d136093de42b1ad1d777
download-only = true
on-update = true
......@@ -255,7 +255,7 @@ context =
# XXX - use websockify = 0.5.1 for compatibility with kvm frontend
websockify = 0.5.1
slapos.toolbox = 0.80
slapos.toolbox = 0.81
erp5.util = 0.4.51
apache-libcloud = 1.1.0
collective.recipe.environment = 0.2.0
......
......@@ -20,6 +20,10 @@ qemu_img_path = '{{ parameter_dict.get("qemu-img-path") }}'
qemu_path = '{{ parameter_dict.get("qemu-path") }}'
disk_size = '{{ parameter_dict.get("disk-size") }}'
disk_type = '{{ parameter_dict.get("disk-type") }}'
disk_format = '{{ parameter_dict.get("disk-format", "qcow2")}}'
disk_format = disk_format \
if disk_format in ['qcow2', 'raw', 'vdi', 'vmdk', 'cloop', 'qed'] else 'qcow2'
socket_path = '{{ parameter_dict.get("socket-path") }}'
nbd_list = (('{{ parameter_dict.get("nbd-host") }}',
{{ parameter_dict.get("nbd-port") }}),
......@@ -27,6 +31,7 @@ nbd_list = (('{{ parameter_dict.get("nbd-host") }}',
{{ parameter_dict.get("nbd2-port") }}))
default_cdrom_iso = '{{ parameter_dict.get("default-cdrom-iso") }}'
disk_path = '{{ parameter_dict.get("disk-path") }}'
virtual_hard_drive_url = '{{ parameter_dict.get("virtual-hard-drive-url") }}'.strip()
virtual_hard_drive_md5sum = '{{ parameter_dict.get("virtual-hard-drive-md5sum") }}'.strip()
virtual_hard_drive_gzipped = '{{ parameter_dict.get("virtual-hard-drive-gzipped") }}'.strip().lower()
......@@ -46,7 +51,9 @@ init_ram_size = {{ parameter_dict.get("init-ram-size") }}
pid_file_path = '{{ parameter_dict.get("pid-file-path") }}'
external_disk_number = {{ parameter_dict.get("external-disk-number") }}
external_disk_size = {{ parameter_dict.get("external-disk-size") }}
external_disk_format = '{{ parameter_dict.get("external-disk-format") }}'
external_disk_format = '{{ parameter_dict.get("external-disk-format", "qcow2") }}'
external_disk_format = external_disk_format \
if external_disk_format in ['qcow2', 'raw', 'vdi', 'vmdk', 'cloop', 'qed'] else 'qcow2'
disk_storage_dict = {}
disk_storage_list = """{{ parameter_dict.get("disk-storage-list") }}""".split('\n')
map_storage_list = []
......@@ -63,16 +70,25 @@ language_list = ['ar', 'da', 'de', 'de-ch', 'en-gb', 'en-us', 'es', 'et', 'fi',
url_check_certificate = '{{ parameter_dict.get("hard-drive-url-check-certificate", "true") }}'.lower()
auto_ballooning = '{{ parameter_dict.get("auto-ballooning") }}' in ('true', 'True', '1')
vm_name = '{{ parameter_dict.get("name") }}'
disk_cache = '{{ parameter_dict.get("disk-cache") }}'.strip()
disk_cache = '{{ parameter_dict.get("disk-cache", "writeback") }}'.strip()
disk_cache = disk_cache if disk_cache in ["none", "writeback", "unsafe",
"directsync", "writethrough"] else "writeback"
disk_aio = '{{ parameter_dict.get("disk-aio") }}'.strip()
disk_aio = disk_aio if disk_aio in ["threads", "native"] and \
disk_cache == "directsync" else "threads"
disk_aio = '{{ parameter_dict.get("disk-aio", "threads") }}'.strip()
disk_aio = disk_aio if disk_aio in ["threads", "native"] else "threads"
# If a device (ie.: /dev/sdb) is provided, use it instead
# the disk_path with disk_format
disk_device_path = '{{ parameter_dict.get("disk-device-path", "") }}'
if disk_device_path.startswith("/dev/"):
disk_path = disk_device_path
disk_format = "raw"
disk_aio = "native"
disk_cache = "none"
smp_count = {{ parameter_dict.get("smp-count") }}
smp_max_count = {{ parameter_dict.get("smp-max-count") }}
machine_options = '{{ parameter_dict.get("machine-options", "") }}'.strip()
cpu_model = '{{ parameter_dict.get("cpu-model", "") }}'.strip()
cpu_model = '{{ parameter_dict.get("cpu-model", "host") }}'.strip()
enable_device_hotplug = '{{ parameter_dict.get("enable-device-hotplug") }}'.lower()
......@@ -184,9 +200,9 @@ if not os.path.exists(disk_path) and virtual_hard_drive_url != '':
# Create disk if doesn't exist
# XXX: move to Buildout profile
if not os.path.exists(disk_path):
if not disk_device_path.startswith("/dev/") and not os.path.exists(disk_path):
print('Creating virtual hard drive...')
subprocess.check_call([qemu_img_path, 'create' ,'-f', 'qcow2',
subprocess.check_call([qemu_img_path, 'create' ,'-f', disk_format,
disk_path, '%sG' % disk_size])
print('Done.')
......@@ -197,9 +213,6 @@ for storage in disk_storage_list:
key, val = storage.split(' ')
disk_storage_dict[key.strip()] = val.strip()
if not external_disk_format in ['qcow2', 'raw', 'vdi', 'vmdk', 'cloop', 'qed']:
external_disk_format = 'qcow2'
map_storage_list, external_disk_number = getMapStorageList(disk_storage_dict,
int(external_disk_number))
......@@ -215,7 +228,7 @@ if disk_storage_dict:
disk_list = glob.glob('%s.*' % os.path.join(path, 'kvm_virtual_disk'))
if disk_list == []:
print('Creating one additional virtual hard drive...')
process = subprocess.check_call([qemu_img_path, 'create' ,'-f', '%s' % external_disk_format,
process = subprocess.check_call([qemu_img_path, 'create' ,'-f', external_disk_format,
disk_filepath, '%sG' % external_disk_size])
else:
# Cannot change or recreate if disk is exists
......@@ -265,6 +278,7 @@ if enable_device_hotplug != 'true':
else:
smp = '1,maxcpus=%s' % smp_max_count
ram = '%sM,slots=128,maxmem=%sM' % (init_ram_size, ram_max_size)
kvm_argument_list = [qemu_path,
'-enable-kvm', '-smp', smp, '-name', vm_name, '-m', ram, '-vga', 'std',
'-drive', 'file=%s,if=%s,cache=%s,aio=%s' % (disk_path, disk_type, disk_cache, disk_aio),
......
......@@ -134,7 +134,7 @@ pycrypto = 2.6.1
pycurl = 7.43.0
setproctitle = 1.1.10
slapos.recipe.template = 4.3
slapos.toolbox = 0.80
slapos.toolbox = 0.81
smmap2 = 2.0.1
transaction = 1.7.0
zodbpickle = 0.6.0
......
......@@ -46,7 +46,7 @@ mode = 0644
[versions]
slapos.recipe.template = 4.3
slapos.toolbox = 0.80
slapos.toolbox = 0.81
dnspython = 1.15.0
PyRSS2Gen = 1.1
erp5.util = 0.4.51
......
......@@ -117,7 +117,7 @@ plone.recipe.command = 1.1
pycrypto = 2.6.1
pycurl = 7.43.0
slapos.recipe.template = 4.3
slapos.toolbox = 0.80
slapos.toolbox = 0.81
smmap = 0.9.0
dnspython = 1.15.0
erp5.util = 0.4.51
......
......@@ -173,7 +173,7 @@ mode = 640
Pygments = 2.1.3
slapos.recipe.template = 4.3
slapos.toolbox = 0.80
slapos.toolbox = 0.81
# All depencies should be pinned.
apache-libcloud = 2.3.0
......
......@@ -171,7 +171,7 @@ prettytable = 0.7.2
pycurl = 7.43.0
slapos.recipe.template = 4.3
collective.recipe.environment = 0.2.0
slapos.toolbox = 0.80
slapos.toolbox = 0.81
smmap = 0.9.0
lockfile = 0.12.2
......
......@@ -95,7 +95,7 @@ futures = 3.1.1
gitdb2 = 2.0.2
gunicorn = 19.7.1
slapos.recipe.template = 4.3
slapos.toolbox = 0.80
slapos.toolbox = 0.81
smmap2 = 2.0.3
# Required by:
......
......@@ -217,6 +217,10 @@ link-binary =
[template-postfix-aliases]
< = download-base
[template-run-zelenium]
< = download-base
url = ${:_profile_base_location_}/template/run-zelenium-test.py.in
[template]
recipe = slapos.recipe.template:jinja2
# XXX: "template.cfg" is hardcoded in instanciation recipe
......@@ -285,6 +289,8 @@ context =
key root_common root-common:target
key site_zcml site-zcml:target
key sixtunnel_location 6tunnel:location
key template_run_zelenium template-run-zelenium:target
key egg_interpreter eggs:interpreter
key stunnel_location stunnel:location
key template_apache_conf template-apache-backend-conf:target
key template_balancer template-balancer:target
......
......@@ -66,7 +66,7 @@ md5sum = 0969fbb25b05c02ef3c2d437b2f4e1a0
[template]
filename = instance.cfg.in
md5sum = 330b72acf0752cce5da70b1fcdfac487
md5sum = a5e8278067899081239d4366cf2b9eae
[monitor-template-dummy]
filename = dummy.cfg
......@@ -74,7 +74,7 @@ md5sum = d41d8cd98f00b204e9800998ecf8427e
[template-erp5]
filename = instance-erp5.cfg.in
md5sum = 9f8851af5faed9d1e346d7dbe0e6db5d
md5sum = 83e0f627633ec3e394dc27d06c627b3b
[template-zeo]
filename = instance-zeo.cfg.in
......@@ -82,7 +82,7 @@ md5sum = 3e650915959ff31c9c13c84069bbcd35
[template-zope]
filename = instance-zope.cfg.in
md5sum = a4dda17c1671ead45ac92b7decc32228
md5sum = e73678921067506e710ae11e41f0a9a8
[template-balancer]
filename = instance-balancer.cfg.in
......
......@@ -152,6 +152,7 @@ config-caucase-url = ${request-caucase:connection-http-url}
config-cloudooo-url = {{ dumps(slapparameter_dict.get('cloudooo-url', default_cloudooo_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-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')) }}
......
......@@ -4,6 +4,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 node_id_index_format = '-%%0%ii' % (len(str(instance_index_list[-1])), ) -%}
{% set part_list = [] -%}
{% set publish_list = [] -%}
......@@ -67,6 +68,25 @@ ca-certs = ${directory:test-ca-certs}
ca-newcerts = ${directory:test-ca-newcerts}
ca-crl = ${directory:test-ca-crl}
{% if saucelabs_dict -%}
[test-zelenium-runner-parameter]
configuration = {{ dumps(saucelabs_dict) }}
user = {{ dumps(slapparameter_dict['inituser-login']) }}
password = {{ dumps(slapparameter_dict['inituser-password']) }}
bin-path = {{ bin_directory }}/{{ parameter_dict['egg-interpreter'] }}
[{{ section('test-zelenium-runner') }}]
<= jinja2-template-base
template = {{ parameter_dict['run-zelenium-template'] }}
rendered = ${directory:bin}/runTestSuite
mode = 755
context =
import json_module json
key configuration test-zelenium-runner-parameter:configuration
key user test-zelenium-runner-parameter:user
key password test-zelenium-runner-parameter:password
key bin_path test-zelenium-runner-parameter:bin-path
{% else -%}
{% if slapparameter_dict['mysql-test-url-list'] -%}
[{{ section('run-unit-test-userhosts-wrapper') }}]
<= userhosts-wrapper-base
......@@ -125,6 +145,7 @@ command-name = runTestSuite
command-line-extra =
--db_list '{{ ','.join(connection_string_list) }}'
{%- endif %}
{%- endif %}
[directory]
recipe = slapos.cookbook:mkdirectory
......@@ -278,8 +299,9 @@ site-id = {{ site_id }}
mysql-url = {{ slapparameter_dict['mysql-url-list'][0] }}
inituser = {{ slapparameter_dict['inituser-login'] }}
{% set mysql = urlparse.urlsplit(slapparameter_dict['mysql-url-list'][0]) -%}
{% set mysql_db = mysql.path.split('/')[1] -%}
sql-connection-string = {{ '%s@erp5-catalog-0:%s %s %s' % (
mysql.path.split('/')[1], mysql.port, mysql.username, mysql.password) }}
mysql_db, mysql.port, mysql.username, mysql.password) }}
bt5 = {{ slapparameter_dict['bt5'] }}
bt5-repository-url = {{ slapparameter_dict['bt5-repository-url'] }}
id-store-interval = {{ dumps(slapparameter_dict['id-store-interval']) }}
......@@ -440,6 +462,16 @@ post = test ! -s {{ '${' ~ conf_parameter_name ~ ':pid-file}' }} || {{ bin_direc
) }}
{% endfor -%}
[{{ section("watch_activities") }}]
<= userhosts-wrapper-base
environment +=
MYSQL=${binary-link:target-directory}/mysql
wrapped-command-line = {{ parameter_dict['erp5-location'] }}/product/CMFActivity/bin/${:_buildout_section_name_} "-h erp5-catalog-0 -P {{ mysql.port }} -u {{ mysql.username }} -p{{ mysql.password}} {{ mysql_db }}" 5 3600
wrapper-path = ${buildout:bin-directory}/${:_buildout_section_name_}
[{{ section("wait_activities") }}]
<= watch_activities
[publish]
recipe = slapos.cookbook:publish.serialised
zope-address-list = {{ dumps(publish_list) }}
......
......@@ -84,6 +84,7 @@ extra-context =
[dynamic-template-zope-parameters]
bin-directory = {{ bin_directory }}
zope-conf-template = {{ template_zope_conf }}
run-zelenium-template = {{ template_run_zelenium }}
buildout-bin-directory = {{ buildout_bin_directory }}
6tunnel = {{ sixtunnel_location }}
coreutils = {{ coreutils_location }}
......@@ -95,6 +96,8 @@ site-zcml = {{ site_zcml }}
template-monitor = {{ dumps(template_monitor) }}
extra-path-list = {{ dumps(extra_path_list) }}
matplotlibrc = {{ matplotlibrc_location }}
erp5-location = {{ erp5_location }}
egg-interpreter = {{egg_interpreter}}
[dynamic-template-zope]
<= jinja2-template-base
......
#!{{ bin_path }}
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
import argparse, os, sys, traceback
from erp5.util import taskdistribution
from lxml import etree
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
from urllib import urlopen
def main():
parser = argparse.ArgumentParser(description='Run a test suite.')
parser_configuration = {{ repr(configuration) }}
parser.add_argument('--test_suite', help='The test suite name')
parser.add_argument('--test_suite_title', help='The test suite title')
parser.add_argument('--test_node_title', help='The test node title')
parser.add_argument('--project_title', help='The project title')
parser.add_argument('--revision', help='The revision to test',
default='dummy_revision')
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')
)
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
}
elif 'Windows' in args.target or 'OS X' in args.target:
capabilities = {
'browserName': args.target_browser,
'platform': args.target,
'version': args.target_version
}
if not args.appium_server_auth or not args.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:
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) }})
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) }})
# Wait until all activities are finished...
wait_url = args.remote_access_url + '/erp5/Zuite_waitForActivities'
while 1:
try:
response = urlopen(wait_url)
try:
if response.code == 500:
sys.exit(-1)
if response.code == 200 and response.read() == 'Done.':
break
finally:
response.close()
except Exception:
traceback.print_exc()
time.sleep(10)
tool = taskdistribution.TaskDistributor(portal_url=args.master_url)
browser = webdriver.Remote(appium_url, capabilities)
try:
agent = browser.execute_script("return navigator.userAgent")
print url
print agent
start_time = time.time()
browser.get(url)
# Wait for Zelenium to be loaded
WebDriverWait(browser, 10).until(EC.presence_of_element_located((
By.XPATH, '//iframe[@id="testSuiteFrame"]'
)))
# XXX No idea how to wait for the iframe content to be loaded
time.sleep(5)
# Count number of test to be executed
test_count = browser.execute_script(
"return document.getElementById('testSuiteFrame').contentDocument.querySelector('tbody').children.length"
) - 1 # First child is the file name
# Wait for test to be executed
erp5_zelenium_test_timeout = 90
WebDriverWait(browser, erp5_zelenium_test_timeout * (test_count + 1)).until(EC.presence_of_element_located((
By.XPATH, '//td[@id="testRuns" and contains(text(), "%i")]' % test_count
)))
execution_duration = round(time.time() - start_time, 2)
if test_count:
test_execution_duration = execution_duration / test_count
else:
test_execution_duration = 0
html_parser = etree.HTMLParser(recover=True)
# body = etree.fromstring(browser.page_source.encode('UTF-8'), html_parser)
# test_count = int(body.xpath('//td[@id="testRuns"]')[0].text)
# failed_test_count = int(body.xpath('//td[@id="testFailures"]')[0].text)
# print 'Run %i, failed %i' % (test_count, failed_test_count)
# https://github.com/appium/appium/issues/5199
# browser.switch_to.frame(browser.find_element_by_id("testSuiteFrame"))
# iframe = etree.fromstring(browser.page_source.encode('UTF-8'), html_parser)
iframe = etree.fromstring(
browser.execute_script(
"return document.getElementById('testSuiteFrame').contentDocument.querySelector('html').innerHTML"
).encode('UTF-8'),
html_parser
)
# parse test result
tbody = iframe.xpath('.//body/table/tbody')[0]
for tr in tbody[1:]:
# First td is the main title
test_name = tr[0][0].text
skip_count = success_count = error_count = 0
test_table = tr[1].xpath('.//table')[0]
test_tbody = tr[1].xpath('.//tbody')[0]
tr_count = len(test_tbody)
for tr in test_tbody:
# print etree.tostring(tr).split('\n')[0]
status = tr.attrib.get('class')
if status is None or 'status_done' in status:
skip_count += 1
elif 'status_passed' in status:
success_count += 1
elif 'status_failed' in status:
error_count += 1
test_line_dict[test_name] = {
'test_count': tr_count,
'error_count': error_count,
'failure_count': tr_count - (skip_count + success_count + error_count),
'skip_count': skip_count,
'duration': test_execution_duration,
'command': url,
'stdout': agent,
'stderr': '',
'html_test_result': etree.tostring(test_table)
}
except:
test_line_dict['UnexpectedException'] = {
'test_count': 1,
'error_count': 0,
'failure_count': 1,
'skip_count': 0,
'duration': 1,
'command': url,
'stdout': agent,
'stderr': traceback.format_exc()
}
finally:
browser.quit()
try:
test_result = tool.createTestResult(revision = revision,
test_name_list = test_line_dict.keys(),
node_title = args.test_node_title,
test_title = test_suite_title,
project_title = args.project_title)
if test_result is None or not hasattr(args, 'master_url'):
return
# report test results
while 1:
test_result_line = test_result.start()
if not test_result_line:
print 'No test result anymore.'
break
print 'Submitting: "%s"' % test_result_line.name
# report status back to Nexedi ERP5
test_result_line.stop(**test_line_dict[test_result_line.name])
except:
# Catch any exception here, to warn user instead of being silent,
# by generating fake error result
traceback.print_exc()
result = dict(status_code=-1,
command=url,
stderr=traceback.format_exc(),
stdout='')
# XXX: inform test node master of error
raise EnvironmentError(result)
if __name__ == "__main__":
main()
\ No newline at end of file
......@@ -121,6 +121,6 @@ depends =
PyRSS2Gen = 1.1
cns.recipe.symlink = 0.2.3
pycurl = 7.43.0
slapos.toolbox = 0.80
slapos.toolbox = 0.81
pyasn1 = 0.3.7
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!