Fix database poison warnings, part 22
The following warning appears in the unit test logs a number of times. "UserWarning: This test uses methods that set internal oslo_db state, but it does not claim to use the database. This will conflict with the setup of tests that do use the database and cause failures later." This patch fixes all the warnings from: nova.tests.unit.api.openstack.compute.test_quotas.py Note that this warning is only emitted once per unit test worker, so new offenders will show up in the logs each time you fix a test until they are all gone. Change-Id: I1f6d5e161abea3a66fe09159b84e100c123561bd Related-Bug: #1568414
This commit is contained in:
parent
9adb28bfc5
commit
993a815e78
|
@ -545,6 +545,40 @@ class QuotaSetsTestV236(test.NoDBTestCase):
|
|||
self.old_req = fakes.HTTPRequest.blank('', version='2.1')
|
||||
self.filtered_quotas = ['fixed_ips', 'floating_ips', 'networks',
|
||||
'security_group_rules', 'security_groups']
|
||||
self.quotas = {
|
||||
'cores': {'limit': 20},
|
||||
'fixed_ips': {'limit': -1},
|
||||
'floating_ips': {'limit': 10},
|
||||
'injected_file_content_bytes': {'limit': 10240},
|
||||
'injected_file_path_bytes': {'limit': 255},
|
||||
'injected_files': {'limit': 5},
|
||||
'instances': {'limit': 10},
|
||||
'key_pairs': {'limit': 100},
|
||||
'metadata_items': {'limit': 128},
|
||||
'networks': {'limit': 3},
|
||||
'ram': {'limit': 51200},
|
||||
'security_group_rules': {'limit': 20},
|
||||
'security_groups': {'limit': 10},
|
||||
'server_group_members': {'limit': 10},
|
||||
'server_groups': {'limit': 10}
|
||||
}
|
||||
self.defaults = {
|
||||
'cores': 20,
|
||||
'fixed_ips': -1,
|
||||
'floating_ips': 10,
|
||||
'injected_file_content_bytes': 10240,
|
||||
'injected_file_path_bytes': 255,
|
||||
'injected_files': 5,
|
||||
'instances': 10,
|
||||
'key_pairs': 100,
|
||||
'metadata_items': 128,
|
||||
'networks': 3,
|
||||
'ram': 51200,
|
||||
'security_group_rules': 20,
|
||||
'security_groups': 10,
|
||||
'server_group_members': 10,
|
||||
'server_groups': 10
|
||||
}
|
||||
self.controller = quotas_v21.QuotaSetsController()
|
||||
self.req = fakes.HTTPRequest.blank('', version='2.36')
|
||||
self.addCleanup(self._remove_network_quota)
|
||||
|
@ -557,32 +591,47 @@ class QuotaSetsTestV236(test.NoDBTestCase):
|
|||
for filtered in self.filtered_quotas:
|
||||
self.assertIn(filtered, res_dict['quota_set'])
|
||||
|
||||
def test_quotas_show_filtered(self):
|
||||
@mock.patch('nova.quota.QUOTAS.get_project_quotas')
|
||||
def test_quotas_show_filtered(self, mock_quotas):
|
||||
mock_quotas.return_value = self.quotas
|
||||
self._ensure_filtered_quotas_existed_in_old_api()
|
||||
res_dict = self.controller.show(self.req, 1234)
|
||||
for filtered in self.filtered_quotas:
|
||||
self.assertNotIn(filtered, res_dict['quota_set'])
|
||||
|
||||
def test_quotas_default_filtered(self):
|
||||
@mock.patch('nova.quota.QUOTAS.get_defaults')
|
||||
@mock.patch('nova.quota.QUOTAS.get_project_quotas')
|
||||
def test_quotas_default_filtered(self, mock_quotas, mock_defaults):
|
||||
mock_quotas.return_value = self.quotas
|
||||
self._ensure_filtered_quotas_existed_in_old_api()
|
||||
res_dict = self.controller.defaults(self.req, 1234)
|
||||
for filtered in self.filtered_quotas:
|
||||
self.assertNotIn(filtered, res_dict['quota_set'])
|
||||
|
||||
def test_quotas_detail_filtered(self):
|
||||
@mock.patch('nova.quota.QUOTAS.get_project_quotas')
|
||||
def test_quotas_detail_filtered(self, mock_quotas):
|
||||
mock_quotas.return_value = self.quotas
|
||||
self._ensure_filtered_quotas_existed_in_old_api()
|
||||
res_dict = self.controller.detail(self.req, 1234)
|
||||
for filtered in self.filtered_quotas:
|
||||
self.assertNotIn(filtered, res_dict['quota_set'])
|
||||
|
||||
def test_quotas_update_input_filtered(self):
|
||||
@mock.patch('nova.quota.QUOTAS.get_project_quotas')
|
||||
def test_quotas_update_input_filtered(self, mock_quotas):
|
||||
mock_quotas.return_value = self.quotas
|
||||
self._ensure_filtered_quotas_existed_in_old_api()
|
||||
for filtered in self.filtered_quotas:
|
||||
self.assertRaises(exception.ValidationError,
|
||||
self.controller.update, self.req, 1234,
|
||||
body={'quota_set': {filtered: 100}})
|
||||
|
||||
def test_quotas_update_output_filtered(self):
|
||||
@mock.patch('nova.objects.Quotas.create_limit')
|
||||
@mock.patch('nova.quota.QUOTAS.get_settable_quotas')
|
||||
@mock.patch('nova.quota.QUOTAS.get_project_quotas')
|
||||
def test_quotas_update_output_filtered(self, mock_quotas, mock_settable,
|
||||
mock_create_limit):
|
||||
mock_quotas.return_value = self.quotas
|
||||
mock_settable.return_value = {'cores': {'maximum': -1, 'minimum': 0}}
|
||||
self._ensure_filtered_quotas_existed_in_old_api()
|
||||
res_dict = self.controller.update(self.req, 1234,
|
||||
body={'quota_set': {'cores': 100}})
|
||||
|
|
Loading…
Reference in New Issue