Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions neutron/services/revisions/revision_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ def _get_objects_to_bump_revision(self, dirty_objects):
def bump_revisions(self, session, context, instances):
self._enforce_if_match_constraints(session)
# bump revision number for updated objects in the session
modified_objs = {o for o in session.dirty if session.is_modified(o)}
self._bump_obj_revisions(
session,
self._get_objects_to_bump_revision(session.dirty))
session, self._get_objects_to_bump_revision(modified_objs))

# see if any created/updated/deleted objects bump the revision
# of another object
objects_with_related_revisions = [
o for o in session.deleted | session.dirty | session.new
o for o in modified_objs | set(session.deleted) | set(session.new)
if getattr(o, 'revises_on_change', ())
]
collected = session.info.setdefault('_related_bumped', set())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ def test_constrained_port_update_handles_db_retries(self):
# update
with self.port() as port:
rev = port['port']['revision_number']
new = {'port': {'name': 'nigiri'}}

def concurrent_increment(s):
db_api.sqla_remove(se.Session, 'before_commit',
concurrent_increment)
# slip in a concurrent update that will bump the revision
plugin = directory.get_plugin()
new = {'port': {'name': 'nigiri'}}
plugin.update_port(nctx.get_admin_context(),
port['port']['id'], new)
raise db_exc.DBDeadlock()
Expand All @@ -160,13 +160,16 @@ def concurrent_increment(s):
# transaction, the revision number is tested only once the first
# time the revision number service is executed for this session and
# object.
new = {'port': {'name': 'sushi'}}
self._update('ports', port['port']['id'], new,
headers={'If-Match': 'revision_number=%s' % rev},
expected_code=exc.HTTPOk.code)
new = {'port': {'name': 'salmon'}}
self._update('ports', port['port']['id'], new,
headers={'If-Match': 'revision_number=%s' %
str(int(rev) + 2)},
expected_code=exc.HTTPOk.code)
new = {'port': {'name': 'tea'}}
self._update('ports', port['port']['id'], new,
headers={'If-Match': 'revision_number=1'},
expected_code=exc.HTTPPreconditionFailed.code)
Expand Down