Commit f054122a authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_configurator: Fix/Update Configurator test to check Constraints.

parent e02b451e
......@@ -11,60 +11,40 @@ import os
class TestSlapOSConfigurator(testSlapOSMixin):
def _testConfiguredPromiseViaAlarm(self, alarm_id):
"""
Make sue one alarm is configured.
"""
alarm = getattr(self.portal.portal_alarms, alarm_id, None)
self.assertNotEquals(alarm, None)
alarm.activeSense()
self.tic()
self.failIf(alarm.sense())
def testConfiguredPAS(self):
""" Make sure PAS is well configured, in this case
we trust on promise outcome."""
self._testConfiguredPromiseViaAlarm("promise_slapos_pas")
def testConfiguredPASExternal(self):
""" Make sure External PAS (Facebook, Google, Browser ID)
is well configured, in this case we trust on promise outcome."""
self._testConfiguredPromiseViaAlarm("promise_slapos_pas_external")
def testConfiguredModuleGeneratorID(self):
def testConfiguredModuleGeneratorIDViaConstraint(self):
""" Make sure Generator ID is well configured, in this
case we trust on promise outcome."""
self._testConfiguredPromiseViaAlarm("promise_slapos_module_id_generator")
self.assertEquals(self.portal.portal_ids.checkConsistency(), [])
def testConfiguredShacacheWebSite(self):
""" Make sure Shacache WebSite is setuped by Alarm
case we trust on promise outcome."""
self._testConfiguredPromiseViaAlarm("promise_slapos_shacache_website")
def testConfiguredVolatileCacheViaPromise(self):
""" Make sure Volitile Cache was configured well,
invoking the alarm to check """
self._testConfiguredPromiseViaAlarm("promise_memcached_server")
self.assertEquals(self.portal.web_site_module.checkConsistency(), [])
def testConfiguredPersistentCacheViaPromise(self):
""" Make sure Persistent Cache was configured well,
invoking the alarm to check """
self._testConfiguredPromiseViaAlarm("promise_kumofs_server")
def testConfiguredCacheViaConstraint(self):
""" Make sure Volitile and Persistent Cache was configured well,
invoking the consistency to check """
self.assertEquals(self.portal.portal_memcached.checkConsistency(), [])
def testConfiguredConversionServerViaPromise(self):
def testConfiguredConversionServerViaConstraint(self):
""" Make sure Conversion Server was configured well,
invoking the alarm to check """
self._testConfiguredPromiseViaAlarm("promise_conversion_server")
invoking checkConsistency """
self.assertEquals(self.portal.portal_preferences.checkConsistency(), [])
def testConfiguredCertificateAuthoringViaPromise(self):
def testConfiguredCertificateAuthoringConstraint(self):
"""Make sure Certificate Authoring was configured well,
invoking the alarm to check. """
self._testConfiguredPromiseViaAlarm("promise_certificate_autority_tool")
invoking checkConsistency.
def testConfiguredTemplateToolViaPromise(self):
Make sure PAS is well configured."""
self.assertEquals(self.portal.portal_certificate_authority.checkConsistency(), [])
def testConfiguredTemplateToolViaConstraint(self):
""" Make sure Template Tool Repositories was configured well,
invoking the alarm to check """
self._testConfiguredPromiseViaAlarm("promise_template_tool_configuration")
invoking checkConsistency """
self.assertEquals(
[ i for i in self.portal.portal_templates.checkConsistency()
if "(reinstall)" not in i.message], [])
def testConfiguredVolatileCache(self):
""" Make sure Memcached is configured
......@@ -79,7 +59,7 @@ class TestSlapOSConfigurator(testSlapOSMixin):
memcached_tool = self.getPortal().portal_memcached
connection_dict = _getVolatileMemcachedServerDict()
url_string = '%(hostname)s:%(port)s' % connection_dict
url_string = 'erp5-memcached-volatile:%(port)s' % connection_dict
self.assertEquals(memcached_tool.default_memcached_plugin.getUrlString(),
url_string)
......@@ -96,7 +76,7 @@ class TestSlapOSConfigurator(testSlapOSMixin):
_getPersistentMemcachedServerDict
memcached_tool = self.getPortal().portal_memcached
connection_dict = _getPersistentMemcachedServerDict()
url_string = '%(hostname)s:%(port)s' % connection_dict
url_string = 'erp5-memcached-persistent:%(port)s' % connection_dict
self.assertEquals(memcached_tool.persistent_memcached_plugin.getUrlString(),
url_string)
......@@ -104,18 +84,17 @@ class TestSlapOSConfigurator(testSlapOSMixin):
""" Make sure Conversion Server (Cloudooo) is
well configured """
if self.isLiveTest():
# This test is redundant with testConfiguredVolatileCacheViaPromise
# This test is redundant with testConfiguredConversionServerViaConstraint
# and it is only aims to verify if test environment is behaving as
# expected, nothing else, and if alamrs were invoked.
return
from Products.ERP5Type.tests.ERP5TypeTestCase import\
_getConversionServerDict
_getConversionServerUrl
# set preference
preference_tool = self.portal.portal_preferences
conversion_dict = _getConversionServerDict()
self.assertEquals(preference_tool.getPreferredOoodocServerAddress(),conversion_dict['hostname'])
self.assertEquals(preference_tool.getPreferredOoodocServerPortNumber(), conversion_dict['port'])
conversion_url = _getConversionServerUrl()
self.assertEquals(preference_tool.getPreferredDocumentConversionServerUrl(), conversion_url)
def testConfiguredCertificateAuthoring(self):
""" Make sure Certificate Authoting is
......
......@@ -39,6 +39,9 @@ from functools import wraps
from Products.ERP5Type.tests.utils import createZODBPythonScript
from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager
from App.config import getConfiguration
config = getConfiguration()
def changeSkin(skin_name):
def decorator(func):
......@@ -190,18 +193,25 @@ class testSlapOSMixin(ERP5TypeTestCase):
self.portal.portal_caches._p_changed = 1
self.commit()
self.portal.portal_caches.updateCache()
if getattr(self.portal, 'is_site_bootstrapped', 0):
for alarm in self.portal.portal_alarms.contentValues():
if alarm.getId().startswith("promise_slapos"):
alarm.solve()
return
else:
try:
initsite = config.product_config["initsite"]
except KeyError:
initsite = {}
if initsite.get("cloudooo_url", None) is None:
from Products.ERP5Type.tests.ERP5TypeTestCase import\
_getConversionServerUrl
initsite["cloudooo_url"] = _getConversionServerUrl()
config.product_config["initsite"] = initsite
if not getattr(self.portal, 'is_site_bootstrapped', 0):
self.portal.is_site_bootstrapped = 1
self.bootstrapSite()
self.portal._p_changed = 1
self.commit()
def deSetUpPersistentDummyMailHost(self):
if 'MailHost' in self.portal.objectIds():
self.portal.manage_delObjects(['MailHost'])
......@@ -237,6 +247,8 @@ class testSlapOSMixin(ERP5TypeTestCase):
def bootstrapSite(self):
self.setupPortalAlarms()
self.createCertificateAuthorityFile()
self.getDefaultSystemPreference().setPreferredHateoasUrl("http://dummy/")
self.getBusinessConfiguration().BusinessConfiguration_invokeSlapOSMasterPromiseAlarmList()
self.clearCache()
self.tic()
......
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