Commit e5b4b198 authored by Jérome Perrin's avatar Jérome Perrin

Port more softwares to python 3

See merge request !1238
parents 7d78a928 dc703207
Pipeline #23230 failed with stage
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
[template-cfg] [template-cfg]
filename = instance.cfg.in filename = instance.cfg.in
md5sum = ef264514b64a4b2c77c9965c587c6d34 md5sum = 23c15a579b66cef866b30a2f53b1b737
[instance_html5as] [instance_html5as]
_update_hash_filename_ = instance_html5as.cfg.in _update_hash_filename_ = instance_html5as.cfg.in
...@@ -45,4 +45,4 @@ md5sum = 1c0ee16966e1fcdb3fd11c09f12ee2b2 ...@@ -45,4 +45,4 @@ md5sum = 1c0ee16966e1fcdb3fd11c09f12ee2b2
[template_instance_replicate] [template_instance_replicate]
_update_hash_filename_ = instance_replicate.cfg.in _update_hash_filename_ = instance_replicate.cfg.in
md5sum = 7ff7e11d05145115f53564ec1af205ef md5sum = d7071867625070c27dbd6456c761f9f0
...@@ -61,7 +61,7 @@ default = instance-html5as:output ...@@ -61,7 +61,7 @@ default = instance-html5as:output
replicate = instance-replicate:output replicate = instance-replicate:output
[slap-configuration] [slap-configuration]
recipe = slapos.cookbook:slapconfiguration recipe = slapos.cookbook:slapconfiguration.serialised
computer = ${slap-connection:computer-id} computer = ${slap-connection:computer-id}
partition = ${slap-connection:partition-id} partition = ${slap-connection:partition-id}
url = ${slap-connection:server-url} url = ${slap-connection:server-url}
......
...@@ -23,7 +23,7 @@ offline = true ...@@ -23,7 +23,7 @@ offline = true
# Macro section sharing request parameters # Macro section sharing request parameters
[instance-request-base] [instance-request-base]
<= slap-connection <= slap-connection
recipe = slapos.cookbook:request recipe = slapos.cookbook:request.serialised
# It is the same software as the current one # It is the same software as the current one
software-url = ${slap-connection:software-release-url} software-url = ${slap-connection:software-release-url}
# We want the default behaviour # We want the default behaviour
...@@ -51,7 +51,7 @@ sla-computer_guid = {{ parameter_dict["sla-%s-computer-guid" % i] }} ...@@ -51,7 +51,7 @@ sla-computer_guid = {{ parameter_dict["sla-%s-computer-guid" % i] }}
# Publish information to connect to the two instances # Publish information to connect to the two instances
[publish-connection-information] [publish-connection-information]
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish.serialised
{% for i in range(1, replicate_quantity + 1) %} {% for i in range(1, replicate_quantity + 1) %}
instance-{{ i }}-server_url = ${instance-{{ i }}:connection-server_url} instance-{{ i }}-server_url = ${instance-{{ i }}:connection-server_url}
instance-{{ i }}-server-cdn-url = ${instance-{{ i }}:connection-server-cdn-url} instance-{{ i }}-server-cdn-url = ${instance-{{ i }}:connection-server-cdn-url}
......
...@@ -25,12 +25,14 @@ ...@@ -25,12 +25,14 @@
# #
############################################################################## ##############################################################################
import json
import os import os
import requests import requests
from urlparse import urlparse from urllib.parse import urlparse
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass( setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass(
os.path.abspath( os.path.abspath(
os.path.join(os.path.dirname(__file__), '..', 'software.cfg'))) os.path.join(os.path.dirname(__file__), '..', 'software.cfg')))
...@@ -43,8 +45,8 @@ class HTML5ASTestCase(SlapOSInstanceTestCase): ...@@ -43,8 +45,8 @@ class HTML5ASTestCase(SlapOSInstanceTestCase):
* Install the software release. * Install the software release.
* Checks it compile without issue. * Checks it compile without issue.
* Deploy the instance * Deploy the instance
* Check deployement works and promise pass * Check deployment works and promise pass
For testing the deployement a different testing class will need to be set up For testing the deployment a different testing class will need to be set up
per each variation of parameters the instance needs to be given. per each variation of parameters the instance needs to be given.
""" """
...@@ -63,11 +65,12 @@ class TestEmptyDeploy(HTML5ASTestCase): ...@@ -63,11 +65,12 @@ class TestEmptyDeploy(HTML5ASTestCase):
""" """
def test_deploy_with_no_paramater(self): def test_deploy_with_no_paramater(self):
url = self.requestDefaultInstance().getConnectionParameterDict()['server_url'] url = json.loads(self.computer_partition.getConnectionParameterDict()['_'])['server_url']
response = self.checkUrlAndGetResponse(url) response = self.checkUrlAndGetResponse(url)
result = response.text result = response.text
self.assertFalse("<h1>" in result) self.assertNotIn("<h1>", result)
self.assertTrue("<p>Hello World</p>" in result) self.assertIn("<p>Hello World</p>", result)
class TestDeployWithTitle(HTML5ASTestCase): class TestDeployWithTitle(HTML5ASTestCase):
""" """
...@@ -77,17 +80,21 @@ class TestDeployWithTitle(HTML5ASTestCase): ...@@ -77,17 +80,21 @@ class TestDeployWithTitle(HTML5ASTestCase):
@classmethod @classmethod
def getInstanceParameterDict(cls): def getInstanceParameterDict(cls):
return { return {
'_': json.dumps(
{
'title': 'Test1', 'title': 'Test1',
} }
)
}
def test_deploy_with_title_parameter(self): def test_deploy_with_title_parameter(self):
connection_parameter_dict = self.computer_partition.getConnectionParameterDict() connection_parameter_dict = json.loads(self.computer_partition.getConnectionParameterDict()['_'])
self.assertEqual(connection_parameter_dict["title"], "Title Test1!") self.assertEqual(connection_parameter_dict["title"], "Title Test1!")
url = connection_parameter_dict['server_url'] url = connection_parameter_dict['server_url']
response = self.checkUrlAndGetResponse(url) response = self.checkUrlAndGetResponse(url)
result = response.text result = response.text
self.assertTrue("<h1>Test1</h1>" in result) self.assertIn("<h1>Test1</h1>", result)
self.assertTrue("<p>Hello World</p>" in result) self.assertIn("<p>Hello World</p>", result)
class TestGracefulWithPortChange(HTML5ASTestCase): class TestGracefulWithPortChange(HTML5ASTestCase):
""" """
...@@ -95,7 +102,9 @@ class TestGracefulWithPortChange(HTML5ASTestCase): ...@@ -95,7 +102,9 @@ class TestGracefulWithPortChange(HTML5ASTestCase):
""" """
instance_parameter_dict = { instance_parameter_dict = {
'_': json.dumps({
'port': 8087 'port': 8087
})
} }
@classmethod @classmethod
...@@ -107,23 +116,23 @@ class TestGracefulWithPortChange(HTML5ASTestCase): ...@@ -107,23 +116,23 @@ class TestGracefulWithPortChange(HTML5ASTestCase):
This test test port change and its application with graceful restart This test test port change and its application with graceful restart
""" """
# Check initial connection parameter match expected port # Check initial connection parameter match expected port
url = self.computer_partition.getConnectionParameterDict()['server_url'] url = json.loads(self.computer_partition.getConnectionParameterDict()['_'])['server_url']
self.assertEqual(urlparse(url).port, 8087) self.assertEqual(urlparse(url).port, 8087)
# Check port is listening even thought it is duplicated with the promise: # Check port is listening even thought it is duplicated with the promise:
# "port-listening-promise" # "port-listening-promise"
self.checkUrlAndGetResponse(url) self.checkUrlAndGetResponse(url)
# Update port parameter # Update port parameter
self.instance_parameter_dict.update({ self.instance_parameter_dict['_'] = json.dumps({
'port': 8086, 'port': 8086
}) })
# Request instance with the new port parameter # Request instance with the new port parameter
self.requestDefaultInstance() self.requestDefaultInstance()
# Reprocess the instance to apply new port and run promises # Reprocess the instance to apply new port and run promises
self.slap.waitForInstance(self.instance_max_retry) self.slap.waitForInstance(self.instance_max_retry)
# Rerequest instance to get update connection parameter # Re-request instance to get update connection parameter
url = self.requestDefaultInstance().getConnectionParameterDict()['server_url'] url = json.loads(self.requestDefaultInstance().getConnectionParameterDict()['_'])['server_url']
# Make sure the new port is the one being used # Make sure the new port is the one being used
self.assertEqual(urlparse(url).port, 8086) self.assertEqual(urlparse(url).port, 8086)
...@@ -138,8 +147,10 @@ class TestReplicateHTML5AS(HTML5ASTestCase): ...@@ -138,8 +147,10 @@ class TestReplicateHTML5AS(HTML5ASTestCase):
""" """
instance_parameter_dict = { instance_parameter_dict = {
'_': json.dumps({
"port-1": 8088, "port-1": 8088,
"title-1": "Title 1", "title-1": "Title 1",
})
} }
@classmethod @classmethod
...@@ -152,31 +163,36 @@ class TestReplicateHTML5AS(HTML5ASTestCase): ...@@ -152,31 +163,36 @@ class TestReplicateHTML5AS(HTML5ASTestCase):
def test_replicate_instance(self): def test_replicate_instance(self):
# Check First instance is deployed with proper parameters # Check First instance is deployed with proper parameters
connection_parameter_dict = self.computer_partition.getConnectionParameterDict() connection_parameter_dict = json.loads(self.computer_partition.getConnectionParameterDict()['_'])
url = connection_parameter_dict['instance-1-server_url'] url = connection_parameter_dict['instance-1-server_url']
self.assertEqual(urlparse(url).port, 8088) self.assertEqual(urlparse(url).port, 8088)
response = self.checkUrlAndGetResponse(url) response = self.checkUrlAndGetResponse(url)
result = response.text result = response.text
self.assertTrue("<h1>Title 1</h1>" in result) self.assertIn("<h1>Title 1</h1>", result)
# Check only one instance is deployed by default # Check only one instance is deployed by default
self.assertTrue("instance-2-server_url" not in connection_parameter_dict) self.assertNotIn("instance-2-server_url", connection_parameter_dict)
# Update replicate quantity parameter # Update replicate quantity parameter
self.instance_parameter_dict.update({ self.instance_parameter_dict['_'] = json.dumps(
dict(
json.loads(self.instance_parameter_dict['_']),
**{
'replicate-quantity': 2, 'replicate-quantity': 2,
'port-2': 8089, 'port-2': 8089,
'sla-2-computer_guid': self.slap._computer_id, 'sla-2-computer_guid': self.slap._computer_id,
"title-2": "Title 314", "title-2": "Title 314",
}) }
)
)
# Request instance with the one more replicate # Request instance with the one more replicate
self.requestDefaultInstance() self.requestDefaultInstance()
self.slap.waitForInstance(self.instance_max_retry) self.slap.waitForInstance(self.instance_max_retry)
# Check the second replicate # Check the second replicate
connection_parameter_dict = self.requestDefaultInstance().getConnectionParameterDict() connection_parameter_dict = json.loads(self.requestDefaultInstance().getConnectionParameterDict()['_'])
url = connection_parameter_dict['instance-2-server_url'] url = connection_parameter_dict['instance-2-server_url']
self.assertEqual(urlparse(url).port, 8089) self.assertEqual(urlparse(url).port, 8089)
response = self.checkUrlAndGetResponse(url) response = self.checkUrlAndGetResponse(url)
result = response.text result = response.text
self.assertTrue("<h1>Title 314</h1>" in result) self.assertIn("<h1>Title 314</h1>", result)
...@@ -45,7 +45,5 @@ url = ${:_profile_base_location_}/${:filename} ...@@ -45,7 +45,5 @@ url = ${:_profile_base_location_}/${:filename}
output = ${buildout:directory}/template.cfg output = ${buildout:directory}/template.cfg
[versions] [versions]
# 1.3.4nxd2 is invalid version string, thus pached version string is not '1.3.4nxd2+SlapOSPatched001'
# but '1.3.4nxd2-SlapOSPatched001'.
gunicorn = 19.1.1 gunicorn = 19.1.1
inotifyx = 0.2.2 inotifyx = 0.2.2
...@@ -41,7 +41,6 @@ class TestHtmlValidatorServer(InstanceTestCase): ...@@ -41,7 +41,6 @@ class TestHtmlValidatorServer(InstanceTestCase):
def test(self): def test(self):
parameter_dict = self.computer_partition.getConnectionParameterDict() parameter_dict = self.computer_partition.getConnectionParameterDict()
# Check that there is a RSS feed
self.assertTrue('vnu-url' in parameter_dict) self.assertTrue('vnu-url' in parameter_dict)
self.assertEqual( self.assertEqual(
'https://[%s]:8899/' % (self._ipv6_address, ), 'https://[%s]:8899/' % (self._ipv6_address, ),
......
...@@ -27,4 +27,4 @@ md5sum = 98faa5ad8cfb23a11d97a459078a1d05 ...@@ -27,4 +27,4 @@ md5sum = 98faa5ad8cfb23a11d97a459078a1d05
[template-runTestSuite] [template-runTestSuite]
filename = runTestSuite.in filename = runTestSuite.in
md5sum = 70d10e7005b98620ddbbf30030b08198 md5sum = 54d585d50a3464100611774db68b72c0
...@@ -33,7 +33,7 @@ def main(): ...@@ -33,7 +33,7 @@ def main():
parser = argparse.ArgumentParser(description='Run a test suite.') parser = argparse.ArgumentParser(description='Run a test suite.')
parser.add_argument('--test_suite', help='The test suite name', parser.add_argument('--test_suite', help='The test suite name',
default=parsed_parameters.get('test-suite', ''), default=parsed_parameters.get('test-suite', ''),
required=not parsed_parameters.has_key('test-suite')) required='test-suite' not in parsed_parameters)
parser.add_argument('--test_suite_title', help='The test suite title') 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('--test_node_title', help='The test node title')
parser.add_argument('--project_title', help='The project title') parser.add_argument('--project_title', help='The project title')
...@@ -96,7 +96,7 @@ def main(): ...@@ -96,7 +96,7 @@ def main():
firefox_binary='${firefox-wrapper-68:location}', firefox_binary='${firefox-wrapper-68:location}',
executable_path='${geckodriver:location}') executable_path='${geckodriver:location}')
else: else:
assert target == 'selenium-server', "Unsupported target {}".format(test_runner['target']) assert target == 'selenium-server', f"Unsupported target {test_runner['target']}"
# use a remote connection which optionally verifies TLS certificate # use a remote connection which optionally verifies TLS certificate
# and optionally against a user provided CA. # and optionally against a user provided CA.
executor = RemoteConnection(test_runner['server-url'], keep_alive=True) executor = RemoteConnection(test_runner['server-url'], keep_alive=True)
...@@ -120,14 +120,14 @@ def main(): ...@@ -120,14 +120,14 @@ def main():
remote_access_url = parsed_parameters.get('remote-access-url') remote_access_url = parsed_parameters.get('remote-access-url')
if remote_access_url: if remote_access_url:
if ('jio' in test_suite): if ('jio' in test_suite):
url = '{}/jio/test/tests.html'.format(remote_access_url) url = f'{remote_access_url}/jio/test/tests.html'
else: else:
url = '{}/renderjs/test/'.format(remote_access_url) url = f'{remote_access_url}/renderjs/test'
is_browser_running = True is_browser_running = True
agent = browser.execute_script("return navigator.userAgent") agent = browser.execute_script("return navigator.userAgent")
print agent print(agent)
print url print(url)
browser.get(url) browser.get(url)
WebDriverWait(browser, 300).until(EC.presence_of_element_located(( WebDriverWait(browser, 300).until(EC.presence_of_element_located((
...@@ -137,7 +137,7 @@ def main(): ...@@ -137,7 +137,7 @@ def main():
html_parser = etree.HTMLParser(recover=True) html_parser = etree.HTMLParser(recover=True)
body = etree.fromstring(browser.page_source.encode('UTF-8'), html_parser) body = etree.fromstring(browser.page_source.encode('UTF-8'), html_parser)
print ' '.join(body.xpath('//*[@id="qunit-testresult"]//text()')) print(' '.join(body.xpath('//*[@id="qunit-testresult"]//text()')))
for elt in body.xpath('.//ol[@id="qunit-tests"]/li'): for elt in body.xpath('.//ol[@id="qunit-tests"]/li'):
if (len(elt.xpath('.//span[@class="module-name"]'))): if (len(elt.xpath('.//span[@class="module-name"]'))):
...@@ -149,7 +149,7 @@ def main(): ...@@ -149,7 +149,7 @@ def main():
else: else:
test_name = elt.xpath('.//span[@class="test-name"]')[0].text test_name = elt.xpath('.//span[@class="test-name"]')[0].text
print elt.get('class'), ''.join(elt.xpath('.//strong')[0].itertext()) print(elt.get('class'), ''.join(elt.xpath('.//strong')[0].itertext()))
# print elt.find_element_by_tag_name('ol').get_attribute('innerHTML') # print elt.find_element_by_tag_name('ol').get_attribute('innerHTML')
failure = int(elt.xpath('.//b[@class="failed"]')[0].text) failure = int(elt.xpath('.//b[@class="failed"]')[0].text)
...@@ -176,7 +176,7 @@ def main(): ...@@ -176,7 +176,7 @@ def main():
# Send results # 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 = list(test_line_dict.keys()),
node_title = args.test_node_title, node_title = args.test_node_title,
test_title = test_suite_title, test_title = test_suite_title,
project_title = args.project_title) project_title = args.project_title)
...@@ -186,17 +186,17 @@ def main(): ...@@ -186,17 +186,17 @@ def main():
while 1: while 1:
test_result_line = test_result.start() test_result_line = test_result.start()
if not test_result_line: if not test_result_line:
print 'No test result anymore.' print('No test result anymore.')
break break
print 'Submitting: "%s"' % test_result_line.name print('Submitting: "%s"' % test_result_line.name)
# report status back to Nexedi ERP5 # report status back to Nexedi ERP5
test_result_line.stop(**test_line_dict[test_result_line.name]) test_result_line.stop(**test_line_dict[test_result_line.name])
except: except:
# Catch any exception here, to warn user instead of being silent, # Catch any exception here, to warn user instead of being silent,
# by generating fake error result # by generating fake error result
print traceback.format_exc() print(traceback.format_exc())
result = dict(status_code=-1, result = dict(status_code=-1,
command=url, command=url,
stderr=traceback.format_exc(), stderr=traceback.format_exc(),
......
...@@ -29,9 +29,6 @@ parts = ...@@ -29,9 +29,6 @@ parts =
openssl openssl
instance instance
[python]
part = python2.7
[nodejs] [nodejs]
<= nodejs-14.16.0 <= nodejs-14.16.0
......
...@@ -20,7 +20,7 @@ md5sum = fc7bccab64e6794b33766ca9925231c8 ...@@ -20,7 +20,7 @@ md5sum = fc7bccab64e6794b33766ca9925231c8
[template-lte-enb-epc] [template-lte-enb-epc]
_update_hash_filename_ = instance-enb-epc.jinja2.cfg _update_hash_filename_ = instance-enb-epc.jinja2.cfg
md5sum = b10c10a9408a934052fd0960f31a75fc md5sum = c9994f2ef03edd7d6773307a6385c47c
[template-lte-enb] [template-lte-enb]
_update_hash_filename_ = instance-enb.jinja2.cfg _update_hash_filename_ = instance-enb.jinja2.cfg
...@@ -28,11 +28,11 @@ md5sum = c450b8c307d20738a98bcb4f6ffeee16 ...@@ -28,11 +28,11 @@ md5sum = c450b8c307d20738a98bcb4f6ffeee16
[template-lte-gnb-epc] [template-lte-gnb-epc]
_update_hash_filename_ = instance-gnb-epc.jinja2.cfg _update_hash_filename_ = instance-gnb-epc.jinja2.cfg
md5sum = 5f86177e7ef18a6046826f96397ded1d md5sum = 4b27f60eab8d71c2c47f21a845fddb47
[template-lte-epc] [template-lte-epc]
_update_hash_filename_ = instance-epc.jinja2.cfg _update_hash_filename_ = instance-epc.jinja2.cfg
md5sum = 2cfe5679374559ab94478b987d646d83 md5sum = b17674f523adce9b0dda942c1493674d
[template-lte-gnb] [template-lte-gnb]
_update_hash_filename_ = instance-gnb.jinja2.cfg _update_hash_filename_ = instance-gnb.jinja2.cfg
......
...@@ -51,7 +51,7 @@ config-monitor-password = ${monitor-htpasswd:passwd} ...@@ -51,7 +51,7 @@ config-monitor-password = ${monitor-htpasswd:passwd}
name = MME name = MME
software-type = mme software-type = mme
config-name = mme config-name = mme
{%- for key, value in slapparameter_dict.iteritems() %} {%- for key, value in slapparameter_dict.items() %}
config-{{ key }} = {{ dumps(value) }} config-{{ key }} = {{ dumps(value) }}
{% endfor -%} {% endfor -%}
config-slave-list = {{ dumps(slave_instance_list) }} config-slave-list = {{ dumps(slave_instance_list) }}
...@@ -62,7 +62,7 @@ return = monitor-base-url epc-ipv6 ...@@ -62,7 +62,7 @@ return = monitor-base-url epc-ipv6
name = eNB name = eNB
software-type = enb software-type = enb
config-name = enb config-name = enb
{%- for key, value in slapparameter_dict.iteritems() %} {%- for key, value in slapparameter_dict.items() %}
config-{{ key }} = {{ dumps(value) }} config-{{ key }} = {{ dumps(value) }}
{% endfor -%} {% endfor -%}
return = monitor-base-url return = monitor-base-url
......
...@@ -51,7 +51,7 @@ return = monitor-base-url epc-ipv6 ...@@ -51,7 +51,7 @@ return = monitor-base-url epc-ipv6
name = MME name = MME
software-type = mme software-type = mme
config-name = mme config-name = mme
{%- for key, value in slapparameter_dict.iteritems() %} {%- for key, value in slapparameter_dict.items() %}
config-{{ key }} = {{ dumps(value) }} config-{{ key }} = {{ dumps(value) }}
{% endfor -%} {% endfor -%}
config-slave-list = {{ dumps(slave_instance_list) }} config-slave-list = {{ dumps(slave_instance_list) }}
......
...@@ -51,7 +51,7 @@ config-monitor-password = ${monitor-htpasswd:passwd} ...@@ -51,7 +51,7 @@ config-monitor-password = ${monitor-htpasswd:passwd}
name = MME name = MME
software-type = mme software-type = mme
config-name = mme config-name = mme
{%- for key, value in slapparameter_dict.iteritems() %} {%- for key, value in slapparameter_dict.items() %}
config-{{ key }} = {{ dumps(value) }} config-{{ key }} = {{ dumps(value) }}
{% endfor -%} {% endfor -%}
config-slave-list = {{ dumps(slave_instance_list) }} config-slave-list = {{ dumps(slave_instance_list) }}
...@@ -62,7 +62,7 @@ return = monitor-base-url epc-ipv6 ...@@ -62,7 +62,7 @@ return = monitor-base-url epc-ipv6
name = gNB name = gNB
software-type = gnb software-type = gnb
config-name = gnb config-name = gnb
{%- for key, value in slapparameter_dict.iteritems() %} {%- for key, value in slapparameter_dict.items() %}
config-{{ key }} = {{ dumps(value) }} config-{{ key }} = {{ dumps(value) }}
{% endfor -%} {% endfor -%}
return = monitor-base-url return = monitor-base-url
......
...@@ -21,8 +21,6 @@ parts += ...@@ -21,8 +21,6 @@ parts +=
# apache-php # apache-php
# logrotate # logrotate
[python]
part = python2.7
[template] [template]
recipe = slapos.recipe.template recipe = slapos.recipe.template
......
...@@ -19,4 +19,4 @@ md5sum = 9b41238f67ea8e12f8ea9590fd552b33 ...@@ -19,4 +19,4 @@ md5sum = 9b41238f67ea8e12f8ea9590fd552b33
[template-selenium] [template-selenium]
filename = instance-selenium.cfg.in filename = instance-selenium.cfg.in
md5sum = 3e50d629307ca9f1381909102a52756d md5sum = 9b4742e8a249aef38c7c8c12d74b0605
...@@ -316,10 +316,10 @@ recipe = slapos.recipe.template ...@@ -316,10 +316,10 @@ recipe = slapos.recipe.template
output = $${directory:bin}/$${:_buildout_section_name_} output = $${directory:bin}/$${:_buildout_section_name_}
inline = inline =
#!${buildout:executable} #!${buildout:executable}
import json, urllib, sys import json, urllib.request, sys
api_url = sys.argv[1] api_url = sys.argv[1]
expected_node_count = int(sys.argv[2]) expected_node_count = int(sys.argv[2])
actual_node_count = json.load(urllib.urlopen(api_url))['slotCounts']['total'] actual_node_count = json.load(urllib.request.urlopen(api_url))['slotCounts']['total']
sys.exit(0 if expected_node_count == actual_node_count else 1) sys.exit(0 if expected_node_count == actual_node_count else 1)
......
...@@ -23,9 +23,6 @@ parts = ...@@ -23,9 +23,6 @@ parts =
collective.recipe.shelloutput collective.recipe.shelloutput
template template
[python]
part = python2.7
[collective.recipe.shelloutput] [collective.recipe.shelloutput]
recipe = zc.recipe.egg recipe = zc.recipe.egg
......
...@@ -31,12 +31,12 @@ import multiprocessing ...@@ -31,12 +31,12 @@ import multiprocessing
import os import os
import tempfile import tempfile
import unittest import unittest
import urlparse import urllib.parse
import base64 import base64
import hashlib import hashlib
import logging import logging
import contextlib import contextlib
from BaseHTTPServer import BaseHTTPRequestHandler from http.server import BaseHTTPRequestHandler
from io import BytesIO from io import BytesIO
...@@ -72,7 +72,7 @@ class WebServer(ManagedHTTPServer): ...@@ -72,7 +72,7 @@ class WebServer(ManagedHTTPServer):
self.send_response(200) self.send_response(200)
self.end_headers() self.end_headers()
self.wfile.write( self.wfile.write(
''' b'''
<html> <html>
<title>Test page</title> <title>Test page</title>
<body> <body>
...@@ -97,15 +97,15 @@ class WebServer(ManagedHTTPServer): ...@@ -97,15 +97,15 @@ class WebServer(ManagedHTTPServer):
self.send_response(200) self.send_response(200)
self.end_headers() self.end_headers()
file_data = 'no file' file_data = 'no file'
if form.has_key('f'): if 'f' in form:
file_data = form['f'].file.read() file_data = form['f'].file.read().decode()
self.wfile.write( self.wfile.write(
''' ('''
<html> <html>
<title>%s</title> <title>%s</title>
<div>%s</div> <div>%s</div>
</html> </html>
''' % (form['q'].value, file_data)) ''' % (form['q'].value, file_data)).encode())
log_message = logging.getLogger(__name__ + '.WebServer').info log_message = logging.getLogger(__name__ + '.WebServer').info
...@@ -148,7 +148,7 @@ class BrowserCompatibilityMixin(WebServerMixin): ...@@ -148,7 +148,7 @@ class BrowserCompatibilityMixin(WebServerMixin):
WebDriverWait(self.driver, 3).until(EC.title_is(self.id())) WebDriverWait(self.driver, 3).until(EC.title_is(self.id()))
def test_upload_file(self): def test_upload_file(self):
f = tempfile.NamedTemporaryFile(delete=False) f = tempfile.NamedTemporaryFile(delete=False, mode='w')
f.write(self.id()) f.write(self.id())
f.close() f.close()
self.addCleanup(lambda: os.remove(f.name)) self.addCleanup(lambda: os.remove(f.name))
...@@ -307,7 +307,7 @@ class TestFrontend(WebServerMixin, SeleniumServerTestCase): ...@@ -307,7 +307,7 @@ class TestFrontend(WebServerMixin, SeleniumServerTestCase):
parameter_dict = self.computer_partition.getConnectionParameterDict() parameter_dict = self.computer_partition.getConnectionParameterDict()
admin_url = parameter_dict['admin-url'] admin_url = parameter_dict['admin-url']
parsed = urlparse.urlparse(admin_url) parsed = urllib.parse.urlparse(admin_url)
self.assertEqual('admin', parsed.username) self.assertEqual('admin', parsed.username)
self.assertTrue(parsed.password) self.assertTrue(parsed.password)
...@@ -316,7 +316,7 @@ class TestFrontend(WebServerMixin, SeleniumServerTestCase): ...@@ -316,7 +316,7 @@ class TestFrontend(WebServerMixin, SeleniumServerTestCase):
def test_browser_use_hub(self): def test_browser_use_hub(self):
parameter_dict = self.computer_partition.getConnectionParameterDict() parameter_dict = self.computer_partition.getConnectionParameterDict()
webdriver_url = parameter_dict['url'] webdriver_url = parameter_dict['url']
parsed = urlparse.urlparse(webdriver_url) parsed = urllib.parse.urlparse(webdriver_url)
self.assertEqual('selenium', parsed.username) self.assertEqual('selenium', parsed.username)
self.assertTrue(parsed.password) self.assertTrue(parsed.password)
...@@ -343,7 +343,7 @@ class TestSSHServer(SeleniumServerTestCase): ...@@ -343,7 +343,7 @@ class TestSSHServer(SeleniumServerTestCase):
def test_connect(self): def test_connect(self):
parameter_dict = self.computer_partition.getConnectionParameterDict() parameter_dict = self.computer_partition.getConnectionParameterDict()
ssh_url = parameter_dict['ssh-url'] ssh_url = parameter_dict['ssh-url']
parsed = urlparse.urlparse(ssh_url) parsed = urllib.parse.urlparse(ssh_url)
self.assertEqual('ssh', parsed.scheme) self.assertEqual('ssh', parsed.scheme)
client = paramiko.SSHClient() client = paramiko.SSHClient()
...@@ -359,9 +359,9 @@ class TestSSHServer(SeleniumServerTestCase): ...@@ -359,9 +359,9 @@ class TestSSHServer(SeleniumServerTestCase):
with contextlib.closing(client): with contextlib.closing(client):
client.connect( client.connect(
username=urlparse.urlparse(ssh_url).username, username=urllib.parse.urlparse(ssh_url).username,
hostname=urlparse.urlparse(ssh_url).hostname, hostname=urllib.parse.urlparse(ssh_url).hostname,
port=urlparse.urlparse(ssh_url).port, port=urllib.parse.urlparse(ssh_url).port,
pkey=self.ssh_key, pkey=self.ssh_key,
) )
...@@ -378,7 +378,7 @@ class TestSSHServer(SeleniumServerTestCase): ...@@ -378,7 +378,7 @@ class TestSSHServer(SeleniumServerTestCase):
# Paramiko does not allow to get the fingerprint as SHA256 easily yet # Paramiko does not allow to get the fingerprint as SHA256 easily yet
# https://github.com/paramiko/paramiko/pull/1103 # https://github.com/paramiko/paramiko/pull/1103
self.assertEqual( self.assertEqual(
fingerprint, fingerprint.encode(),
# XXX with sha256, we need to remove that trailing = # XXX with sha256, we need to remove that trailing =
base64.b64encode( base64.b64encode(
hashlib.new(fingerprint_algorithm, hashlib.new(fingerprint_algorithm,
...@@ -386,15 +386,15 @@ class TestSSHServer(SeleniumServerTestCase): ...@@ -386,15 +386,15 @@ class TestSSHServer(SeleniumServerTestCase):
channel = client.invoke_shell() channel = client.invoke_shell()
channel.settimeout(30) channel.settimeout(30)
received = '' received = b''
while True: while True:
r = channel.recv(1024) r = channel.recv(1024)
if not r: if not r:
break break
received += r received += r
if 'Selenium Server.' in received: if b'Selenium Server.' in received:
break break
self.assertIn("Welcome to SlapOS Selenium Server.", received) self.assertIn(b"Welcome to SlapOS Selenium Server.", received)
class TestFirefox52( class TestFirefox52(
...@@ -405,8 +405,9 @@ class TestFirefox52( ...@@ -405,8 +405,9 @@ class TestFirefox52(
desired_capabilities = dict(DesiredCapabilities.FIREFOX, version='52.9.0esr') desired_capabilities = dict(DesiredCapabilities.FIREFOX, version='52.9.0esr')
user_agent = 'Gecko/20100101 Firefox/52.0' user_agent = 'Gecko/20100101 Firefox/52.0'
# resizing window is not supported on firefox 52 geckodriver # resizing window is not supported on firefox 52 geckodriver
test_resize_window = unittest.expectedFailure( @unittest.expectedFailure
BrowserCompatibilityMixin.test_resize_window) def test_resize_window(self):
super().test_resize_window()
class TestFirefox60( class TestFirefox60(
......
...@@ -16,18 +16,26 @@ extra = ...@@ -16,18 +16,26 @@ extra =
caddy-frontend ${slapos.test.caddy-frontend-setup:setup} caddy-frontend ${slapos.test.caddy-frontend-setup:setup}
erp5testnode ${slapos.test.erp5testnode-setup:setup} erp5testnode ${slapos.test.erp5testnode-setup:setup}
galene ${slapos.test.galene-setup:setup} galene ${slapos.test.galene-setup:setup}
grafana ${slapos.test.grafana-setup:setup}
headless-chromium ${slapos.test.headless-chromium-setup:setup} headless-chromium ${slapos.test.headless-chromium-setup:setup}
helloworld ${slapos.test.helloworld-setup:setup} helloworld ${slapos.test.helloworld-setup:setup}
html5as ${slapos.test.html5as-setup:setup}
html5as-base ${slapos.test.html5as-base-setup:setup}
hugo ${slapos.test.hugo-setup:setup} hugo ${slapos.test.hugo-setup:setup}
jstestnode ${slapos.test.jstestnode-setup:setup}
jupyter ${slapos.test.jupyter-setup:setup} jupyter ${slapos.test.jupyter-setup:setup}
kvm ${slapos.test.kvm-setup:setup} kvm ${slapos.test.kvm-setup:setup}
matomo ${slapos.test.matomo-setup:setup} matomo ${slapos.test.matomo-setup:setup}
metabase ${slapos.test.metabase-setup:setup}
monitor ${slapos.test.monitor-setup:setup} monitor ${slapos.test.monitor-setup:setup}
nextcloud ${slapos.test.nextcloud-setup:setup} nextcloud ${slapos.test.nextcloud-setup:setup}
nginx-push-stream ${slapos.test.nginx-push-stream-setup:setup} nginx-push-stream ${slapos.test.nginx-push-stream-setup:setup}
ors-amarisoft ${slapos.test.ors-amarisoft-setup:setup}
plantuml ${slapos.test.plantuml-setup:setup} plantuml ${slapos.test.plantuml-setup:setup}
powerdns ${slapos.test.powerdns-setup:setup} powerdns ${slapos.test.powerdns-setup:setup}
proftpd ${slapos.test.proftpd-setup:setup} proftpd ${slapos.test.proftpd-setup:setup}
repman ${slapos.test.repman-setup:setup} repman ${slapos.test.repman-setup:setup}
restic-rest-server ${slapos.test.restic_rest_server-setup:setup} restic-rest-server ${slapos.test.restic_rest_server-setup:setup}
seleniumserver ${slapos.test.seleniumserver-setup:setup}
theia ${slapos.test.theia-setup:setup} theia ${slapos.test.theia-setup:setup}
turnserver ${slapos.test.turnserver-setup:setup}
...@@ -359,8 +359,6 @@ tests = ...@@ -359,8 +359,6 @@ tests =
# here, to check there's no promise issue when slapos node runs with Python 2. # here, to check there's no promise issue when slapos node runs with Python 2.
erp5 ${slapos.test.erp5-setup:setup} erp5 ${slapos.test.erp5-setup:setup}
fluentd ${slapos.test.fluentd-setup:setup} fluentd ${slapos.test.fluentd-setup:setup}
metabase ${slapos.test.metabase-setup:setup}
ors-amarisoft ${slapos.test.ors-amarisoft-setup:setup}
### ###
${:extra} ${:extra}
...@@ -373,17 +371,11 @@ extra = ...@@ -373,17 +371,11 @@ extra =
cloudooo ${slapos.test.cloudooo-setup:setup} cloudooo ${slapos.test.cloudooo-setup:setup}
dream ${slapos.test.dream-setup:setup} dream ${slapos.test.dream-setup:setup}
gitlab ${slapos.test.gitlab-setup:setup} gitlab ${slapos.test.gitlab-setup:setup}
grafana ${slapos.test.grafana-setup:setup}
html5as ${slapos.test.html5as-setup:setup}
html5as-base ${slapos.test.html5as-base-setup:setup}
htmlvalidatorserver ${slapos.test.htmlvalidatorserver-setup:setup} htmlvalidatorserver ${slapos.test.htmlvalidatorserver-setup:setup}
jscrawler ${slapos.test.jscrawler-setup:setup} jscrawler ${slapos.test.jscrawler-setup:setup}
jstestnode ${slapos.test.jstestnode-setup:setup}
re6stnet ${slapos.test.re6stnet-setup:setup} re6stnet ${slapos.test.re6stnet-setup:setup}
seleniumserver ${slapos.test.seleniumserver-setup:setup}
slapos-master ${slapos.test.slapos-master-setup:setup} slapos-master ${slapos.test.slapos-master-setup:setup}
slaprunner ${slapos.test.slaprunner-setup:setup} slaprunner ${slapos.test.slaprunner-setup:setup}
turnserver ${slapos.test.turnserver-setup:setup}
upgrade_erp5 ${slapos.test.upgrade_erp5-setup:setup} upgrade_erp5 ${slapos.test.upgrade_erp5-setup:setup}
[versions] [versions]
......
...@@ -14,9 +14,6 @@ parts = ...@@ -14,9 +14,6 @@ parts =
coturn coturn
instance-cfg instance-cfg
[python]
part = python2.7
[download-base] [download-base]
recipe = slapos.recipe.build:download recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:filename} url = ${:_profile_base_location_}/${:filename}
......
...@@ -29,7 +29,7 @@ import os ...@@ -29,7 +29,7 @@ import os
import subprocess import subprocess
import json import json
import glob import glob
import ConfigParser import configparser
from slapos.recipe.librecipe import generateHashFromFiles from slapos.recipe.librecipe import generateHashFromFiles
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
...@@ -96,7 +96,7 @@ class TestServices(TurnServerTestCase): ...@@ -96,7 +96,7 @@ class TestServices(TurnServerTestCase):
secret_file = os.path.join(self.partition_path, 'etc/.turnsecret') secret_file = os.path.join(self.partition_path, 'etc/.turnsecret')
self.assertTrue(os.path.exists(self.partition_path)) self.assertTrue(os.path.exists(self.partition_path))
self.assertTrue(os.path.exists(secret_file)) self.assertTrue(os.path.exists(secret_file))
config = ConfigParser.ConfigParser() config = configparser.ConfigParser()
with open(secret_file) as f: with open(secret_file) as f:
config.readfp(f) config.readfp(f)
secret = config.get('turnserver', 'secret') secret = config.get('turnserver', 'secret')
...@@ -151,7 +151,7 @@ class TestParameters(TurnServerTestCase): ...@@ -151,7 +151,7 @@ class TestParameters(TurnServerTestCase):
secret_file = os.path.join(self.partition_path, 'etc/.turnsecret') secret_file = os.path.join(self.partition_path, 'etc/.turnsecret')
self.assertTrue(os.path.exists(self.partition_path)) self.assertTrue(os.path.exists(self.partition_path))
self.assertTrue(os.path.exists(secret_file)) self.assertTrue(os.path.exists(secret_file))
config = ConfigParser.ConfigParser() config = configparser.ConfigParser()
with open(secret_file) as f: with open(secret_file) as f:
config.readfp(f) config.readfp(f)
secret = config.get('turnserver', 'secret') secret = config.get('turnserver', 'secret')
......
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