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