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

Fixes for ProFTPd test suite

!311 was merged a bit too fast. After test suite was repaired ( the test node was stuck updating the git repository ), [test](https://nexedi.erp5.net/test_result_module/20180507-19395E1F/2) was not passing on testnode, because path was too deep.

While debugging this, I realized this check was wrong, because supervisor [also append the pid](https://github.com/Supervisor/supervisor/blob/70720a0311d868fbf58a31cd26a7147921dcff29/supervisor/http.py#L564-L574) to this path, so the path is even longer. I just checked that we have room for 7 digit pids.

Because path was too long on test node, test now run with `SLAPOS_TEST_WORKING_DIR` set to a slightly shorter path that's enough for this case.

There are some other minor fixes, see individual commits.

/cc @Nicolas @luke @rafael 

/reviewed-on nexedi/slapos!325
parents 47c58642 778cc621
...@@ -15,6 +15,6 @@ ...@@ -15,6 +15,6 @@
# not need these here). # not need these here).
[template] [template]
filename = instance.cfg filename = instance.cfg.in
md5sum = 9b4cc727c43d0daaec5b01cf4b9f7a15 md5sum = 20c5afac025e97c2937852f4d84f7cd3
...@@ -25,6 +25,7 @@ repository = ${slapos-repository:location} ...@@ -25,6 +25,7 @@ repository = ${slapos-repository:location}
[create-directory] [create-directory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
bin = $${buildout:directory}/bin bin = $${buildout:directory}/bin
working-dir = $${buildout:directory}/tmp/
[slapos-test-runner] [slapos-test-runner]
recipe = slapos.cookbook:wrapper recipe = slapos.cookbook:wrapper
...@@ -40,3 +41,4 @@ environment = ...@@ -40,3 +41,4 @@ environment =
PATH=${buildout:bin-directory}:/usr/bin/:/bin/ PATH=${buildout:bin-directory}:/usr/bin/:/bin/
LOCAL_IPV4=$${slap-configuration:ipv4-random} LOCAL_IPV4=$${slap-configuration:ipv4-random}
GLOBAL_IPV6=$${slap-configuration:ipv6-random} GLOBAL_IPV6=$${slap-configuration:ipv6-random}
SLAPOS_TEST_WORKING_DIR=$${create-directory:working-dir}
...@@ -67,3 +67,7 @@ mode = 640 ...@@ -67,3 +67,7 @@ mode = 640
slapos.test.proftpd = slapos.test.proftpd =
erp5.util = erp5.util =
#erp5.util = 0.4.51 #erp5.util = 0.4.51
pyasn1 = 0.4.2
slapos.recipe.template = 4.3
pysftp = 0.2.9
...@@ -68,7 +68,14 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -68,7 +68,14 @@ class SlapOSInstanceTestCase(unittest.TestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
try:
cls._setUpClass()
except:
cls.stopSlapOSProcesses()
raise
@classmethod
def _setUpClass(cls):
working_directory = os.environ.get( working_directory = os.environ.get(
'SLAPOS_TEST_WORKING_DIR', 'SLAPOS_TEST_WORKING_DIR',
os.path.join(os.path.dirname(__file__), '.slapos')) os.path.join(os.path.dirname(__file__), '.slapos'))
...@@ -76,8 +83,11 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -76,8 +83,11 @@ class SlapOSInstanceTestCase(unittest.TestCase):
# AF_UNIX path too long This `working_directory` should not be too deep. # AF_UNIX path too long This `working_directory` should not be too deep.
# Socket path is 108 char max on linux # Socket path is 108 char max on linux
# https://github.com/torvalds/linux/blob/3848ec5/net/unix/af_unix.c#L234-L238 # https://github.com/torvalds/linux/blob/3848ec5/net/unix/af_unix.c#L234-L238
if len(working_directory + '/inst/supervisord.socket') > 108: # Supervisord socket name contains the pid number, which is why we add
raise RuntimeError('working directory too deep, try setting SLAPOS_TEST_WORKING_DIR') # .xxxxxxx in this check.
if len(working_directory + '/inst/supervisord.socket.xxxxxxx') > 108:
raise RuntimeError('working directory ( {} ) is too deep, try setting '
'SLAPOS_TEST_WORKING_DIR'.format(working_directory))
if not os.path.exists(working_directory): if not os.path.exists(working_directory):
os.mkdir(working_directory) os.mkdir(working_directory)
...@@ -128,7 +138,7 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -128,7 +138,7 @@ class SlapOSInstanceTestCase(unittest.TestCase):
# TODO: log more details in this case # TODO: log more details in this case
assert software_status_dict['status_code'] == 0 assert software_status_dict['status_code'] == 0
instance_parameter_dict = cls.getInstanceParmeterDict() instance_parameter_dict = cls.getInstanceParameterDict()
instance_status_dict = slapos_controler.runComputerPartition( instance_status_dict = slapos_controler.runComputerPartition(
config, config,
cluster_configuration=instance_parameter_dict, cluster_configuration=instance_parameter_dict,
...@@ -147,7 +157,7 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -147,7 +157,7 @@ class SlapOSInstanceTestCase(unittest.TestCase):
partition_parameter_kw=instance_parameter_dict)) partition_parameter_kw=instance_parameter_dict))
# expose some class attributes so that tests can use them: # expose some class attributes so that tests can use them:
# the ComputerPartition instances, to getInstanceParmeterDict # the ComputerPartition instances, to getInstanceParameterDict
cls.computer_partition = computer_partition_list[0] cls.computer_partition = computer_partition_list[0]
# the path of the instance on the filesystem, for low level inspection # the path of the instance on the filesystem, for low level inspection
...@@ -158,7 +168,10 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -158,7 +168,10 @@ class SlapOSInstanceTestCase(unittest.TestCase):
@classmethod @classmethod
def tearDownClass(cls): def stopSlapOSProcesses(cls):
# FIXME: if setUpClass fail, this is not called and leaks zombie processes if hasattr(cls, '_process_manager'):
cls._process_manager.killPreviousRun() cls._process_manager.killPreviousRun()
@classmethod
def tearDownClass(cls):
cls.stopSlapOSProcesses()
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