Commit 2b0cae53 authored by Arnaud Fontaine's avatar Arnaud Fontaine

testUpgradeInstanceWithOldDataFs: New Unit Test to check upgrade of old...

testUpgradeInstanceWithOldDataFs: New Unit Test to check upgrade of old instance to current ERP5 version.

After copying old instance ZODB and SQL from erp5-bin.git, this checks whether
instance can be successfully through upgrader. Introduced because of 140be41d.
parent cc9869aa
##############################################################################
#
# Copyright (c) 2020 Nexedi SA and Contributors. All Rights Reserved.
# Arnaud Fontaine <arnaud.fontaine@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability 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
# garantees 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class TestUpgradeInstanceWithOldDataFs(ERP5TypeTestCase):
def getBusinessTemplateList(self):
return ('erp5_core_proxy_field_legacy',
'erp5_full_text_mroonga_catalog',
'erp5_base',
'erp5_workflow',
'erp5_accounting',
'erp5_configurator',
'erp5_simulation',
'erp5_pdm',
'erp5_trade',
'erp5_accounting',
'erp5_configurator_standard_trade_template',
'erp5_upgrader')
def testUpgrade(self):
if not self.portal.portal_templates.getRepositoryList():
self.setupAutomaticBusinessTemplateRepository(
searchable_business_template_list=["erp5_core", "erp5_base"])
from Products.ERP5Type.tests.utils import createZODBPythonScript
createZODBPythonScript(
self.portal.portal_skins.custom,
'Base_getUpgradeBusinessTemplateList',
'',
"""return (('erp5_base',
'erp5_configurator_standard_trade_template',
'erp5_configurator_standard',
'erp5_jquery',
'erp5_xhtml_style'),
['erp5_upgrader'])""")
self.tic()
alarm = self.portal.portal_alarms.promise_check_upgrade
alarm.solve()
self.tic()
self.assertEquals(alarm.getLastActiveProcess().getResultList(), [])
......@@ -100,8 +100,40 @@ class ERP5(_ERP5):
if not status_dict['status_code']:
status_dict = self.runUnitTest('--load', '--activity_node=2', full_test)
return status_dict
if test.startswith('testFunctional'):
elif test.startswith('testFunctional'):
return self._updateFunctionalTestResponse(self.runUnitTest(full_test))
elif test == 'testUpgradeInstanceWithOldDataFs':
old_data_path = None
for path in sys.path:
if path.endswith('/erp5-bin'):
old_data_path = os.path.join(path, 'test_data', test)
if not os.path.isdir(old_data_path):
return dict(
status_code=-1,
test_count=1,
failure_count=1,
stderr='%s does not exist or is not a directory' % old_data_path)
break
else:
return dict(
status_code=-1,
test_count=1,
failure_count=1,
stderr='erp5-bin repository not found in %s' % '\n'.join(sys.path))
instance_home = (self.instance and 'unit_test.%u' % self.instance
or 'unit_test')
os.makedirs(os.path.join(instance_home, 'var'))
import shutil
shutil.copyfile(os.path.join(old_data_path, 'Data.fs'),
os.path.join(instance_home, 'var', 'Data.fs'))
shutil.copyfile(os.path.join(old_data_path, 'dump.sql'),
os.path.join(instance_home, 'dump.sql'))
return self.runUnitTest('--load', full_test)
return super(ERP5, self).run(full_test)
def _updateFunctionalTestResponse(self, status_dict):
......@@ -192,4 +224,3 @@ class ERP5BusinessTemplateCodingStyleTestSuite(_ERP5):
def run(self, full_test):
return self.runUnitTest('CodingStyleTest', TESTED_BUSINESS_TEMPLATE=full_test)
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