From 93ceb7fb5e3cc8112a314ae19fe63ffe3481a6ce Mon Sep 17 00:00:00 2001 From: melanie witt Date: Thu, 7 Dec 2017 01:54:18 +0000 Subject: [PATCH] Add API and nova-manage tests that use the NoopQuotaDriver These are written in preparation for follow up old-style quotas code removal that moves the logic for the 'reserved' field from the quota internals (where it's no longer used) to the API (where it's expected to be provided until we have a new microversion). These tests will help catch any unintended change in behavior. Change-Id: I1f743a8db7d032e09372587622ab64250a05e0f0 --- .../quotas-show-defaults-get-resp.json | 20 +++++ .../quotas-show-detail-get-resp.json | 80 +++++++++++++++++++ .../quotas-show-get-resp.json | 20 +++++ .../quotas-update-force-post-req.json | 6 ++ .../quotas-update-force-post-resp.json | 19 +++++ .../quotas-update-post-req.json | 5 ++ .../quotas-update-post-resp.json | 19 +++++ .../user-quotas-show-get-resp.json | 20 +++++ .../user-quotas-update-post-req.json | 6 ++ .../user-quotas-update-post-resp.json | 19 +++++ nova/tests/fixtures.py | 23 ++++++ .../quotas-show-defaults-get-resp.json.tpl | 20 +++++ .../quotas-show-detail-get-resp.json.tpl | 80 +++++++++++++++++++ .../quotas-show-get-resp.json.tpl | 20 +++++ .../quotas-update-force-post-req.json.tpl | 6 ++ .../quotas-update-force-post-resp.json.tpl | 19 +++++ .../quotas-update-post-req.json.tpl | 5 ++ .../quotas-update-post-resp.json.tpl | 19 +++++ .../user-quotas-show-get-resp.json.tpl | 20 +++++ .../user-quotas-update-post-req.json.tpl | 6 ++ .../user-quotas-update-post-resp.json.tpl | 19 +++++ .../api_sample_tests/test_quota_sets.py | 12 +++ nova/tests/unit/test_nova_manage.py | 14 ++++ 23 files changed, 477 insertions(+) create mode 100644 doc/api_samples/os-quota-sets-noop/quotas-show-defaults-get-resp.json create mode 100644 doc/api_samples/os-quota-sets-noop/quotas-show-detail-get-resp.json create mode 100644 doc/api_samples/os-quota-sets-noop/quotas-show-get-resp.json create mode 100644 doc/api_samples/os-quota-sets-noop/quotas-update-force-post-req.json create mode 100644 doc/api_samples/os-quota-sets-noop/quotas-update-force-post-resp.json create mode 100644 doc/api_samples/os-quota-sets-noop/quotas-update-post-req.json create mode 100644 doc/api_samples/os-quota-sets-noop/quotas-update-post-resp.json create mode 100644 doc/api_samples/os-quota-sets-noop/user-quotas-show-get-resp.json create mode 100644 doc/api_samples/os-quota-sets-noop/user-quotas-update-post-req.json create mode 100644 doc/api_samples/os-quota-sets-noop/user-quotas-update-post-resp.json create mode 100644 nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-show-defaults-get-resp.json.tpl create mode 100644 nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-show-detail-get-resp.json.tpl create mode 100644 nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-show-get-resp.json.tpl create mode 100644 nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-force-post-req.json.tpl create mode 100644 nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-force-post-resp.json.tpl create mode 100644 nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-post-req.json.tpl create mode 100644 nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-post-resp.json.tpl create mode 100644 nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/user-quotas-show-get-resp.json.tpl create mode 100644 nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/user-quotas-update-post-req.json.tpl create mode 100644 nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/user-quotas-update-post-resp.json.tpl diff --git a/doc/api_samples/os-quota-sets-noop/quotas-show-defaults-get-resp.json b/doc/api_samples/os-quota-sets-noop/quotas-show-defaults-get-resp.json new file mode 100644 index 000000000000..620fa8ed3575 --- /dev/null +++ b/doc/api_samples/os-quota-sets-noop/quotas-show-defaults-get-resp.json @@ -0,0 +1,20 @@ +{ + "quota_set": { + "cores": -1, + "fixed_ips": -1, + "floating_ips": -1, + "id": "fake_tenant", + "injected_file_content_bytes": -1, + "injected_file_path_bytes": -1, + "injected_files": -1, + "instances": -1, + "key_pairs": -1, + "metadata_items": -1, + "networks": -1, + "ram": -1, + "security_group_rules": -1, + "security_groups": -1, + "server_group_members": -1, + "server_groups": -1 + } +} \ No newline at end of file diff --git a/doc/api_samples/os-quota-sets-noop/quotas-show-detail-get-resp.json b/doc/api_samples/os-quota-sets-noop/quotas-show-detail-get-resp.json new file mode 100644 index 000000000000..47af14b048f8 --- /dev/null +++ b/doc/api_samples/os-quota-sets-noop/quotas-show-detail-get-resp.json @@ -0,0 +1,80 @@ +{ + "quota_set": { + "cores": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "fixed_ips": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "floating_ips": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "id": "fake_tenant", + "injected_file_content_bytes": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "injected_file_path_bytes": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "injected_files": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "instances": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "key_pairs": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "metadata_items": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "networks": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "ram": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "security_group_rules": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "security_groups": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "server_group_members": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "server_groups": { + "in_use": -1, + "limit": -1, + "reserved": -1 + } + } +} \ No newline at end of file diff --git a/doc/api_samples/os-quota-sets-noop/quotas-show-get-resp.json b/doc/api_samples/os-quota-sets-noop/quotas-show-get-resp.json new file mode 100644 index 000000000000..620fa8ed3575 --- /dev/null +++ b/doc/api_samples/os-quota-sets-noop/quotas-show-get-resp.json @@ -0,0 +1,20 @@ +{ + "quota_set": { + "cores": -1, + "fixed_ips": -1, + "floating_ips": -1, + "id": "fake_tenant", + "injected_file_content_bytes": -1, + "injected_file_path_bytes": -1, + "injected_files": -1, + "instances": -1, + "key_pairs": -1, + "metadata_items": -1, + "networks": -1, + "ram": -1, + "security_group_rules": -1, + "security_groups": -1, + "server_group_members": -1, + "server_groups": -1 + } +} \ No newline at end of file diff --git a/doc/api_samples/os-quota-sets-noop/quotas-update-force-post-req.json b/doc/api_samples/os-quota-sets-noop/quotas-update-force-post-req.json new file mode 100644 index 000000000000..460d2ac1c7c4 --- /dev/null +++ b/doc/api_samples/os-quota-sets-noop/quotas-update-force-post-req.json @@ -0,0 +1,6 @@ +{ + "quota_set": { + "force": "True", + "instances": 45 + } +} \ No newline at end of file diff --git a/doc/api_samples/os-quota-sets-noop/quotas-update-force-post-resp.json b/doc/api_samples/os-quota-sets-noop/quotas-update-force-post-resp.json new file mode 100644 index 000000000000..0a4c3e9008d7 --- /dev/null +++ b/doc/api_samples/os-quota-sets-noop/quotas-update-force-post-resp.json @@ -0,0 +1,19 @@ +{ + "quota_set": { + "cores": -1, + "fixed_ips": -1, + "floating_ips": -1, + "injected_file_content_bytes": -1, + "injected_file_path_bytes": -1, + "injected_files": -1, + "instances": -1, + "key_pairs": -1, + "metadata_items": -1, + "networks": -1, + "ram": -1, + "security_group_rules": -1, + "security_groups": -1, + "server_group_members": -1, + "server_groups": -1 + } +} \ No newline at end of file diff --git a/doc/api_samples/os-quota-sets-noop/quotas-update-post-req.json b/doc/api_samples/os-quota-sets-noop/quotas-update-post-req.json new file mode 100644 index 000000000000..0b78cff3095f --- /dev/null +++ b/doc/api_samples/os-quota-sets-noop/quotas-update-post-req.json @@ -0,0 +1,5 @@ +{ + "quota_set": { + "security_groups": 45 + } +} \ No newline at end of file diff --git a/doc/api_samples/os-quota-sets-noop/quotas-update-post-resp.json b/doc/api_samples/os-quota-sets-noop/quotas-update-post-resp.json new file mode 100644 index 000000000000..0a4c3e9008d7 --- /dev/null +++ b/doc/api_samples/os-quota-sets-noop/quotas-update-post-resp.json @@ -0,0 +1,19 @@ +{ + "quota_set": { + "cores": -1, + "fixed_ips": -1, + "floating_ips": -1, + "injected_file_content_bytes": -1, + "injected_file_path_bytes": -1, + "injected_files": -1, + "instances": -1, + "key_pairs": -1, + "metadata_items": -1, + "networks": -1, + "ram": -1, + "security_group_rules": -1, + "security_groups": -1, + "server_group_members": -1, + "server_groups": -1 + } +} \ No newline at end of file diff --git a/doc/api_samples/os-quota-sets-noop/user-quotas-show-get-resp.json b/doc/api_samples/os-quota-sets-noop/user-quotas-show-get-resp.json new file mode 100644 index 000000000000..620fa8ed3575 --- /dev/null +++ b/doc/api_samples/os-quota-sets-noop/user-quotas-show-get-resp.json @@ -0,0 +1,20 @@ +{ + "quota_set": { + "cores": -1, + "fixed_ips": -1, + "floating_ips": -1, + "id": "fake_tenant", + "injected_file_content_bytes": -1, + "injected_file_path_bytes": -1, + "injected_files": -1, + "instances": -1, + "key_pairs": -1, + "metadata_items": -1, + "networks": -1, + "ram": -1, + "security_group_rules": -1, + "security_groups": -1, + "server_group_members": -1, + "server_groups": -1 + } +} \ No newline at end of file diff --git a/doc/api_samples/os-quota-sets-noop/user-quotas-update-post-req.json b/doc/api_samples/os-quota-sets-noop/user-quotas-update-post-req.json new file mode 100644 index 000000000000..cbd6f18af1d7 --- /dev/null +++ b/doc/api_samples/os-quota-sets-noop/user-quotas-update-post-req.json @@ -0,0 +1,6 @@ +{ + "quota_set": { + "force": "True", + "instances": 9 + } +} \ No newline at end of file diff --git a/doc/api_samples/os-quota-sets-noop/user-quotas-update-post-resp.json b/doc/api_samples/os-quota-sets-noop/user-quotas-update-post-resp.json new file mode 100644 index 000000000000..0a4c3e9008d7 --- /dev/null +++ b/doc/api_samples/os-quota-sets-noop/user-quotas-update-post-resp.json @@ -0,0 +1,19 @@ +{ + "quota_set": { + "cores": -1, + "fixed_ips": -1, + "floating_ips": -1, + "injected_file_content_bytes": -1, + "injected_file_path_bytes": -1, + "injected_files": -1, + "instances": -1, + "key_pairs": -1, + "metadata_items": -1, + "networks": -1, + "ram": -1, + "security_group_rules": -1, + "security_groups": -1, + "server_group_members": -1, + "server_groups": -1 + } +} \ No newline at end of file diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index ee3e8885c180..03e6018f75c8 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -1612,3 +1612,26 @@ class PrivsepNoHelperFixture(fixtures.Fixture): self.useFixture(fixtures.MonkeyPatch( 'oslo_privsep.daemon.RootwrapClientChannel', UnHelperfulClientChannel)) + + +class NoopQuotaDriverFixture(fixtures.Fixture): + """A fixture to run tests using the NoopQuotaDriver. + + We can't simply set self.flags to the NoopQuotaDriver in tests to use the + NoopQuotaDriver because the QuotaEngine object is global. Concurrently + running tests will fail intermittently because they might get the + NoopQuotaDriver globally when they expected the default DbQuotaDriver + behavior. So instead, we can patch the _driver property of the QuotaEngine + class on a per-test basis. + """ + + def setUp(self): + super(NoopQuotaDriverFixture, self).setUp() + self.useFixture(fixtures.MonkeyPatch('nova.quota.QuotaEngine._driver', + nova_quota.NoopQuotaDriver())) + # Set the config option just so that code checking for the presence of + # the NoopQuotaDriver setting will see it as expected. + # For some reason, this does *not* work when TestCase.flags is used. + # When using self.flags, the concurrent test failures returned. + CONF.set_override('driver', 'nova.quota.NoopQuotaDriver', 'quota') + self.addCleanup(CONF.clear_override, 'driver', 'quota') diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-show-defaults-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-show-defaults-get-resp.json.tpl new file mode 100644 index 000000000000..a86bea6b558c --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-show-defaults-get-resp.json.tpl @@ -0,0 +1,20 @@ +{ + "quota_set": { + "cores": -1, + "floating_ips": -1, + "fixed_ips": -1, + "id": "fake_tenant", + "injected_file_content_bytes": -1, + "injected_file_path_bytes": -1, + "injected_files": -1, + "instances": -1, + "key_pairs": -1, + "metadata_items": -1, + "ram": -1, + "security_group_rules": -1, + "security_groups": -1, + "server_groups": -1, + "server_group_members": -1, + "networks": -1 + } +} diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-show-detail-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-show-detail-get-resp.json.tpl new file mode 100644 index 000000000000..f7c33a8d425d --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-show-detail-get-resp.json.tpl @@ -0,0 +1,80 @@ +{ + "quota_set": { + "cores": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "fixed_ips": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "floating_ips": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "id": "fake_tenant", + "injected_file_content_bytes": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "injected_file_path_bytes": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "injected_files": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "instances": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "key_pairs": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "metadata_items": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "networks": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "ram": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "security_group_rules": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "security_groups": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "server_group_members": { + "in_use": -1, + "limit": -1, + "reserved": -1 + }, + "server_groups": { + "in_use": -1, + "limit": -1, + "reserved": -1 + } + } +} diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-show-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-show-get-resp.json.tpl new file mode 100644 index 000000000000..620fa8ed3575 --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-show-get-resp.json.tpl @@ -0,0 +1,20 @@ +{ + "quota_set": { + "cores": -1, + "fixed_ips": -1, + "floating_ips": -1, + "id": "fake_tenant", + "injected_file_content_bytes": -1, + "injected_file_path_bytes": -1, + "injected_files": -1, + "instances": -1, + "key_pairs": -1, + "metadata_items": -1, + "networks": -1, + "ram": -1, + "security_group_rules": -1, + "security_groups": -1, + "server_group_members": -1, + "server_groups": -1 + } +} \ No newline at end of file diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-force-post-req.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-force-post-req.json.tpl new file mode 100644 index 000000000000..a58a17912375 --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-force-post-req.json.tpl @@ -0,0 +1,6 @@ +{ + "quota_set": { + "force": "True", + "instances": 45 + } +} diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-force-post-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-force-post-resp.json.tpl new file mode 100644 index 000000000000..0a4c3e9008d7 --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-force-post-resp.json.tpl @@ -0,0 +1,19 @@ +{ + "quota_set": { + "cores": -1, + "fixed_ips": -1, + "floating_ips": -1, + "injected_file_content_bytes": -1, + "injected_file_path_bytes": -1, + "injected_files": -1, + "instances": -1, + "key_pairs": -1, + "metadata_items": -1, + "networks": -1, + "ram": -1, + "security_group_rules": -1, + "security_groups": -1, + "server_group_members": -1, + "server_groups": -1 + } +} \ No newline at end of file diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-post-req.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-post-req.json.tpl new file mode 100644 index 000000000000..1f12caa0450e --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-post-req.json.tpl @@ -0,0 +1,5 @@ +{ + "quota_set": { + "security_groups": 45 + } +} diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-post-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-post-resp.json.tpl new file mode 100644 index 000000000000..0a4c3e9008d7 --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/quotas-update-post-resp.json.tpl @@ -0,0 +1,19 @@ +{ + "quota_set": { + "cores": -1, + "fixed_ips": -1, + "floating_ips": -1, + "injected_file_content_bytes": -1, + "injected_file_path_bytes": -1, + "injected_files": -1, + "instances": -1, + "key_pairs": -1, + "metadata_items": -1, + "networks": -1, + "ram": -1, + "security_group_rules": -1, + "security_groups": -1, + "server_group_members": -1, + "server_groups": -1 + } +} \ No newline at end of file diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/user-quotas-show-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/user-quotas-show-get-resp.json.tpl new file mode 100644 index 000000000000..620fa8ed3575 --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/user-quotas-show-get-resp.json.tpl @@ -0,0 +1,20 @@ +{ + "quota_set": { + "cores": -1, + "fixed_ips": -1, + "floating_ips": -1, + "id": "fake_tenant", + "injected_file_content_bytes": -1, + "injected_file_path_bytes": -1, + "injected_files": -1, + "instances": -1, + "key_pairs": -1, + "metadata_items": -1, + "networks": -1, + "ram": -1, + "security_group_rules": -1, + "security_groups": -1, + "server_group_members": -1, + "server_groups": -1 + } +} \ No newline at end of file diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/user-quotas-update-post-req.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/user-quotas-update-post-req.json.tpl new file mode 100644 index 000000000000..b322b2a87007 --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/user-quotas-update-post-req.json.tpl @@ -0,0 +1,6 @@ +{ + "quota_set": { + "force": "True", + "instances": 9 + } +} diff --git a/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/user-quotas-update-post-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/user-quotas-update-post-resp.json.tpl new file mode 100644 index 000000000000..0a4c3e9008d7 --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/os-quota-sets-noop/user-quotas-update-post-resp.json.tpl @@ -0,0 +1,19 @@ +{ + "quota_set": { + "cores": -1, + "fixed_ips": -1, + "floating_ips": -1, + "injected_file_content_bytes": -1, + "injected_file_path_bytes": -1, + "injected_files": -1, + "instances": -1, + "key_pairs": -1, + "metadata_items": -1, + "networks": -1, + "ram": -1, + "security_group_rules": -1, + "security_groups": -1, + "server_group_members": -1, + "server_groups": -1 + } +} \ No newline at end of file diff --git a/nova/tests/functional/api_sample_tests/test_quota_sets.py b/nova/tests/functional/api_sample_tests/test_quota_sets.py index 4cbca1a0cfa7..95b91be6ff72 100644 --- a/nova/tests/functional/api_sample_tests/test_quota_sets.py +++ b/nova/tests/functional/api_sample_tests/test_quota_sets.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from nova.tests import fixtures as nova_fixtures from nova.tests.functional.api_sample_tests import api_sample_base @@ -80,3 +81,14 @@ class QuotaSetsSampleJsonTests(api_sample_base.ApiSampleTestBaseV21): class QuotaSetsSampleJsonTests2_36(QuotaSetsSampleJsonTests): microversion = '2.36' scenarios = [('v2_36', {'api_major_version': 'v2.1'})] + + +class NoopQuotaSetsSampleJsonTests(QuotaSetsSampleJsonTests): + sample_dir = "os-quota-sets-noop" + + def setUp(self): + super(NoopQuotaSetsSampleJsonTests, self).setUp() + # NOTE(melwitt): We can't simply set self.flags to the NoopQuotaDriver + # here to use the driver because the QuotaEngine is global. See the + # fixture for details. + self.useFixture(nova_fixtures.NoopQuotaDriverFixture()) diff --git a/nova/tests/unit/test_nova_manage.py b/nova/tests/unit/test_nova_manage.py index 88f4e94b4a14..5c777ca54cb2 100644 --- a/nova/tests/unit/test_nova_manage.py +++ b/nova/tests/unit/test_nova_manage.py @@ -390,6 +390,20 @@ class ProjectCommandsTestCase(test.TestCase): def test_quota_update_invalid_key(self): self.assertEqual(2, self.commands.quota('admin', 'volumes1', '10')) + def test_quota_reserved(self): + self.commands.quota(project_id='admin') + result = self.output.getvalue() + print_format = "%-36s %-10s %-10s %-10s" % ('cores', '20', '0', '0') + self.assertIn(print_format, result) + + def test_quota_reserved_noop_driver(self): + self.useFixture(nova_fixtures.NoopQuotaDriverFixture()) + self.commands.quota(project_id='admin') + result = self.output.getvalue() + print_format = "%-36s %-10s %-10s %-10s" % ('cores', 'unlimited', + '-1', '-1') + self.assertIn(print_format, result) + class DBCommandsTestCase(test.NoDBTestCase): USES_DB_SELF = True