コード例 #1
0
    def test_quota_overrides(self):
        """Make sure overriding a projects quotas works"""
        num_instances = quota.allowed_instances(
            self.context, 100, self._get_instance_type('m1.small'))
        self.assertEqual(num_instances, 2)
        db.quota_create(self.context, self.project_id, 'instances', 10)
        num_instances = quota.allowed_instances(
            self.context, 100, self._get_instance_type('m1.small'))
        self.assertEqual(num_instances, 4)
        db.quota_create(self.context, self.project_id, 'cores', 100)
        num_instances = quota.allowed_instances(
            self.context, 100, self._get_instance_type('m1.small'))
        self.assertEqual(num_instances, 10)
        db.quota_create(self.context, self.project_id, 'ram', 3 * 2048)
        num_instances = quota.allowed_instances(
            self.context, 100, self._get_instance_type('m1.small'))
        self.assertEqual(num_instances, 3)

        # metadata_items
        too_many_items = FLAGS.quota_metadata_items + 1000
        num_metadata_items = quota.allowed_metadata_items(
            self.context, too_many_items)
        self.assertEqual(num_metadata_items, FLAGS.quota_metadata_items)
        db.quota_create(self.context, self.project_id, 'metadata_items', 5)
        num_metadata_items = quota.allowed_metadata_items(
            self.context, too_many_items)
        self.assertEqual(num_metadata_items, 5)

        # Cleanup
        db.quota_destroy_all_by_project(self.context, self.project_id)
コード例 #2
0
    def test_quota_overrides(self):
        """Make sure overriding a projects quotas works"""
        num_instances = quota.allowed_instances(self.context, 100,
            self._get_instance_type('m1.small'))
        self.assertEqual(num_instances, 2)
        db.quota_create(self.context, self.project_id, 'instances', 10)
        num_instances = quota.allowed_instances(self.context, 100,
            self._get_instance_type('m1.small'))
        self.assertEqual(num_instances, 4)
        db.quota_create(self.context, self.project_id, 'cores', 100)
        num_instances = quota.allowed_instances(self.context, 100,
            self._get_instance_type('m1.small'))
        self.assertEqual(num_instances, 10)
        db.quota_create(self.context, self.project_id, 'ram', 3 * 2048)
        num_instances = quota.allowed_instances(self.context, 100,
            self._get_instance_type('m1.small'))
        self.assertEqual(num_instances, 3)

        # metadata_items
        too_many_items = FLAGS.quota_metadata_items + 1000
        num_metadata_items = quota.allowed_metadata_items(self.context,
                                                          too_many_items)
        self.assertEqual(num_metadata_items, FLAGS.quota_metadata_items)
        db.quota_create(self.context, self.project_id, 'metadata_items', 5)
        num_metadata_items = quota.allowed_metadata_items(self.context,
                                                          too_many_items)
        self.assertEqual(num_metadata_items, 5)

        # Cleanup
        db.quota_destroy_all_by_project(self.context, self.project_id)
コード例 #3
0
 def test_unlimited_cores(self):
     self.flags(quota_instances=-1, quota_ram=-1, quota_cores=2)
     instance_type = self._get_instance_type('m1.small')
     num_instances = quota.allowed_instances(self.context, 100,
                                             instance_type)
     self.assertEqual(num_instances, 2)
     db.quota_create(self.context, self.project_id, 'cores', None)
     num_instances = quota.allowed_instances(self.context, 100,
                                             instance_type)
     self.assertEqual(num_instances, 100)
     num_instances = quota.allowed_instances(self.context, 101,
                                             instance_type)
     self.assertEqual(num_instances, 101)
コード例 #4
0
 def test_unlimited_cores(self):
     self.flags(quota_instances=-1, quota_ram=-1, quota_cores=2)
     instance_type = self._get_instance_type('m1.small')
     num_instances = quota.allowed_instances(self.context, 100,
                                             instance_type)
     self.assertEqual(num_instances, 2)
     db.quota_create(self.context, self.project_id, 'cores', None)
     num_instances = quota.allowed_instances(self.context, 100,
                                             instance_type)
     self.assertEqual(num_instances, 100)
     num_instances = quota.allowed_instances(self.context, 101,
                                             instance_type)
     self.assertEqual(num_instances, 101)