Commit c175a161 authored by Tristan Cavelier's avatar Tristan Cavelier

update tests and configurators to handle cloudooo url preferences

parent 7136e773
......@@ -12,11 +12,13 @@ for obj in portal.portal_catalog(path=["%%/%s" % i.replace("**", "%") for i in b
for document in portal.portal_catalog(portal_type=bt.getTemplatePortalTypeRoleList()):
document.updateLocalRolesOnSecurityGroups()
conversion_server_url = portal.portal_preferences.getPreferredDocumentConversionServerUrl()
conversion_server_hostname = portal.portal_preferences.getPreferredOoodocServerAddress()
conversion_server_port = portal.portal_preferences.getPreferredOoodocServerPortNumber()
for preference_id in ["default_configurator_preference", "default_configurator_system_preference"]:
preference = getattr(portal.portal_preferences, preference_id)
if preference.getPortalType() == "System Preference":
preference.setPreferredDocumentConversionServerUrl(conversion_server_url)
preference.setPreferredOoodocServerPortNumber(conversion_server_port)
preference.setPreferredOoodocServerAddress(conversion_server_hostname)
......
......@@ -191,6 +191,8 @@ class TestRunMyDocsConfiguratorWorkflowMixin(TestLiveConfiguratorWorkflowMixin):
conversion_dict['port'])
self.assertEqual(system_preference.getPreferredOoodocServerAddress(),
conversion_dict['hostname'])
self.assertEqual(system_preference.getPreferredDocumentConversionServerUrl(),
conversion_dict['url'])
def stepCheckUserPreferenceAfterInstallation(self, sequence=None, sequence_list=None, **kw):
""" Check System Preference"""
......
......@@ -380,6 +380,7 @@ class StandardConfigurationMixin(TestLiveConfiguratorWorkflowMixin):
# on Business Configuration
#self.assertEqual('localhost', preference_tool.getPreferredOoodocServerAddress())
#self.assertEqual(8011, preference_tool.getPreferredOoodocServerPortNumber())
#self.assertEqual('http://localhost:8011', preference_tool.getPreferredDocumentConversionServerUrl())
# accounting
self.assertEqual('group/my_group',
......
......@@ -18,6 +18,9 @@ default_site_preference.setPreferredHtmlStyleUnsavedFormWarning(False)
default_site_preference.setPreferredHtmlStyleDevelopperMode(None)
default_site_preference.setPreferredHtmlStyleAccessTab('1')
previous_conversion_server_url = portal.portal_preferences.getPreferredDocumentConversionServerUrl()
default_site_preference.setPreferredDocumentConversionServerUrl(previous_conversion_server_url)
previous_conversion_server_address = portal.portal_preferences.getPreferredOoodocServerAddress()
default_site_preference.setPreferredOoodocServerAddress(previous_conversion_server_address)
......
......@@ -217,6 +217,8 @@ class TestUNGConfiguratorWorkflowMixin(TestLiveConfiguratorWorkflowMixin):
conversion_dict['port'])
self.assertEqual(system_preference.getPreferredOoodocServerAddress(),
conversion_dict['hostname'])
self.assertEqual(system_preference.getPreferredDocumentConversionServerUrl(),
conversion_dict['url'])
def stepCheckUserPreferenceAfterInstallation(self, sequence=None, sequence_list=None, **kw):
""" Check System Preference"""
......
......@@ -27,4 +27,5 @@ if ung_system_preference is None:
title='UNG System Preference')
ung_system_preference.setPreferredOoodocServerAddress('localhost')
ung_system_preference.setPreferredOoodocServerPortNumber('8008')
ung_system_preference.setPreferredDocumentConversionServerUrl('http://localhost:8008')
ung_system_preference.enable()
portal = context.getPortalObject()
MARKER = (None, '',)
url = portal.portal_preferences.getPreferredDocumentConversionServerUrl()
address = portal.portal_preferences.getPreferredOoodocServerAddress()
port = portal.portal_preferences.getPreferredOoodocServerPortNumber()
# make sure cloudoo is available. this check is required ONLY due to
# unit test nature where a bt5 with a data content which is to be reindexed
# is installed BEFORE the real cloudoo is setup in preferences.
if address not in MARKER and port not in MARKER:
if url not in MARKER or (address not in MARKER and port not in MARKER):
for index_uid in range(len(uid)):
document_relative_url = getRelativeUrl[index_uid]
document = portal.restrictedTraverse(document_relative_url)
......
......@@ -76,6 +76,7 @@ class TestIngestion(ERP5TypeLiveTestCase):
portal_preferences = getToolByName(self.portal, 'portal_preferences')
default_pref = portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
default_pref.setPreferredDocumentFileNameRegularExpression(FILE_NAME_REGULAR_EXPRESSION)
......
......@@ -7,7 +7,7 @@ promise_url = portal.getPromiseParameter('external_service', 'cloudooo_url')
if promise_url is None:
return
url = "cloudooo://%s:%s/" % (portal_preferences.getPreferredOoodocServerAddress(), portal_preferences.getPreferredOoodocServerPortNumber())
url = portal_preferences.getPreferredDocumentConversionServerUrl()
active_result = ActiveResult()
......
......@@ -2,10 +2,6 @@ portal = context.getPortalObject()
portal_preferences = portal.portal_preferences
promise_url = portal.getPromiseParameter('external_service', 'cloudooo_url')
domain_port = promise_url.split('//')[1].split('/')[0]
port = domain_port.split(':')[-1]
domain = domain_port[:-(len(port)+1)]
system_preference = portal_preferences.getActiveSystemPreference()
if system_preference is None:
system_preference = portal_preferences.newContent(
......@@ -14,6 +10,5 @@ if system_preference is None:
system_preference.enable()
system_preference.edit(
preferred_ooodoc_server_address=domain,
preferred_ooodoc_server_port_number=port,
preferred_document_conversion_server_url=promise_url,
)
......@@ -5,6 +5,9 @@ subversion working copy paths and conversion server address.
It's not meant to be called by zelenium tests directly.
"""
if conversion_server_url is None and (conversion_server_address is None or conversion_server_port is None):
raise TypeError("argument conversion_server_url (or conversion_server_{address,port}) should not be None")
pref = getattr(context.portal_preferences, "erp5_ui_test_preference", None)
if pref is None:
pref = context.portal_preferences.newContent(id="erp5_ui_test_preference",
......@@ -23,6 +26,7 @@ if pref is None:
portal_type="System Preference",
priority=1)
pref.setPreferredDocumentConversionServerUrl(conversion_server_url)
pref.setPreferredOoodocServerAddress(conversion_server_hostname)
pref.setPreferredOoodocServerPortNumber(conversion_server_port)
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>working_copy_list, conversion_server_hostname, conversion_server_port</string> </value>
<value> <string>working_copy_list, conversion_server_hostname=None, conversion_server_port=None, conversion_server_url=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -453,6 +453,7 @@ class TestUNG(ERP5TypeTestCase):
portal_contributions = portal.portal_contributions
system_preference = portal_preferences.newContent(portal_type='System Preference')
conversion_dict = _getConversionServerDict()
system_preference.setPreferredDocumentConversionServerUrl(conversion_dict["url"])
system_preference.setPreferredOoodocServerAddress(conversion_dict["hostname"])
system_preference.setPreferredOoodocServerPortNumber(conversion_dict["port"])
system_preference.enable()
......
......@@ -374,6 +374,8 @@ class IntrospectionTool(LogMixin, BaseTool):
'getPreferredOoodocServerAddress')
collect_information_by_method(system_preference,
'getPreferredOoodocServerPortNumber')
collect_information_by_method(system_preference,
'getPreferredDocumentConversionServerUrl')
def collect_information_by_property(document, property_id):
key = "%s/%s" % (document.getId(), property_id)
......
......@@ -122,6 +122,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
def setDefaultSitePreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
if self.portal.portal_workflow.isTransitionPossible(default_pref, 'enable'):
......
......@@ -1019,6 +1019,7 @@ class TestCRMMailSend(BaseTestCRM):
# set preference
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
default_pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
......
......@@ -69,6 +69,7 @@ class TestERP5WebWithCRM(ERP5TypeTestCase):
else:
preference = preference_list[0]
conversion_dict = _getConversionServerDict()
preference.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
preference.setPreferredOoodocServerAddress(conversion_dict['hostname'])
preference.setPreferredOoodocServerPortNumber(conversion_dict['port'])
if self.portal.portal_workflow.isTransitionPossible(preference, 'enable'):
......
......@@ -153,6 +153,7 @@ class TestERP5WebWithDms(ERP5TypeTestCase, ZopeTestCase.Functional):
def setDefaultSitePreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
if self.portal.portal_workflow.isTransitionPossible(default_pref, 'enable'):
......
......@@ -95,6 +95,7 @@ class TestWebCrawler(ERP5TypeTestCase):
system_preference = portal_preferences.newContent(id=self.system_pref_id,
portal_type='System Preference')
conversion_dict = _getConversionServerDict()
system_preference.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
system_preference.\
setPreferredOoodocServerAddress(conversion_dict['hostname'])
system_preference.\
......
......@@ -131,6 +131,7 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
else:
preference = preference_list[0]
conversion_dict = _getConversionServerDict()
preference.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
preference.setPreferredOoodocServerAddress(conversion_dict['hostname'])
preference.setPreferredOoodocServerPortNumber(conversion_dict['port'])
if self.portal.portal_workflow.isTransitionPossible(preference, 'enable'):
......
......@@ -491,23 +491,23 @@ class TestPreferences(PropertySheetTestCase):
preference_tool = self.portal.portal_preferences
system_pref = preference_tool.newContent(
portal_type='System Preference',
preferred_ooodoc_server_address='127.0.0.1',
preferred_document_conversion_server_url='http://127.0.0.1',
priority=Priority.SITE)
# check not taken into account if not enabled
self.assertEqual(None,
preference_tool.getPreferredOoodocServerAddress())
self.assertEqual('localhost',
preference_tool.getPreferredOoodocServerAddress('localhost'))
preference_tool.getPreferredDocumentConversionServerUrl())
self.assertEqual('http://localhost',
preference_tool.getPreferredDocumentConversionServerUrl('http://localhost'))
self.assertEqual(default_large_image_height,
preference_tool.getPreferredLargeImageHeight())
# enable it and check preference is returned
self.portal.portal_workflow.doActionFor(system_pref, 'enable_action')
self.assertEqual(system_pref.getPreferenceState(), 'global')
self.tic()
self.assertEqual('127.0.0.1',
preference_tool.getPreferredOoodocServerAddress())
self.assertEqual('127.0.0.1',
preference_tool.getPreferredOoodocServerAddress('localhost'))
self.assertEqual('http://127.0.0.1',
preference_tool.getPreferredDocumentConversionServerUrl())
self.assertEqual('http://127.0.0.1',
preference_tool.getPreferredDocumentConversionServerUrl('http://localhost'))
self.assertEqual(default_large_image_height,
preference_tool.getPreferredLargeImageHeight())
# Default value passed by parameter has priority over the default in the
......@@ -523,12 +523,12 @@ class TestPreferences(PropertySheetTestCase):
# But they can see others
system_pref.view()
# check accessors works
system_pref.setPreferredOoodocServerAddress('1.2.3.4')
system_pref.setPreferredDocumentConversionServerUrl('http://1.2.3.4')
self.tic()
self.assertEqual('1.2.3.4',
preference_tool.getPreferredOoodocServerAddress())
self.assertEqual('1.2.3.4',
preference_tool.getPreferredOoodocServerAddress('localhost'))
self.assertEqual('http://1.2.3.4',
preference_tool.getPreferredDocumentConversionServerUrl())
self.assertEqual('http://1.2.3.4',
preference_tool.getPreferredDocumentConversionServerUrl('http://localhost'))
self.assertEqual(default_large_image_height,
preference_tool.getPreferredLargeImageHeight())
......@@ -541,15 +541,15 @@ class TestPreferences(PropertySheetTestCase):
self.portal.portal_workflow.doActionFor(user_pref, 'enable_action')
self.assertEqual(user_pref.getPreferenceState(), 'enabled')
self.tic()
self.assertEqual('1.2.3.4',
preference_tool.getPreferredOoodocServerAddress('localhost'))
self.assertEqual('http://1.2.3.4',
preference_tool.getPreferredDocumentConversionServerUrl('http://localhost'))
self.assertEqual(large_image_height,
preference_tool.getPreferredLargeImageHeight())
self.assertEqual(large_image_height,
preference_tool.getPreferredLargeImageHeight(0))
# check a user can't edit preference which are marked for manager
self.assertRaises(Unauthorized, user_pref.edit, preferred_ooodoc_server_address="localhost")
self.assertRaises(Unauthorized, user_pref.edit, preferred_document_conversion_server_url="http://localhost")
# even if there is System Preference enabled getActivePreference shall return
# user preference
self.assertEqual(user_pref, preference_tool.getActivePreference())
......
......@@ -50,6 +50,7 @@ class TestFormPrintoutMixin(ERP5TypeTestCase):
def setSystemPreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
#default_pref.setPreferredConversionCacheFactory('document_cache_factory')
......
......@@ -123,6 +123,7 @@ class TestDocumentMixin(ERP5TypeTestCase):
def setDefaultSitePreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
default_pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
......
......@@ -140,6 +140,7 @@ class TestIngestion(ERP5TypeTestCase):
def setSystemPreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
default_pref.setPreferredDocumentFilenameRegularExpression(FILENAME_REGULAR_EXPRESSION)
......@@ -1048,6 +1049,7 @@ class TestIngestion(ERP5TypeTestCase):
conversion_dict = _getConversionServerDict()
self.assertEqual(preference_tool.getPreferredOoodocServerAddress(), conversion_dict['hostname'])
self.assertEqual(preference_tool.getPreferredOoodocServerPortNumber(), conversion_dict['port'])
self.assertEqual(preference_tool.getPreferredDocumentConversionServerUrl(), conversion_dict['url'])
self.assertEqual(preference_tool.getPreferredDocumentFilenameRegularExpression(), FILENAME_REGULAR_EXPRESSION)
self.assertEqual(preference_tool.getPreferredDocumentReferenceRegularExpression(), REFERENCE_REGULAR_EXPRESSION)
......
......@@ -58,6 +58,7 @@ class TestOOoImportMixin(ERP5TypeTestCase):
self.pref = self.portal.portal_preferences.newContent(
portal_type='System Preference')
conversion_dict = _getConversionServerDict()
self.pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
self.pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
self.pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
self.pref.setPriority(Priority.SITE)
......
......@@ -89,6 +89,7 @@ class TestOOoStyle(ERP5TypeTestCase, ZopeTestCase.Functional):
def setDefaultSitePreference(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
if self.portal.portal_workflow.isTransitionPossible(default_pref, 'enable'):
......
......@@ -150,6 +150,7 @@ class TestERP5DocumentSyncMLMixin(TestERP5SyncMLMixin):
def setSystemPreferences(self):
default_pref = self.portal.portal_preferences.default_site_preference
conversion_dict = _getConversionServerDict()
default_pref.setPreferredDocumentConversionServerUrl(conversion_dict['url'])
default_pref.setPreferredOoodocServerAddress(conversion_dict['hostname'])
default_pref.setPreferredOoodocServerPortNumber(conversion_dict['port'])
default_pref.setPreferredDocumentFileNameRegularExpression(FILENAME_REGULAR_EXPRESSION)
......
......@@ -376,6 +376,7 @@ class ERP5TypeFunctionalTestCase(ERP5TypeTestCase):
conversion_dict = _getConversionServerDict()
self.portal.Zuite_setPreference(
working_copy_list=bt5_dir_list,
conversion_server_url=conversion_dict['url'],
conversion_server_hostname=conversion_dict['hostname'],
conversion_server_port=conversion_dict['port']
)
......
......@@ -127,13 +127,15 @@ def _getConnectionStringDict():
return connection_string_dict
def _getConversionServerDict():
""" Returns a dict with hostname and port for Conversion Server (Oood)
""" Returns a dict with url for Conversion Server (Oood)
"""
conversion_server_url = os.environ.get('conversion_server_url')
conversion_server_hostname = os.environ.get('conversion_server_hostname',
'localhost')
conversion_server_port = os.environ.get('conversion_server_port',
'8008')
return dict(hostname=conversion_server_hostname,
return dict(url=conversion_server_url,
hostname=conversion_server_hostname,
port=int(conversion_server_port))
def _getVolatileMemcachedServerDict():
......@@ -157,8 +159,7 @@ def _createTestPromiseConfigurationFile(promise_path, bt5_repository_path_list=N
_getVolatileMemcachedServerDict()
memcached_url = "memcached://%(hostname)s:%(port)s/" % \
_getPersistentMemcachedServerDict()
cloudooo_url = "cloudooo://%(hostname)s:%(port)s/" % \
_getConversionServerDict()
cloudooo_url = _getConversionServerDict()['url']
promise_config = ConfigParser.RawConfigParser()
promise_config.add_section('external_service')
......@@ -853,8 +854,7 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
conversion_dict = _getConversionServerDict()
preference = self.portal.portal_preferences[
self.getDefaultSitePreferenceId()]
preference._setPreferredOoodocServerAddress(conversion_dict['hostname'])
preference._setPreferredOoodocServerPortNumber(conversion_dict['port'])
preference._setPreferredDocumentConversionServerUrl(conversion_dict['url'])
def _updateMemcachedConfiguration(self):
"""Update default memcached plugin configuration
......
......@@ -281,15 +281,18 @@ user_pref("capability.principal.codebase.p1.subjectName", "");""" % \
return status
def setPreference(self):
conversion_server_url = os.environ.get('conversion_server_url', '')
conversion_server_hostname = os.environ.get('conversion_server_hostname',
'localhost')
conversion_server_port = os.environ.get('conversion_server_port', '8008')
urllib2.urlopen('%s/Zuite_setPreference?__ac_name='
'%s&__ac_password=%s&working_copy_list=%s'
'&conversion_server_url=%s'
'&conversion_server_hostname=%s'
'&conversion_server_port=%s'%
(self.portal_url, self.user, self.password,
bt5_dir_list, conversion_server_hostname,
bt5_dir_list, conversion_server_url,
conversion_server_hostname,
conversion_server_port))
......
......@@ -53,6 +53,7 @@ def main():
default=None)
parser.add_argument('--db_list', help='A list of sql connection strings')
# parameters that needs to be passed to runUnitTest
parser.add_argument('--conversion_server_url', default=None)
parser.add_argument('--conversion_server_hostname', default=None)
parser.add_argument('--conversion_server_port', default=None)
parser.add_argument('--volatile_memcached_server_hostname', default=None)
......
......@@ -99,14 +99,20 @@ Options:
for performance reasons. Provide list of documents
(delimited with comas) for which we want to force
indexing. This can only be for now 'portal_types'
--conversion_server_url=STRING
URL used to connect to document conversion server,
this value will stored at default preference.
Empty by default.
--conversion_server_hostname=STRING
Hostname used to connect to conversion server (Oood),
this value will stored at default preference.
By default localhost is used.
Ignored if --conversion_server_url is not empty.
By default localhost is used. DEPRECATED
--conversion_server_port=STRING
Port number used to connect to conversion server
(Oood), the value will be stored at default preference.
By default 8008 is used.
Ignored if --conversion_server_url is not empty.
By default 8008 is used. DEPRECATED
--volatile_memcached_server_hostname=STRING
Hostname used to connect to volatile memcached server,
this value will stored on portal_memcached.
......@@ -690,6 +696,7 @@ def main(argument_list=None):
"recreate_catalog=", "erp5_sql_connection_string=",
"cmf_activity_sql_connection_string=",
"extra_sql_connection_string_list=",
"conversion_server_url=",
"conversion_server_port=",
"conversion_server_hostname=",
"volatile_memcached_server_port=",
......@@ -790,6 +797,8 @@ def main(argument_list=None):
os.environ["update_business_templates"] = "1"
elif opt == "--update_business_templates":
os.environ["update_business_templates"] = "1"
elif opt == "--conversion_server_url":
os.environ["conversion_server_url"] = arg
elif opt == "--conversion_server_hostname":
os.environ["conversion_server_hostname"] = arg
elif opt == "--conversion_server_port":
......
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