Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
104
Merge Requests
104
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
db797f12
Commit
db797f12
authored
Aug 23, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[software/jstestnode] Allow to run jio test with node
parent
5b06eea6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
69 deletions
+109
-69
component/nodejs/buildout.cfg
component/nodejs/buildout.cfg
+10
-0
software/jstestnode/runTestSuite.in
software/jstestnode/runTestSuite.in
+93
-67
software/jstestnode/software.cfg
software/jstestnode/software.cfg
+6
-2
No files found.
component/nodejs/buildout.cfg
View file @
db797f12
[buildout]
[buildout]
extends =
extends =
../coreutils/buildout.cfg
../patch/buildout.cfg
../patch/buildout.cfg
../git/buildout.cfg
../git/buildout.cfg
../pkgconfig/buildout.cfg
../pkgconfig/buildout.cfg
...
@@ -32,6 +33,15 @@ environment =
...
@@ -32,6 +33,15 @@ environment =
LDFLAGS=-Wl,-rpath=${gcc:location}/lib -Wl,-rpath=${gcc:location}/lib64 -Wl,-rpath=${openssl:location}/lib -L${zlib:location}/lib -Wl,-rpath=${zlib:location}/lib
LDFLAGS=-Wl,-rpath=${gcc:location}/lib -Wl,-rpath=${gcc:location}/lib64 -Wl,-rpath=${openssl:location}/lib -L${zlib:location}/lib -Wl,-rpath=${zlib:location}/lib
LD_LIBRARY_PATH=${openssl:location}/lib
LD_LIBRARY_PATH=${openssl:location}/lib
[nodejs-8.6.0-output]
# Shared binary location to ease migration
recipe = plone.recipe.command
stop-on-error = true
update-command = ${:command}
command = ${coreutils-output:test} -x ${:node} -a -x ${:npm}
node = ${nodejs-8.6.0:location}/bin/node
npm = ${nodejs-8.6.0:location}/bin/npm
[nodejs-5]
[nodejs-5]
# Server-side Javascript.
# Server-side Javascript.
recipe = slapos.recipe.cmmi
recipe = slapos.recipe.cmmi
...
...
software/jstestnode/runTestSuite.in
View file @
db797f12
...
@@ -12,6 +12,8 @@ from selenium import webdriver
...
@@ -12,6 +12,8 @@ from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support import expected_conditions as EC
from subprocess import check_output
import json
os.environ['TMPDIR'] = '$${xvfb-instance:tmp-path}'
os.environ['TMPDIR'] = '$${xvfb-instance:tmp-path}'
os.environ['DISPLAY'] = ':0'
os.environ['DISPLAY'] = ':0'
...
@@ -81,13 +83,13 @@ def main():
...
@@ -81,13 +83,13 @@ def main():
date = strftime("%Y/%m/%d %H:%M:%S", gmtime())
date = strftime("%Y/%m/%d %H:%M:%S", gmtime())
##########################
##########################
# Run all tests
# Run all tests
##########################
##########################
is_appium = False
is_appium = False
if args.target == 'firefox':
if args.target == 'firefox':
firefox_capabilities = webdriver.common.desired_capabilities.DesiredCapabilities.FIREFOX
firefox_capabilities = webdriver.common.desired_capabilities.DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
firefox_capabilities['marionette'] = True
...
@@ -114,71 +116,95 @@ def main():
...
@@ -114,71 +116,95 @@ def main():
'platform': args.target,
'platform': args.target,
'version': args.target_version
'version': args.target_version
}
}
if is_appium:
if not args.appium_server_auth:
raise RuntimeError('--appium_server_auth is required.')
appium_url = "http://%s@ondemand.saucelabs.com/wd/hub" % (args.appium_server_auth)
browser = webdriver.Remote(appium_url, capabilities)
# adjust path for remote test url
remote_access_url = parsed_parameters.get('remote-access-url', None)
if remote_access_url:
if ('jio' in test_suite):
url = os.path.join(remote_access_url, 'jio/test/tests.html')
else:
url = os.path.join(remote_access_url, 'renderjs/test/')
else:
raise ValueError('remote-access-url is not defined in instance parameter')
is_browser_running = True
agent = browser.execute_script("return navigator.userAgent")
print agent
print url
browser.get(url)
WebDriverWait(browser, 300).until(EC.presence_of_element_located((
By.XPATH, '//p[@id="qunit-testresult" and contains(text(), "completed")]')
))
html_parser = etree.HTMLParser(recover=True)
body = etree.fromstring(browser.page_source.encode('UTF-8'), html_parser)
print ' '.join(body.xpath('//*[@id="qunit-testresult"]//text()'))
for elt in body.xpath('.//ol[@id="qunit-tests"]/li'):
if (len(elt.xpath('.//span[@class="module-name"]'))):
test_name = '%s: %s' % (
elt.xpath('.//span[@class="module-name"]')[0].text,
elt.xpath('.//span[@class="test-name"]')[0].text
)
#global failure, like Uncaught ReferenceError: RSVP is not defined
else:
test_name = elt.xpath('.//span[@class="test-name"]')[0].text
print elt.get('class'), ''.join(elt.xpath('.//strong')[0].itertext())
# print elt.find_element_by_tag_name('ol').get_attribute('innerHTML')
failure = int(elt.xpath('.//b[@class="failed"]')[0].text)
success = int(elt.xpath('.//b[@class="passed"]')[0].text)
test_line_dict[test_name] = {
'test_count': success + failure,
'error_count': 0,
'failure_count': failure,
'skip_count': 0,
'duration': int(elt.xpath('.//span[@class="runtime"]')[0].text.split()[0]),
'command': elt.xpath('.//a[text()="Rerun"]')[0].get('href'),
'stdout': agent,
'stderr': '',
'html_test_result': etree.tostring(elt.xpath('.//ol')[0])
}
# do quit browser asap as we have results. this is required in case of timeout of
# remote appium service which will close test session of no command received within
# usually 90s and thus fail this script. And it costs processing time as well
# to keep test session needlessly opened.
browser.quit()
is_browser_running = False
if args.target == 'node':
# Execute NodeJS tests
result_string = check_output(['${nodejs-output:node}', '${jio-repository.git:location}/test/node.js'],
cwd='${jio-repository.git:location}',
env={'CI': 'true'})
result_dict = json.loads(result_string)
for result in result_dict['tests']:
test_line_dict['%s: %s' % (result['module'], result['name'])] = {
'test_count': int(result['total']),
'error_count': 0,
'failure_count': int(result['failed']),
'skip_count': 0,
'duration': int(result['duration']),
'command': '',
'stdout': result['source'],
'stderr': '',
'html_test_result': json.dumps(result['assertions'])
}
else:
# Execute WebBrowser tests
if is_appium:
if not args.appium_server_auth:
raise RuntimeError('--appium_server_auth is required.')
appium_url = "http://%s@ondemand.saucelabs.com/wd/hub" % (args.appium_server_auth)
browser = webdriver.Remote(appium_url, capabilities)
# adjust path for remote test url
remote_access_url = parsed_parameters.get('remote-access-url', None)
if remote_access_url:
if ('jio' in test_suite):
url = os.path.join(remote_access_url, 'jio/test/tests.html')
else:
url = os.path.join(remote_access_url, 'renderjs/test/')
else:
raise ValueError('remote-access-url is not defined in instance parameter')
is_browser_running = True
agent = browser.execute_script("return navigator.userAgent")
print agent
print url
browser.get(url)
WebDriverWait(browser, 300).until(EC.presence_of_element_located((
By.XPATH, '//p[@id="qunit-testresult" and contains(text(), "completed")]')
))
html_parser = etree.HTMLParser(recover=True)
body = etree.fromstring(browser.page_source.encode('UTF-8'), html_parser)
print ' '.join(body.xpath('//*[@id="qunit-testresult"]//text()'))
for elt in body.xpath('.//ol[@id="qunit-tests"]/li'):
if (len(elt.xpath('.//span[@class="module-name"]'))):
test_name = '%s: %s' % (
elt.xpath('.//span[@class="module-name"]')[0].text,
elt.xpath('.//span[@class="test-name"]')[0].text
)
#global failure, like Uncaught ReferenceError: RSVP is not defined
else:
test_name = elt.xpath('.//span[@class="test-name"]')[0].text
print elt.get('class'), ''.join(elt.xpath('.//strong')[0].itertext())
# print elt.find_element_by_tag_name('ol').get_attribute('innerHTML')
failure = int(elt.xpath('.//b[@class="failed"]')[0].text)
success = int(elt.xpath('.//b[@class="passed"]')[0].text)
test_line_dict[test_name] = {
'test_count': success + failure,
'error_count': 0,
'failure_count': failure,
'skip_count': 0,
'duration': int(elt.xpath('.//span[@class="runtime"]')[0].text.split()[0]),
'command': elt.xpath('.//a[text()="Rerun"]')[0].get('href'),
'stdout': agent,
'stderr': '',
'html_test_result': etree.tostring(elt.xpath('.//ol')[0])
}
# do quit browser asap as we have results. this is required in case of timeout of
# remote appium service which will close test session of no command received within
# usually 90s and thus fail this script. And it costs processing time as well
# to keep test session needlessly opened.
browser.quit()
is_browser_running = False
# Send results
tool = taskdistribution.TaskDistributor(portal_url=args.master_url)
tool = taskdistribution.TaskDistributor(portal_url=args.master_url)
test_result = tool.createTestResult(revision = revision,
test_result = tool.createTestResult(revision = revision,
test_name_list = test_line_dict.keys(),
test_name_list = test_line_dict.keys(),
...
@@ -208,7 +234,7 @@ def main():
...
@@ -208,7 +234,7 @@ def main():
stdout='')
stdout='')
# XXX: inform test node master of error
# XXX: inform test node master of error
raise EnvironmentError(result)
raise EnvironmentError(result)
finally:
finally:
if is_browser_running:
if is_browser_running:
# if by any chance browser is still running due to
# if by any chance browser is still running due to
...
...
software/jstestnode/software.cfg
View file @
db797f12
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
extends =
extends =
../../stack/slapos.cfg
../../stack/slapos.cfg
../../stack/nodejs.cfg
../../stack/nodejs.cfg
../../component/coreutils/buildout.cfg
../../component/git/buildout.cfg
../../component/git/buildout.cfg
../../component/xorg/buildout.cfg
../../component/xorg/buildout.cfg
../../component/firefox/buildout.cfg
../../component/firefox/buildout.cfg
...
@@ -27,6 +28,9 @@ parts =
...
@@ -27,6 +28,9 @@ parts =
[nodejs]
[nodejs]
<= nodejs-8.6.0
<= nodejs-8.6.0
[nodejs-output]
<= nodejs-8.6.0-output
[instance]
[instance]
recipe = slapos.recipe.template
recipe = slapos.recipe.template
md5sum = 7c907db5f803b03a218b49888a3a3799
md5sum = 7c907db5f803b03a218b49888a3a3799
...
@@ -52,7 +56,7 @@ develop = true
...
@@ -52,7 +56,7 @@ develop = true
[renderjs-install]
[renderjs-install]
recipe = plone.recipe.command
recipe = plone.recipe.command
stop-on-error = true
stop-on-error = true
command = cd ${renderjs-repository.git:location} && PATH=${git:location}/bin/:${nodejs:location}/bin/:$PATH ${nodejs
:location}/bin/npm
install . && PATH=${git:location}/bin/:${nodejs:location}/bin/:$PATH ./node_modules/grunt-cli/bin/grunt
command = cd ${renderjs-repository.git:location} && PATH=${git:location}/bin/:${nodejs:location}/bin/:$PATH ${nodejs
-output:npm}
install . && PATH=${git:location}/bin/:${nodejs:location}/bin/:$PATH ./node_modules/grunt-cli/bin/grunt
update-command = ${:command}
update-command = ${:command}
[jio-repository.git]
[jio-repository.git]
...
@@ -111,7 +115,7 @@ mode = 0644
...
@@ -111,7 +115,7 @@ mode = 0644
[template-runTestSuite]
[template-runTestSuite]
recipe = slapos.recipe.template
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/runTestSuite.in
url = ${:_profile_base_location_}/runTestSuite.in
md5sum =
8528d90cce5d034195e3e71bef855c48
md5sum =
2898d62902351e6df9ce887bd98e2ca1
output = ${buildout:directory}/runTestSuite.in
output = ${buildout:directory}/runTestSuite.in
mode = 0644
mode = 0644
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment