Merge "Remove unused function "check_hypervisor_stats""

This commit is contained in:
Jenkins 2017-07-03 15:21:08 +00:00 committed by Gerrit Code Review
commit a80f22445b
3 changed files with 2 additions and 113 deletions

View File

@ -28,32 +28,6 @@ from tripleoclient import exceptions
from tripleoclient import utils
class TestCheckHypervisorUtil(TestCase):
def test_check_hypervisor_stats(self):
mock_compute = mock.Mock()
mock_stats = mock.Mock()
return_values = [
{'count': 0, 'memory_mb': 0, 'vcpus': 0},
{'count': 1, 'memory_mb': 1, 'vcpus': 1},
]
mock_stats.to_dict.side_effect = return_values
mock_compute.hypervisors.statistics.return_value = mock_stats
stats = utils.check_hypervisor_stats(
mock_compute, nodes=1, memory=1, vcpu=1)
self.assertIsNone(stats)
self.assertEqual(mock_stats.to_dict.call_count, 1)
stats = utils.check_hypervisor_stats(
mock_compute, nodes=1, memory=1, vcpu=1)
self.assertEqual(stats, return_values[-1])
self.assertEqual(mock_stats.to_dict.call_count, 2)
class TestWaitForStackUtil(TestCase):
def setUp(self):
self.mock_orchestration = mock.Mock()

View File

@ -72,13 +72,10 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
autospec=True)
@mock.patch('heatclient.common.template_utils.get_template_contents',
autospec=True)
@mock.patch('tripleoclient.utils.check_hypervisor_stats',
autospec=True)
@mock.patch('uuid.uuid1', autospec=True)
@mock.patch('time.time', autospec=True)
@mock.patch('shutil.copytree', autospec=True)
def test_tht_scale(self, mock_copy, mock_time, mock_uuid1,
mock_check_hypervisor_stats,
mock_get_template_contents,
wait_for_stack_ready_mock,
mock_remove_known_hosts,
@ -113,11 +110,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_env = yaml.safe_dump({'environments': []})
object_client.get_object.return_value = ({}, mock_env)
mock_check_hypervisor_stats.return_value = {
'count': 4,
'memory_mb': 4096,
'vcpus': 8,
}
clients.network.api.find_attr.return_value = {
"id": "network id"
}
@ -184,15 +176,12 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
autospec=True)
@mock.patch('heatclient.common.template_utils.get_template_contents',
autospec=True)
@mock.patch('tripleoclient.utils.check_hypervisor_stats',
autospec=True)
@mock.patch('uuid.uuid1', autospec=True)
@mock.patch('time.time', autospec=True)
@mock.patch('shutil.copytree', autospec=True)
@mock.patch('tempfile.mkdtemp', autospec=True)
def test_tht_deploy(self, mock_tmpdir, mock_copy, mock_time,
mock_uuid1,
mock_check_hypervisor_stats,
mock_get_template_contents,
wait_for_stack_ready_mock,
mock_remove_known_hosts,
@ -230,11 +219,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
orchestration_client.stacks.create.side_effect = _orch_clt_create
mock_check_hypervisor_stats.return_value = {
'count': 4,
'memory_mb': 4096,
'vcpus': 8,
}
clients.network.api.find_attr.return_value = {
"id": "network id"
}
@ -313,17 +297,14 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
autospec=True)
@mock.patch('heatclient.common.template_utils.get_template_contents',
autospec=True)
@mock.patch('tripleoclient.utils.check_hypervisor_stats',
autospec=True)
@mock.patch('uuid.uuid1', autospec=True)
@mock.patch('time.time', autospec=True)
@mock.patch('shutil.copytree', autospec=True)
@mock.patch('tempfile.mkdtemp', autospec=True)
def test_tht_deploy_with_plan_environment_file(
self, mock_tmpdir, mock_copy, mock_time, mock_uuid1,
mock_check_hypervisor_stats, mock_get_template_contents,
wait_for_stack_ready_mock, mock_remove_known_hosts,
mock_overcloudrc, mock_write_overcloudrc,
mock_get_template_contents, wait_for_stack_ready_mock,
mock_remove_known_hosts, mock_overcloudrc, mock_write_overcloudrc,
mock_create_tempest_deployer, mock_create_parameters_env,
mock_validate_args, mock_breakpoints_cleanup,
mock_tarball, mock_postconfig,
@ -358,11 +339,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_env = yaml.safe_dump({'environments': []})
object_client.get_object.return_value = ({}, mock_env)
mock_check_hypervisor_stats.return_value = {
'count': 4,
'memory_mb': 4096,
'vcpus': 8,
}
clients.network.api.find_attr.return_value = {
"id": "network id"
}
@ -446,8 +422,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
autospec=True)
@mock.patch('heatclient.common.template_utils.get_template_contents',
autospec=True)
@mock.patch('tripleoclient.utils.check_hypervisor_stats',
autospec=True)
@mock.patch('uuid.uuid1', autospec=True)
@mock.patch('time.time', autospec=True)
@mock.patch('shutil.rmtree', autospec=True)
@ -456,7 +430,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
def test_tht_deploy_skip_deploy_identifier(
self, mock_tmpdir, mock_copy, mock_rm, mock_time,
mock_uuid1,
mock_check_hypervisor_stats,
mock_get_template_contents,
wait_for_stack_ready_mock,
mock_remove_known_hosts,
@ -494,11 +467,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_env = yaml.safe_dump({'environments': []})
object_client.get_object.return_value = ({}, mock_env)
mock_check_hypervisor_stats.return_value = {
'count': 4,
'memory_mb': 4096,
'vcpus': 8,
}
clients.network.api.find_attr.return_value = {
"id": "network id"
}
@ -540,11 +508,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
autospec=True)
@mock.patch('heatclient.common.template_utils.get_template_contents',
autospec=True)
@mock.patch('tripleoclient.utils.check_hypervisor_stats',
autospec=True)
@mock.patch('shutil.copytree', autospec=True)
def test_deploy_custom_templates(self, mock_copy,
mock_check_hypervisor_stats,
mock_get_template_contents,
wait_for_stack_ready_mock,
mock_remove_known_hosts,
@ -564,11 +529,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
orchestration_client.stacks.get.return_value = fakes.create_tht_stack()
mock_events.return_value = []
mock_check_hypervisor_stats.return_value = {
'count': 4,
'memory_mb': 4096,
'vcpus': 8,
}
clients.network.api.find_attr.return_value = {
"id": "network id"
}
@ -874,13 +834,10 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
'process_environment_and_files', autospec=True)
@mock.patch('heatclient.common.template_utils.get_template_contents',
autospec=True)
@mock.patch('tripleoclient.utils.check_hypervisor_stats',
autospec=True)
@mock.patch('shutil.copytree', autospec=True)
@mock.patch('tempfile.mkdtemp', autospec=True)
@mock.patch('shutil.rmtree', autospec=True)
def test_deploy_rhel_reg(self, mock_rmtree, mock_tmpdir, mock_copy,
mock_check_hypervisor_stats,
mock_get_template_contents,
mock_process_env,
wait_for_stack_ready_mock,
@ -923,11 +880,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_env = yaml.safe_dump({'environments': []})
object_client.get_object.return_value = ({}, mock_env)
mock_check_hypervisor_stats.return_value = {
'count': 4,
'memory_mb': 4096,
'vcpus': 8,
}
clients.network.api.find_attr.return_value = {
"id": "network id"
}
@ -1231,14 +1183,11 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
'process_environment_and_files', autospec=True)
@mock.patch('heatclient.common.template_utils.get_template_contents',
autospec=True)
@mock.patch('tripleoclient.utils.check_hypervisor_stats',
autospec=True)
@mock.patch('uuid.uuid1', autospec=True)
@mock.patch('time.time', autospec=True)
@mock.patch('shutil.copytree', autospec=True)
def test_tht_deploy_with_ntp(self, mock_copy, mock_time,
mock_uuid1,
mock_check_hypervisor_stats,
mock_get_template_contents,
mock_process_env,
wait_for_stack_ready_mock,
@ -1284,11 +1233,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_env = yaml.safe_dump({'environments': []})
object_client.get_object.return_value = ({}, mock_env)
mock_check_hypervisor_stats.return_value = {
'count': 4,
'memory_mb': 4096,
'vcpus': 8,
}
clients.network.api.find_attr.return_value = {
"id": "network id"
}

View File

@ -139,35 +139,6 @@ def create_tempest_deployer_input(config_name='tempest-deployer-input.conf'):
config.write(config_file)
def check_hypervisor_stats(compute_client, nodes=1, memory=0, vcpu=0):
"""Check the Hypervisor stats meet a minimum value
Check the hypervisor stats match the required counts. This is an
implementation of a command in TripleO with the same name.
:param compute_client: Instance of Nova client
:type compute_client: novaclient.client.v2.Client
:param nodes: The number of nodes to wait for, defaults to 1.
:type nodes: int
:param memory: The amount of memory to wait for in MB, defaults to 0.
:type memory: int
:param vcpu: The number of vcpus to wait for, defaults to 0.
:type vcpu: int
"""
statistics = compute_client.hypervisors.statistics().to_dict()
if all([statistics['count'] >= nodes,
statistics['memory_mb'] >= memory,
statistics['vcpus'] >= vcpu]):
return statistics
else:
return None
def wait_for_stack_ready(orchestration_client, stack_name, marker=None,
action='CREATE', verbose=False):
"""Check the status of an orchestration stack