Merge "Ensure that the zookeeper backend creates missing atoms"
This commit is contained in:
@@ -169,7 +169,11 @@ class ZkConnection(base.Connection):
|
|||||||
ad_data, _zstat = self._client.get(ad_path)
|
ad_data, _zstat = self._client.get(ad_path)
|
||||||
except k_exc.NoNodeError:
|
except k_exc.NoNodeError:
|
||||||
# Not-existent: create or raise exception.
|
# Not-existent: create or raise exception.
|
||||||
raise exc.NotFound("No atom details found with id: %s" % ad.uuid)
|
if not create_missing:
|
||||||
|
raise exc.NotFound("No atom details found with"
|
||||||
|
" id: %s" % ad.uuid)
|
||||||
|
else:
|
||||||
|
txn.create(ad_path)
|
||||||
else:
|
else:
|
||||||
# Existent: read it out.
|
# Existent: read it out.
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -25,7 +25,48 @@ from taskflow.types import failure
|
|||||||
|
|
||||||
class PersistenceTestMixin(object):
|
class PersistenceTestMixin(object):
|
||||||
def _get_connection(self):
|
def _get_connection(self):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError('_get_connection() implementation required')
|
||||||
|
|
||||||
|
def test_task_detail_update_not_existing(self):
|
||||||
|
lb_id = uuidutils.generate_uuid()
|
||||||
|
lb_name = 'lb-%s' % (lb_id)
|
||||||
|
lb = logbook.LogBook(name=lb_name, uuid=lb_id)
|
||||||
|
fd = logbook.FlowDetail('test', uuid=uuidutils.generate_uuid())
|
||||||
|
lb.add(fd)
|
||||||
|
td = logbook.TaskDetail("detail-1", uuid=uuidutils.generate_uuid())
|
||||||
|
fd.add(td)
|
||||||
|
with contextlib.closing(self._get_connection()) as conn:
|
||||||
|
conn.save_logbook(lb)
|
||||||
|
|
||||||
|
td2 = logbook.TaskDetail("detail-1", uuid=uuidutils.generate_uuid())
|
||||||
|
fd.add(td2)
|
||||||
|
with contextlib.closing(self._get_connection()) as conn:
|
||||||
|
conn.update_flow_details(fd)
|
||||||
|
|
||||||
|
with contextlib.closing(self._get_connection()) as conn:
|
||||||
|
lb2 = conn.get_logbook(lb.uuid)
|
||||||
|
fd2 = lb2.find(fd.uuid)
|
||||||
|
self.assertIsNotNone(fd2.find(td.uuid))
|
||||||
|
self.assertIsNotNone(fd2.find(td2.uuid))
|
||||||
|
|
||||||
|
def test_flow_detail_update_not_existing(self):
|
||||||
|
lb_id = uuidutils.generate_uuid()
|
||||||
|
lb_name = 'lb-%s' % (lb_id)
|
||||||
|
lb = logbook.LogBook(name=lb_name, uuid=lb_id)
|
||||||
|
fd = logbook.FlowDetail('test', uuid=uuidutils.generate_uuid())
|
||||||
|
lb.add(fd)
|
||||||
|
with contextlib.closing(self._get_connection()) as conn:
|
||||||
|
conn.save_logbook(lb)
|
||||||
|
|
||||||
|
fd2 = logbook.FlowDetail('test-2', uuid=uuidutils.generate_uuid())
|
||||||
|
lb.add(fd2)
|
||||||
|
with contextlib.closing(self._get_connection()) as conn:
|
||||||
|
conn.save_logbook(lb)
|
||||||
|
|
||||||
|
with contextlib.closing(self._get_connection()) as conn:
|
||||||
|
lb2 = conn.get_logbook(lb.uuid)
|
||||||
|
self.assertIsNotNone(lb2.find(fd.uuid))
|
||||||
|
self.assertIsNotNone(lb2.find(fd2.uuid))
|
||||||
|
|
||||||
def test_logbook_save_retrieve(self):
|
def test_logbook_save_retrieve(self):
|
||||||
lb_id = uuidutils.generate_uuid()
|
lb_id = uuidutils.generate_uuid()
|
||||||
|
|||||||
Reference in New Issue
Block a user