Commit a88369fc authored by Rafael Monnerat's avatar Rafael Monnerat

Add test for Test upgrade from older versions of ERP5

parent a5da7be3
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2012 Vifib 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 testSlapOSMixin import testSlapOSMixin
import unittest
class TestUpgradeInstanceWithOldDataFs(testSlapOSMixin):
def afterSetUp(self):
# Do nothing as all work is done on the saved testSlapOSMixin already
# When save the data.fs
pass
def getBusinessTemplateList(self):
# we dont need bt5 as this test is supposed to run only as --load
return ['erp5_core']
def testUpgrade(self):
if not self.portal.portal_templates.getRepositoryList():
self.setupAutomaticBusinessTemplateRepository(
searchable_business_template_list=["erp5_core", "erp5_base",
"slapos_erp5", "erp5_slapos_tutorial"])
alarm = self.portal.portal_alarms.promise_check_upgrade
alarm.solve()
self.tic()
self.assertEquals(alarm.getLastActiveProcess().getResultList(), [])
bt5_list = self.portal.portal_templates.getInstalledBusinessTemplateTitleList()
self.assertTrue('slapos_erp5' in bt5_list, bt5_list)
# Make sure that *all* Portal Type can be loaded after upgrade
import erp5.portal_type
from Products.ERP5Type.dynamic.lazy_class import ERP5BaseBroken
error_list = []
for portal_type_obj in self.portal.portal_types.listTypeInfo():
portal_type_id = portal_type_obj.getId()
portal_type_class = getattr(erp5.portal_type, portal_type_id)
portal_type_class.loadClass()
if issubclass(portal_type_class, ERP5BaseBroken):
error_list.append(portal_type_id)
self.assertEquals(
error_list, [],
msg="The following Portal Type classes could not be loaded (see zLOG.log): %r" % error_list)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestUpgradeInstanceWithOldDataFs))
return suite
......@@ -60,6 +60,43 @@ class SlapOSCloud(SavedTestSuite, ProjectTestSuite):
test = ':' in full_test and full_test.split(':')[1] or full_test
if test.startswith('testFunctional'):
return self._updateFunctionalTestResponse(self.runUnitTest(full_test))
elif test == 'testSlapOSUpgradeInstanceWithOldDataFs':
old_data_path = None
for path in sys.path:
if path.endswith('/slapos-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='slapos-bin repository not found in %s' % '\n'.join(sys.path))
instance_home = (self.instance and 'unit_test.%u' % self.instance
or 'unit_test')
import shutil
shutil.rmtree(instance_home, ignore_errors=True)
os.makedirs(os.path.join(instance_home, 'var'))
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',
'--portal_id=erp5',
'--enable_full_indexing=portal_types,portal_property_sheets',
full_test)
return super(SlapOSCloud, self).run(full_test)
def _updateFunctionalTestResponse(self, status_dict):
......
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