diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-07-28 15:50:26 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-07-28 15:50:26 +0000 |
commit | 65694bc2f07239a84ea67d81c4ffe103d7826d85 (patch) | |
tree | 87aa79fca69fbdb52f7947654bb3e214c0bb67c0 | |
parent | ac614adc47cabfe50b9f80eeb056510ed84beff1 (diff) | |
parent | 789709f1db081222c2e4d21d287781e437b76a95 (diff) | |
download | designate-65694bc2f07239a84ea67d81c4ffe103d7826d85.tar.gz |
Merge "Ensure RecordSet quotas are enforced"1.0.0.0b2
-rw-r--r-- | designate/central/service.py | 19 | ||||
-rw-r--r-- | designate/tests/test_central/test_service.py | 28 |
2 files changed, 35 insertions, 12 deletions
diff --git a/designate/central/service.py b/designate/central/service.py index 59c56d17..546b8e62 100644 --- a/designate/central/service.py +++ b/designate/central/service.py @@ -595,18 +595,27 @@ class Service(service.RPCService, service.Service): self.quota.limit_check(context, tenant_id, domains=count) def _enforce_recordset_quota(self, context, domain): - # TODO(kiall): Enforce RRSet Quotas - pass + # Ensure the recordsets per domain quota is OK + criterion = {'domain_id': domain.id} + count = self.storage.count_recordsets(context, criterion) + + self.quota.limit_check( + context, domain.tenant_id, domain_recordsets=count) def _enforce_record_quota(self, context, domain, recordset): # Ensure the records per domain quota is OK - criterion = {'domain_id': domain['id']} + criterion = {'domain_id': domain.id} count = self.storage.count_records(context, criterion) - self.quota.limit_check(context, domain['tenant_id'], + self.quota.limit_check(context, domain.tenant_id, domain_records=count) - # TODO(kiall): Enforce Records per RRSet Quotas + # Ensure the records per recordset quota is OK + criterion = {'recordset_id': recordset.id} + count = self.storage.count_records(context, criterion) + + self.quota.limit_check(context, domain.tenant_id, + recordset_records=count) # Misc Methods def get_absolute_limits(self, context): diff --git a/designate/tests/test_central/test_service.py b/designate/tests/test_central/test_service.py index eab3a5ac..584c2de6 100644 --- a/designate/tests/test_central/test_service.py +++ b/designate/tests/test_central/test_service.py @@ -1063,15 +1063,16 @@ class CentralServiceTest(CentralTestCase): self.assertIsNotNone(recordset.records[1].id) self.assertThat(new_serial, GreaterThan(original_serial)) - # def test_create_recordset_over_quota(self): - # self.config(quota_domain_recordsets=1) + def test_create_recordset_over_quota(self): + # SOA, NS recordsets exist by default. + self.config(quota_domain_recordsets=3) - # domain = self.create_domain() + domain = self.create_domain() - # self.create_recordset(domain) + self.create_recordset(domain) - # with testtools.ExpectedException(exceptions.OverQuota): - # self.create_recordset(domain) + with testtools.ExpectedException(exceptions.OverQuota): + self.create_recordset(domain) def test_create_invalid_recordset_location_cname_at_apex(self): domain = self.create_domain() @@ -1595,7 +1596,8 @@ class CentralServiceTest(CentralTestCase): self.assertEqual(record['data'], values['data']) self.assertIn('status', record) - def test_create_record_over_quota(self): + def test_create_record_over_domain_quota(self): + # SOA and NS Records exist self.config(quota_domain_records=3) # Creating the domain automatically creates SOA & NS records @@ -1607,6 +1609,18 @@ class CentralServiceTest(CentralTestCase): with testtools.ExpectedException(exceptions.OverQuota): self.create_record(domain, recordset) + def test_create_record_over_recordset_quota(self): + self.config(quota_recordset_records=1) + + # Creating the domain automatically creates SOA & NS records + domain = self.create_domain() + recordset = self.create_recordset(domain) + + self.create_record(domain, recordset) + + with testtools.ExpectedException(exceptions.OverQuota): + self.create_record(domain, recordset) + def test_create_record_without_incrementing_serial(self): domain = self.create_domain() recordset = self.create_recordset(domain, type='A') |