From dea224ae26c752d328ccbb622048a63e990bee50 Mon Sep 17 00:00:00 2001 From: Eoghan Glynn Date: Wed, 4 Jul 2012 11:21:19 +0000 Subject: Distinguish over-quota for volume size and number. Fixes LP 1020634 Ensure that exceeding the allowed number of volumes is not mis-represented in log messages and exception handling as excessive space usage. Change-Id: I71ec995c77bc447bfc9221084b057bd8d69a4513 --- nova/tests/test_volume.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/test_volume.py b/nova/tests/test_volume.py index 2e149f950..0478eb545 100644 --- a/nova/tests/test_volume.py +++ b/nova/tests/test_volume.py @@ -121,6 +121,39 @@ class VolumeTestCase(test.TestCase): self.context, volume_id) + def _do_test_create_over_quota(self, resource, expected): + """Test volume creation over quota.""" + + def fake_reserve(context, **deltas): + kwargs = dict(overs=[resource], + quotas=dict(gigabytes=1000, volumes=10), + usages=dict(gigabytes=dict(reserved=1, in_use=999), + volumes=dict(reserved=1, in_use=9))) + raise exception.OverQuota(**kwargs) + + def fake_commit(context, reservations): + self.fail('should not commit over quota') + + self.stubs.Set(QUOTAS, 'reserve', fake_reserve) + self.stubs.Set(QUOTAS, 'commit', fake_commit) + + volume_api = nova.volume.api.API() + + self.assertRaises(expected, + volume_api.create, + self.context, + 2, + 'name', + 'description') + + def test_create_volumes_over_quota(self): + self._do_test_create_over_quota('volumes', + exception.VolumeLimitExceeded) + + def test_create_gigabytes_over_quota(self): + self._do_test_create_over_quota('gigabytes', + exception.VolumeSizeTooLarge) + def test_delete_busy_volume(self): """Test volume survives deletion if driver reports it as busy.""" volume = self._create_volume() -- cgit