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

erp5/test: another workaround for too deep paths

parent cd36f15a
...@@ -92,11 +92,13 @@ class TestPublishedURLIsReachableMixin(object): ...@@ -92,11 +92,13 @@ class TestPublishedURLIsReachableMixin(object):
class TestDefaultParameters(ERP5TestCase, TestPublishedURLIsReachableMixin): class TestDefaultParameters(ERP5TestCase, TestPublishedURLIsReachableMixin):
"""Test ERP5 can be instanciated with no parameters """Test ERP5 can be instanciated with no parameters
""" """
__partition_reference__ = 'defp'
class TestDisableTestRunner(ERP5TestCase, TestPublishedURLIsReachableMixin): class TestDisableTestRunner(ERP5TestCase, TestPublishedURLIsReachableMixin):
"""Test ERP5 can be instanciated without test runner. """Test ERP5 can be instanciated without test runner.
""" """
__partition_reference__ = 'distr'
@classmethod @classmethod
def getInstanceParameterDict(cls): def getInstanceParameterDict(cls):
return {'_': json.dumps({'test-runner': {'enabled': False}})} return {'_': json.dumps({'test-runner': {'enabled': False}})}
......
...@@ -61,15 +61,25 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -61,15 +61,25 @@ class SlapOSInstanceTestCase(unittest.TestCase):
on the class. on the class.
All tests from the test class will run with the same instance. All tests from the test class will run with the same instance.
The following class attributes are available: The following class attributes are available:
* `computer_partition`: the `slapos.core.XXX` computer partition instance. * `computer_partition`: the `slapos.core.XXX` computer partition instance.
* `computer_partition_root_path`: the path of the instance root directory, * `computer_partition_root_path`: the path of the instance root directory,
A note about paths:
SlapOS itself and some services running in SlapOS uses unix sockets and (sometimes very)
deep path, which does not play very well together. To workaround this, users can
set SLAPOS_TEST_WORKING_DIR enivonment variable to the path of a short enough directory
and local slapos will be in this directory.
The partitions references will be named after the unittest class name, which can also lead
to long paths. For this, unit test classes can define a __partition_reference__ attribute
which will be used as partition reference. The trick is then to use a shorter
__partition_reference__
See https://lab.nexedi.com/kirr/slapns for the solution to all these problems.
""" """
# Methods to be defined by subclasses. # Methods to be defined by subclasses.
@classmethod @classmethod
def getSoftwareURLList(cls): def getSoftwareURLList(cls):
...@@ -182,7 +192,7 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -182,7 +192,7 @@ class SlapOSInstanceTestCase(unittest.TestCase):
"log_directory": cls.working_directory, "log_directory": cls.working_directory,
"computer_id": 'slapos.test', # XXX "computer_id": 'slapos.test', # XXX
'proxy_database': os.path.join(cls.working_directory, 'proxy.db'), 'proxy_database': os.path.join(cls.working_directory, 'proxy.db'),
'partition_reference': cls.__name__, 'partition_reference': getattr(cls, '__partition_reference__', cls.__name__),
# "proper" slapos command must be in $PATH # "proper" slapos command must be in $PATH
'slapos_binary': 'slapos', 'slapos_binary': 'slapos',
} }
......
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