summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorEoghan Glynn <eglynn@redhat.com>2012-07-04 11:21:19 +0000
committerEoghan Glynn <eglynn@redhat.com>2012-07-04 16:39:04 +0100
commitdea224ae26c752d328ccbb622048a63e990bee50 (patch)
tree0cab8091383831ff520a4bebe121b5044da6a3a0 /nova/tests
parent980c76266629ea66bc23fddb02f5be61c51d873c (diff)
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
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_volume.py33
1 files changed, 33 insertions, 0 deletions
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()