1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
##############################################################################
#
# Copyright (c) 2002-2018 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from erp5.component.test.testDms import makeFileUpload
from Products.ERP5Form.PreferenceTool import Priority
class TestOOoConversionServerRetry(ERP5TypeTestCase):
def getBusinessTemplateList(self):
business_template_list = ['erp5_core_proxy_field_legacy',
'erp5_jquery',
'erp5_full_text_mroonga_catalog',
'erp5_base',
'erp5_ingestion_mysql_innodb_catalog',
'erp5_ingestion',
'erp5_web',
'erp5_dms']
return business_template_list
def clearDocumentModule(self):
self.abort()
doc_module = self.portal.document_module
doc_module.manage_delObjects(list(doc_module.objectIds()))
self.tic()
def beforeTearDown(self):
self.abort()
activity_tool = self.portal.portal_activities
activity_status = {m.processing_node < -1
for m in activity_tool.getMessageList()}
if True in activity_status:
activity_tool.manageClearActivities()
self.clearDocumentModule()
def afterSetUp(self):
self.portal.portal_caches.clearAllCache()
self.retry_count = 2
def getDefaultSystemPreference(self):
id_ = 'default_system_preference'
tool = self.getPreferenceTool()
try:
pref = tool[id_]
except KeyError:
pref = tool.newContent(id_, 'System Preference')
pref.setPriority(Priority.SITE)
pref.enable()
return pref
def test_01_no_retry_for_no_network_issue(self):
system_pref = self.getDefaultSystemPreference()
system_pref.setPreferredDocumentConversionServerRetry(self.retry_count)
self.tic()
filename = 'monochrome_sample.tiff'
file_ = makeFileUpload(filename)
document = self.portal.document_module.newContent(portal_type='Text')
document.edit(file = file_)
message = document.Document_tryToConvertToBaseFormat()
self.assertEqual(message.count('Error converting document to base format'), 1)
def test_02_retry_for_network_issue(self):
system_pref = self.getDefaultSystemPreference()
saved_server_list = system_pref.getPreferredDocumentConversionServerUrlList()
system_pref.setPreferredDocumentConversionServerRetry(self.retry_count)
system_pref.setPreferredDocumentConversionServerUrlList(['https://broken.url'])
self.tic()
filename = 'TEST-en-002.doc'
file_ = makeFileUpload(filename)
document = self.portal.portal_contributions.newContent(file=file_)
message = document.Document_tryToConvertToBaseFormat()
self.assertEqual(message.count('broken.url: Connection refused'), self.retry_count + 1)
system_pref.setPreferredDocumentConversionServerUrlList(saved_server_list)
self.commit()
def test_03_retry_for_socket_issue(self):
system_pref = self.getDefaultSystemPreference()
server_list = system_pref.getPreferredDocumentConversionServerUrlList()
system_pref.setPreferredDocumentConversionServerRetry(self.retry_count)
system_pref.setPreferredOoodocServerTimeout(1)
self.tic()
filename = 'TEST-en-002.doc'
file_ = makeFileUpload(filename)
document = self.portal.portal_contributions.newContent(file=file_)
message = document.Document_tryToConvertToBaseFormat()
if 'Socket Error: SSLError' in message:
self.assertEqual(message.count('Socket Error: SSLError'), (self.retry_count + 1) * len(server_list))