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

test

parent e0118fd0
...@@ -35,13 +35,12 @@ from erp5.util.testnode.SlapOSControler import SlapOSControler ...@@ -35,13 +35,12 @@ from erp5.util.testnode.SlapOSControler import SlapOSControler
from erp5.util.testnode.ProcessManager import ProcessManager from erp5.util.testnode.ProcessManager import ProcessManager
import slapos import slapos
logger = logging.getLogger(__name__)
def findFreeTCPPort(ip=''): def findFreeTCPPort(ip=''):
"""Find a free TCP port to listen to. """Find a free TCP port to listen to.
inspired by https://stackoverflow.com/a/45690594
""" """
with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as s: family = socket.AF_INET6 if ':' in ip else socket.AF_INET
with closing(socket.socket(family, socket.SOCK_STREAM)) as s:
s.bind((ip, 0)) s.bind((ip, 0))
return s.getsockname()[1] return s.getsockname()[1]
...@@ -59,10 +58,13 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -59,10 +58,13 @@ class SlapOSInstanceTestCase(unittest.TestCase):
def getInstanceParmeterDict(cls): def getInstanceParmeterDict(cls):
"""Return instance parameters """Return instance parameters
To be defined by subclasses if needed To be defined by subclasses if they need to request instance with specific
parameters.
""" """
return {} return {}
# TODO: software type ?
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
...@@ -104,6 +106,7 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -104,6 +106,7 @@ class SlapOSInstanceTestCase(unittest.TestCase):
) )
slapproxy_log = os.path.join(config['log_directory'], 'slapproxy.log') slapproxy_log = os.path.join(config['log_directory'], 'slapproxy.log')
logger = logging.getLogger(__name__)
logger.debug('Configured slapproxy log to %r', slapproxy_log) logger.debug('Configured slapproxy log to %r', slapproxy_log)
software_url_list = cls.getSoftwareURLList() software_url_list = cls.getSoftwareURLList()
...@@ -151,6 +154,6 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -151,6 +154,6 @@ class SlapOSInstanceTestCase(unittest.TestCase):
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
print "Teardown", cls
# FIXME: if setUpClass fail, this is not called and leaks zombie processes # FIXME: if setUpClass fail, this is not called and leaks zombie processes
cls._process_manager.killPreviousRun() cls._process_manager.killPreviousRun()
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