summaryrefslogtreecommitdiff
path: root/nova
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-04-26 21:28:58 +0000
committerGerrit Code Review <review@openstack.org>2017-04-26 21:28:58 +0000
commitcf5b369e1cab6905cd68627f57e30d61e2820dbf (patch)
tree3c17657b77e8233234c5f578976abbd509563deb /nova
parent0e06f808a5e8e1569017456ae08b3c038cb0fb7a (diff)
parent6d1ce4cf5cfa9525dfde14bd55b94e86f5e548c1 (diff)
downloadnova-cf5b369e1cab6905cd68627f57e30d61e2820dbf.tar.gz
Merge "Use deepcopy when process filters in db api" into stable/newton
Diffstat (limited to 'nova')
-rw-r--r--nova/db/sqlalchemy/api.py2
-rw-r--r--nova/tests/unit/db/test_db_api.py26
2 files changed, 27 insertions, 1 deletions
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index 29baac57fc..bbdc40ab38 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -2114,7 +2114,7 @@ def instance_get_all_by_filters_sort(context, filters, limit=None, marker=None,
# Make a copy of the filters dictionary to use going forward, as we'll
# be modifying it and we shouldn't affect the caller's use of it.
- filters = filters.copy()
+ filters = copy.deepcopy(filters)
if 'changes-since' in filters:
changes_since = timeutils.normalize_time(filters['changes-since'])
diff --git a/nova/tests/unit/db/test_db_api.py b/nova/tests/unit/db/test_db_api.py
index 926486a717..72f1528153 100644
--- a/nova/tests/unit/db/test_db_api.py
+++ b/nova/tests/unit/db/test_db_api.py
@@ -10241,6 +10241,32 @@ class TestInstanceTagsFiltering(test.TestCase):
self._assertEqualInstanceUUIDs([uuids[0], uuids[1], uuids[3], uuids[4],
uuids[6], uuids[7]], result)
+ def test_instance_get_all_by_filters_not_tags_multiple_cells(self):
+ """Test added for bug 1682693.
+
+ In cells v2 scenario, db.instance_get_all_by_filters() will
+ be called multiple times to search across all cells. This
+ test tests that filters for all cells remain the same in the
+ loop.
+ """
+ uuids = self._create_instances(8)
+
+ db.instance_tag_set(self.ctxt, uuids[0], [u't1'])
+ db.instance_tag_set(self.ctxt, uuids[1], [u't2'])
+ db.instance_tag_set(self.ctxt, uuids[2], [u't1', u't2'])
+ db.instance_tag_set(self.ctxt, uuids[3], [u't2', u't3'])
+ db.instance_tag_set(self.ctxt, uuids[4], [u't3'])
+ db.instance_tag_set(self.ctxt, uuids[5], [u't1', u't2', u't3'])
+ db.instance_tag_set(self.ctxt, uuids[6], [u't3', u't4'])
+ db.instance_tag_set(self.ctxt, uuids[7], [])
+
+ filters = {'not-tags': [u't1', u't2']}
+
+ result = db.instance_get_all_by_filters(self.ctxt, filters)
+
+ self._assertEqualInstanceUUIDs([uuids[0], uuids[1], uuids[3], uuids[4],
+ uuids[6], uuids[7]], result)
+
def test_instance_get_all_by_filters_not_tags_any(self):
uuids = self._create_instances(8)