In change I2b94945a0963d6a61af931505b69afe2d4733759 the exceptions that
placement uses were moved into the placement hierarchy and most of the
code that uses those exceptions was updated to reflect the change.
I86416e35da1798cdf039b42c9ed7629f0f9c75fc merged slightly before,
and had not made the change to the new style.
As the old aggregate handler had no exceptions imported, there was no
merge conflict when the exceptions change merged. At the same time
the exception in question is not covered by tests, because it only
happens if there is a concurrent update, which we don't cover in the
gabbi tests. We do cover a generation conflict on a supplied
generation, but that's not the same thing.
So basically this went by without us noticing and I happened to notice
while doing something else, so here's a fix for it.
To test it, a new directory for unit tests for handlers is added and
a new file, test_aggregate. Following the guidelines in https://docs.openstack.org/nova/latest/contributor/placement.html#testing
the problematic code has been extracted to its own private method so that
it can be tested as a unit with limited mocking. The overarching flow
of setting aggregates continues to be tested by the gabbi functional
tests.
Note the added NOTE in the new _set_aggregates method: It appears that
the DBDuplicateEntry exception maybe doesn't need to be there.
Reviewed: https:/ /review. openstack. org/558916 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=db6aa640623 d6dbd5730b6cab3 59d0b470cb2dd5
Committed: https:/
Submitter: Zuul
Branch: master
commit db6aa640623d6db d5730b6cab359d0 b470cb2dd5
Author: Chris Dent <email address hidden>
Date: Wed Apr 4 21:08:02 2018 +0100
[placement] Fix incorrect exception import
In change I2b94945a0963d6 a61af931505b69a fe2d4733759 the exceptions that
placement uses were moved into the placement hierarchy and most of the
code that uses those exceptions was updated to reflect the change.
I86416e35da 1798cdf039b42c9 ed7629f0f9c75fc merged slightly before,
and had not made the change to the new style.
As the old aggregate handler had no exceptions imported, there was no
merge conflict when the exceptions change merged. At the same time
the exception in question is not covered by tests, because it only
happens if there is a concurrent update, which we don't cover in the
gabbi tests. We do cover a generation conflict on a supplied
generation, but that's not the same thing.
So basically this went by without us noticing and I happened to notice
while doing something else, so here's a fix for it.
To test it, a new directory for unit tests for handlers is added and /docs.openstack .org/nova/ latest/ contributor/ placement. html#testing
a new file, test_aggregate. Following the guidelines in
https:/
the problematic code has been extracted to its own private method so that
it can be tested as a unit with limited mocking. The overarching flow
of setting aggregates continues to be tested by the gabbi functional
tests.
Note the added NOTE in the new _set_aggregates method: It appears that
the DBDuplicateEntry exception maybe doesn't need to be there.
Change-Id: I4b7b29270b2d99 00b59c7dd740826 88164430252
Closes-Bug: #1761295