Commit f4652d73 authored by Julien Muchembled's avatar Julien Muchembled

tests: update --neo_storage runUnit option for NEO 1.0

parent f231ac72
......@@ -91,32 +91,29 @@ class TestERP5(ERP5TypeTestCase):
return 'erp5_base', 'test_conflict_resolution'
def afterSetUp(self):
other_node = self.getOtherZEOClientNode()
other_node = self.getOtherZopeNode()
self.other_node = self.portal.portal_web_services.connect(
"http://%s%s" % (other_node, self.portal.getPath()),
'ERP5TypeTestCase', '', 'xml-rpc')
self.login()
def getOtherZEOClientNode(self):
from ZEO.ClientStorage import ClientStorage
storage = self.portal._p_jar._storage
def getOtherZopeNode(self):
activity_tool = self.portal.portal_activities
node_list = list(activity_tool.getProcessingNodeList())
node_list.remove(activity_tool.getCurrentNode())
assert node_list and isinstance(storage, ClientStorage), \
"this unit test must be run with at least 2 ZEO clients"
assert node_list, "this unit test must be run with at least 2 Zope nodes"
return node_list[0]
def testZODBCookie(self):
cookie_name = self._testMethodName
portal = self.portal
self.assertEqual(0, portal.getCacheCookie(cookie_name))
cookie = portal.getCacheCookie(cookie_name) # 0
self.commit()
portal.newCacheCookie(cookie_name) # 1
self.other_node.newCacheCookie(cookie_name) # 1
self.other_node.newCacheCookie(cookie_name) # 2
self.commit()# max(1, 2) + 1
self.assertEqual(3, portal.getCacheCookie(cookie_name))
self.assertEqual(cookie + 3, portal.getCacheCookie(cookie_name))
def testActiveProcess(self):
active_process = self.portal.portal_activities.newActiveProcess()
......
3
\ No newline at end of file
4
\ No newline at end of file
......@@ -82,7 +82,7 @@ if load:
if not live_instance_path:
backup_path = os.path.basename(backup_path)
os.symlink(backup_path, full_path)
elif save and not zeo_client and os.path.exists(data_fs_path):
elif save and not (neo_storage or zeo_client) and os.path.exists(data_fs_path):
os.remove(data_fs_path)
for static_dir in static_dir_list:
......@@ -126,16 +126,38 @@ def forkNodes():
cluster = True
if neo_storage:
if load or save or zeo_client:
raise Exception("--neo_storage conflicts with --load/save/zeo_client")
if zeo_client:
sys.exit("--neo_storage conflicts with --zeo_client")
demo_storage = load and not save
if activity_node > 1 and demo_storage:
sys.exit("--save is required when running several"
" zope nodes on an existing NEO database")
from neo.lib import logging
from neo.tests.functional import NEOCluster
neo_cluster = NEOCluster(range(2), partitions=4, adapter='BTree',
temp_dir=os.getcwd(), verbose=False)
logging.backlog()
storage_count = 2
if load or save:
db_list = [os.path.join(instance_home, 'var', 'neo%u.sqlite' % i)
for i in xrange(1, storage_count+1)]
else:
db_list = [None] * storage_count
cwd = os.getcwd()
neo_cluster = NEOCluster(db_list, partitions=4, name='erp5/unit_test',
temp_dir=cwd, logger=save,
adapter='SQLite', clear_databases=not load)
forkNodes()
if node_pid_list is None:
save_mysql = None
else:
cluster = bool(node_pid_list)
sigint = signal.signal(signal.SIGINT, signal.SIG_IGN)
try:
neo_cluster.start()
finally:
signal.signal(signal.SIGINT, sigint)
forkNodes()
Storage = neo_cluster.getZODBStorage()
Storage = neo_cluster.getZODBStorage(read_only=demo_storage)
if demo_storage:
Storage = DemoStorage(base=Storage)
else:
neo_cluster = None
while not zeo_client:
......
......@@ -138,8 +138,7 @@ Options:
Make ZServer listen on given host:port
If used with --activity_node=, this can be a
comma-separated list of addresses.
--neo_storage Use a volatile NEO storage instead of a DemoStorage
(not compatible with --save or --load).
--neo_storage Use a NEO storage (SQLite) instead of FileStorage.
--products_path=path,path Comma-separated list of products paths locations
which shall be used in test environment.
--sys_path=path,path Comma-separated list of paths which will be used to
......
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