summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorMark Washenberger <mark.washenberger@rackspace.com>2011-03-03 17:49:41 -0500
committerMark Washenberger <mark.washenberger@rackspace.com>2011-03-03 17:49:41 -0500
commite14f524eb92ae07704a2ec7dac0f97c60940a6ab (patch)
tree1fa6784e24f7df8f24324350046912690b44cbf5 /nova/tests
parent9cfe8ff2e8e66952c3202b852a88ee6fca6fb736 (diff)
enforce personality quotas
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_quota.py66
1 files changed, 60 insertions, 6 deletions
diff --git a/nova/tests/test_quota.py b/nova/tests/test_quota.py
index 48e5a5538..16a083788 100644
--- a/nova/tests/test_quota.py
+++ b/nova/tests/test_quota.py
@@ -177,12 +177,66 @@ class QuotaTestCase(test.TestCase):
image_id='fake',
metadata=metadata)
- def test_allowed_file_injection_files(self):
+ def test_allowed_personality_files(self):
self.assertEqual(
- quota.allowed_file_injection_files(self.context),
- FLAGS.quota_file_injection_max_files)
+ quota.allowed_personality_files(self.context),
+ FLAGS.quota_personality_max_files)
+
+ def _create_with_personality(self, files):
+ api = compute.API()
+ api.create(self.context, min_count=1, max_count=1,
+ instance_type='m1.small', image_id='fake',
+ onset_files=files)
+
+ def test_no_personality_files(self):
+ api = compute.API()
+ api.create(self.context, instance_type='m1.small', image_id='fake')
+
+ def test_max_personality_files(self):
+ files = []
+ for i in xrange(FLAGS.quota_personality_max_files):
+ files.append(('/my/path%d' % i, 'config = test\n'))
+ self._create_with_personality(files) # no QuotaError
+
+ def test_too_many_personality_files(self):
+ files = []
+ for i in xrange(FLAGS.quota_personality_max_files + 1):
+ files.append(('/my/path%d' % i, 'my\ncontent%d\n' % i))
+ self.assertRaises(quota.QuotaError,
+ self._create_with_personality, files)
- def test_allowed_file_injection_file_bytes(self):
+ def test_allowed_personality_content_bytes(self):
self.assertEqual(
- quota.allowed_file_injection_file_bytes(self.context),
- FLAGS.quota_file_injection_max_file_bytes)
+ quota.allowed_personality_content_bytes(self.context),
+ FLAGS.quota_personality_max_content_bytes)
+
+ def test_max_personality_content_bytes(self):
+ max = FLAGS.quota_personality_max_content_bytes
+ content = ''.join(['a' for i in xrange(max)])
+ files = [('/test/path', content)]
+ self._create_with_personality(files) # no QuotaError
+
+ def test_too_many_personality_content_bytes(self):
+ max = FLAGS.quota_personality_max_content_bytes
+ content = ''.join(['a' for i in xrange(max + 1)])
+ files = [('/test/path', content)]
+ self.assertRaises(quota.QuotaError,
+ self._create_with_personality, files)
+
+ def test_allowed_personality_path_bytes(self):
+ self.assertEqual(
+ quota.allowed_personality_path_bytes(self.context),
+ FLAGS.quota_personality_max_path_bytes)
+
+ def test_max_personality_path_bytes(self):
+ max = FLAGS.quota_personality_max_path_bytes
+ path = ''.join(['a' for i in xrange(max)])
+ files = [(path, 'config = quotatest')]
+ self._create_with_personality(files) # no QuotaError
+
+ def test_too_many_personality_path_bytes(self):
+ max = FLAGS.quota_personality_max_path_bytes
+ path = ''.join(['a' for i in xrange(max + 1)])
+ files = [(path, 'config = quotatest')]
+ self.assertRaises(quota.QuotaError,
+ self._create_with_personality, files)