Commit 1c492ab2 authored by Jérome Perrin's avatar Jérome Perrin

slapos-master/test: use slapos.testing

/reviewed-on nexedi/slapos!635
parent e1e605bd
Tests for ERP5 software release Tests for Slapos Master software release
...@@ -25,15 +25,24 @@ ...@@ -25,15 +25,24 @@
# #
############################################################################## ##############################################################################
import json
import os import os
import unittest
import logging
if os.environ.get('DEBUG'): from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
raise ValueError("Don't set DEBUG - it breaks postfix compilation - set SLAPOS_TEST_DEBUG instead.")
debug_mode = os.environ.get('SLAPOS_TEST_DEBUG') setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass(
# for development: debugging logs and install Ctrl+C handler os.path.abspath(
if debug_mode: os.path.join(os.path.dirname(__file__), '..', '..', 'software.cfg')))
logging.basicConfig(level=logging.DEBUG)
unittest.installHandler()
class ERP5InstanceTestCase(SlapOSInstanceTestCase):
"""ERP5 base test case
"""
# ERP5 instanciation needs to run several times before being ready, as
# the root instance request more instances.
instance_max_retry = 7 # XXX how many times ?
def getRootPartitionConnectionParameterDict(self):
"""Return the output paramters from the root partition"""
return json.loads(
self.computer_partition.getConnectionParameterDict()['_'])
...@@ -29,26 +29,15 @@ import os ...@@ -29,26 +29,15 @@ import os
import json import json
import glob import glob
import urlparse import urlparse
import logging import socket
import time import time
import psutil
import requests import requests
from utils import SlapOSInstanceTestCase from . import ERP5InstanceTestCase
from . import setUpModule
setUpModule # pyflakes
class ERP5TestCase(SlapOSInstanceTestCase):
"""Test the remote driver on a minimal web server.
"""
logger = logging.getLogger(__name__)
@classmethod
def getSoftwareURLList(cls):
return (os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'software.cfg')), )
def getRootPartitionConnectionParameterDict(self):
"""Return the output paramters from the root partition"""
return json.loads(
self.computer_partition.getConnectionParameterDict()['_'])
class TestPublishedURLIsReachableMixin(object): class TestPublishedURLIsReachableMixin(object):
...@@ -61,9 +50,10 @@ class TestPublishedURLIsReachableMixin(object): ...@@ -61,9 +50,10 @@ class TestPublishedURLIsReachableMixin(object):
# with 503 Service Unavailable. # with 503 Service Unavailable.
# If we can move the "create site" in slapos node instance, then this retry loop # If we can move the "create site" in slapos node instance, then this retry loop
# would not be necessary. # would not be necessary.
for i in range(1, 20): for i in range(1, 60):
r = requests.get(url, verify=False) # XXX can we get CA from caucase already ? r = requests.get(url, verify=False) # XXX can we get CA from caucase already ?
if r.status_code == requests.codes.service_unavailable: if r.status_code in (requests.codes.service_unavailable,
requests.codes.not_found):
delay = i * 2 delay = i * 2
self.logger.warn("ERP5 was not available, sleeping for %ds and retrying", delay) self.logger.warn("ERP5 was not available, sleeping for %ds and retrying", delay)
time.sleep(delay) time.sleep(delay)
...@@ -89,13 +79,13 @@ class TestPublishedURLIsReachableMixin(object): ...@@ -89,13 +79,13 @@ class TestPublishedURLIsReachableMixin(object):
urlparse.urljoin(param_dict['family-default'], param_dict['site-id'])) urlparse.urljoin(param_dict['family-default'], param_dict['site-id']))
class TestDefaultParameters(ERP5TestCase, TestPublishedURLIsReachableMixin): class TestDefaultParameters(ERP5InstanceTestCase, TestPublishedURLIsReachableMixin):
"""Test ERP5 can be instanciated with no parameters """Test ERP5 can be instanciated with no parameters
""" """
__partition_reference__ = 'defp' __partition_reference__ = 'defp'
class TestDisableTestRunner(ERP5TestCase, TestPublishedURLIsReachableMixin): class TestDisableTestRunner(ERP5InstanceTestCase, TestPublishedURLIsReachableMixin):
"""Test ERP5 can be instanciated without test runner. """Test ERP5 can be instanciated without test runner.
""" """
__partition_reference__ = 'distr' __partition_reference__ = 'distr'
......
This diff is collapsed.
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