2018-04-02 15:07:25 -07:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
#
|
|
|
|
|
|
|
|
from openstackclient.common import limits
|
|
|
|
from openstackclient.tests.unit.compute.v2 import fakes as compute_fakes
|
2023-07-17 15:34:44 +05:30
|
|
|
from openstackclient.tests.unit.volume.v3 import fakes as volume_fakes
|
2018-04-02 15:07:25 -07:00
|
|
|
|
|
|
|
|
|
|
|
class TestComputeLimits(compute_fakes.TestComputev2):
|
2023-07-17 15:34:44 +05:30
|
|
|
absolute_columns = ['Name', 'Value']
|
2023-05-08 11:35:45 +01:00
|
|
|
rate_columns = ["Verb", "URI", "Value", "Remain", "Unit", "Next Available"]
|
2018-04-02 15:07:25 -07:00
|
|
|
|
|
|
|
def setUp(self):
|
2022-09-29 18:42:26 +01:00
|
|
|
super().setUp()
|
2018-04-02 15:07:25 -07:00
|
|
|
self.app.client_manager.volume_endpoint_enabled = False
|
|
|
|
|
2023-07-17 15:34:44 +05:30
|
|
|
self.fake_limits = compute_fakes.create_limits()
|
|
|
|
|
|
|
|
self.absolute_data = [
|
|
|
|
('floating_ips', 10),
|
|
|
|
('floating_ips_used', 0),
|
|
|
|
('image_meta', 128),
|
|
|
|
('instances', 10),
|
|
|
|
('instances_used', 0),
|
|
|
|
('keypairs', 100),
|
|
|
|
('max_image_meta', 128),
|
|
|
|
('max_security_group_rules', 20),
|
|
|
|
('max_security_groups', 10),
|
|
|
|
('max_server_group_members', 10),
|
|
|
|
('max_server_groups', 10),
|
|
|
|
('max_server_meta', 128),
|
|
|
|
('max_total_cores', 20),
|
|
|
|
('max_total_floating_ips', 10),
|
|
|
|
('max_total_instances', 10),
|
|
|
|
('max_total_keypairs', 100),
|
|
|
|
('max_total_ram_size', 51200),
|
|
|
|
('personality', 5),
|
|
|
|
('personality_size', 10240),
|
|
|
|
('security_group_rules', 20),
|
|
|
|
('security_groups', 10),
|
|
|
|
('security_groups_used', 0),
|
|
|
|
('server_group_members', 10),
|
|
|
|
('server_groups', 10),
|
|
|
|
('server_groups_used', 0),
|
|
|
|
('server_meta', 128),
|
|
|
|
('total_cores', 20),
|
|
|
|
('total_cores_used', 0),
|
|
|
|
('total_floating_ips_used', 0),
|
|
|
|
('total_instances_used', 0),
|
|
|
|
('total_ram', 51200),
|
|
|
|
('total_ram_used', 0),
|
|
|
|
('total_security_groups_used', 0),
|
|
|
|
('total_server_groups_used', 0),
|
|
|
|
]
|
|
|
|
self.rate_data = [
|
|
|
|
('POST', '*', 10, 2, 'MINUTE', '2011-12-15T22:42:45Z'),
|
|
|
|
('PUT', '*', 10, 2, 'MINUTE', '2011-12-15T22:42:45Z'),
|
|
|
|
('DELETE', '*', 100, 100, 'MINUTE', '2011-12-15T22:42:45Z'),
|
|
|
|
]
|
|
|
|
|
|
|
|
self.compute_sdk_client.get_limits.return_value = self.fake_limits
|
2018-04-02 15:07:25 -07:00
|
|
|
|
|
|
|
def test_compute_show_absolute(self):
|
|
|
|
arglist = ['--absolute']
|
|
|
|
verifylist = [('is_absolute', True)]
|
|
|
|
cmd = limits.ShowLimits(self.app, None)
|
|
|
|
parsed_args = self.check_parser(cmd, arglist, verifylist)
|
|
|
|
|
|
|
|
columns, data = cmd.take_action(parsed_args)
|
|
|
|
|
|
|
|
self.assertEqual(self.absolute_columns, columns)
|
2023-07-17 15:34:44 +05:30
|
|
|
self.assertEqual(self.absolute_data, data)
|
2018-04-02 15:07:25 -07:00
|
|
|
|
|
|
|
def test_compute_show_rate(self):
|
|
|
|
arglist = ['--rate']
|
|
|
|
verifylist = [('is_rate', True)]
|
|
|
|
cmd = limits.ShowLimits(self.app, None)
|
|
|
|
parsed_args = self.check_parser(cmd, arglist, verifylist)
|
|
|
|
|
|
|
|
columns, data = cmd.take_action(parsed_args)
|
|
|
|
|
|
|
|
self.assertEqual(self.rate_columns, columns)
|
2023-07-17 15:34:44 +05:30
|
|
|
self.assertEqual(self.rate_data, data)
|
2018-04-02 15:07:25 -07:00
|
|
|
|
|
|
|
|
|
|
|
class TestVolumeLimits(volume_fakes.TestVolume):
|
2023-07-17 15:34:44 +05:30
|
|
|
absolute_columns = ['Name', 'Value']
|
2023-05-08 11:35:45 +01:00
|
|
|
rate_columns = ["Verb", "URI", "Value", "Remain", "Unit", "Next Available"]
|
2018-04-02 15:07:25 -07:00
|
|
|
|
|
|
|
def setUp(self):
|
2022-09-29 18:42:26 +01:00
|
|
|
super().setUp()
|
2018-04-02 15:07:25 -07:00
|
|
|
self.app.client_manager.compute_endpoint_enabled = False
|
|
|
|
|
2023-07-17 15:34:44 +05:30
|
|
|
self.fake_limits = volume_fakes.create_limits()
|
|
|
|
|
|
|
|
self.absolute_data = [
|
|
|
|
('max_total_backup_gigabytes', 1000),
|
|
|
|
('max_total_backups', 10),
|
|
|
|
('max_total_snapshots', 10),
|
|
|
|
('max_total_volume_gigabytes', 1000),
|
|
|
|
('max_total_volumes', 10),
|
|
|
|
('total_backup_gigabytes_used', 0),
|
|
|
|
('total_backups_used', 0),
|
|
|
|
('total_gigabytes_used', 35),
|
|
|
|
('total_snapshots_used', 1),
|
|
|
|
('total_volumes_used', 4),
|
|
|
|
]
|
|
|
|
self.rate_data = [
|
|
|
|
('POST', '*', 10, 2, 'MINUTE', '2011-12-15T22:42:45Z'),
|
|
|
|
('PUT', '*', 10, 2, 'MINUTE', '2011-12-15T22:42:45Z'),
|
|
|
|
('DELETE', '*', 100, 100, 'MINUTE', '2011-12-15T22:42:45Z'),
|
|
|
|
]
|
|
|
|
|
|
|
|
self.volume_sdk_client.get_limits.return_value = self.fake_limits
|
2018-04-02 15:07:25 -07:00
|
|
|
|
|
|
|
def test_volume_show_absolute(self):
|
|
|
|
arglist = ['--absolute']
|
|
|
|
verifylist = [('is_absolute', True)]
|
|
|
|
cmd = limits.ShowLimits(self.app, None)
|
|
|
|
parsed_args = self.check_parser(cmd, arglist, verifylist)
|
|
|
|
|
|
|
|
columns, data = cmd.take_action(parsed_args)
|
|
|
|
|
|
|
|
self.assertEqual(self.absolute_columns, columns)
|
2023-07-17 15:34:44 +05:30
|
|
|
self.assertEqual(self.absolute_data, data)
|
2018-04-02 15:07:25 -07:00
|
|
|
|
|
|
|
def test_volume_show_rate(self):
|
|
|
|
arglist = ['--rate']
|
|
|
|
verifylist = [('is_rate', True)]
|
|
|
|
cmd = limits.ShowLimits(self.app, None)
|
|
|
|
parsed_args = self.check_parser(cmd, arglist, verifylist)
|
|
|
|
|
|
|
|
columns, data = cmd.take_action(parsed_args)
|
|
|
|
|
|
|
|
self.assertEqual(self.rate_columns, columns)
|
2023-07-17 15:34:44 +05:30
|
|
|
self.assertEqual(self.rate_data, data)
|