diff options
| author | Rodolfo Alonso Hernandez <ralonsoh@redhat.com> | 2022-02-03 15:08:35 +0000 |
|---|---|---|
| committer | Rodolfo Alonso Hernandez <ralonsoh@redhat.com> | 2022-03-17 02:38:07 +0000 |
| commit | 1c6d396ba30c1a92a417f778d7522ea43e9b2d4a (patch) | |
| tree | a31895947bdcfe160b8e28b002574f5cc0518c4e /openstackclient/tests/functional/common | |
| parent | e91e0e001c8c46f33f0a67860e78b6bc285b4ecb (diff) | |
| download | python-openstackclient-1c6d396ba30c1a92a417f778d7522ea43e9b2d4a.tar.gz | |
Allow "--force" flag in quota network commands
This flag allows to set a new Neutron quota resource limit without
checking first the current resource usage. The new limit will be
set anyway. This flag was used only by the compute engine.
Related-Bug: #1953170
Change-Id: I7084f8208b804236ac99e6842db7a45854ce54d7
Diffstat (limited to 'openstackclient/tests/functional/common')
| -rw-r--r-- | openstackclient/tests/functional/common/test_quota.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/openstackclient/tests/functional/common/test_quota.py b/openstackclient/tests/functional/common/test_quota.py index bf67101a..5096fa06 100644 --- a/openstackclient/tests/functional/common/test_quota.py +++ b/openstackclient/tests/functional/common/test_quota.py @@ -169,12 +169,21 @@ class QuotaTests(base.TestCase): self.assertTrue(cmd_output["key-pairs"] >= 0) self.assertTrue(cmd_output["snapshots"] >= 0) + def _restore_quota_limit(self, resource, limit, project): + self.openstack('quota set --%s %s %s' % (resource, limit, project)) + def test_quota_network_set_with_check_limit(self): if not self.haz_network: self.skipTest('No Network service present') if not self.is_extension_enabled('quota-check-limit'): self.skipTest('No "quota-check-limit" extension present') + cmd_output = json.loads(self.openstack( + 'quota list -f json --network' + )) + self.addCleanup(self._restore_quota_limit, 'network', + cmd_output[0]['Networks'], self.PROJECT_NAME) + self.openstack('quota set --networks 40 ' + self.PROJECT_NAME) cmd_output = json.loads(self.openstack( 'quota list -f json --network' @@ -190,3 +199,41 @@ class QuotaTests(base.TestCase): self.assertRaises(exceptions.CommandFailed, self.openstack, 'quota set --networks 1 --check-limit ' + self.PROJECT_NAME) + + def test_quota_network_set_with_force(self): + if not self.haz_network: + self.skipTest('No Network service present') + # NOTE(ralonsoh): the Neutron support for the flag "check-limit" was + # added with the extension "quota-check-limit". The flag "force" was + # added too in order to change the behaviour of Neutron quota engine + # and mimic the Nova one: by default the engine will check the resource + # usage before setting the new limit; with "force", this check will be + # skipped (in Yoga, this behaviour is still NOT the default in + # Neutron). + if not self.is_extension_enabled('quota-check-limit'): + self.skipTest('No "quota-check-limit" extension present') + + cmd_output = json.loads(self.openstack( + 'quota list -f json --network' + )) + self.addCleanup(self._restore_quota_limit, 'network', + cmd_output[0]['Networks'], self.PROJECT_NAME) + + self.openstack('quota set --networks 40 ' + self.PROJECT_NAME) + cmd_output = json.loads(self.openstack( + 'quota list -f json --network' + )) + self.assertIsNotNone(cmd_output) + self.assertEqual(40, cmd_output[0]['Networks']) + + # That will ensure we have at least two networks in the system. + for _ in range(2): + self.openstack('network create --project %s %s' % + (self.PROJECT_NAME, uuid.uuid4().hex)) + + self.openstack('quota set --networks 1 --force ' + self.PROJECT_NAME) + cmd_output = json.loads(self.openstack( + 'quota list -f json --network' + )) + self.assertIsNotNone(cmd_output) + self.assertEqual(1, cmd_output[0]['Networks']) |
