diff options
author | Ross Brattain <ross.b.brattain@intel.com> | 2017-07-31 20:10:20 -0700 |
---|---|---|
committer | Ross Brattain <ross.b.brattain@intel.com> | 2017-07-31 20:46:46 -0700 |
commit | d455f3b56c866b0e61394a01f0a07e05831f3044 (patch) | |
tree | f1d3a289a70fb9265d6f891e4bde5fbf63d44612 /yardstick/vTC/apexlake/tests/deployment_unit_test.py | |
parent | 5ad208bd8d0c1798179de226f28f1e1ec03033fa (diff) |
DRAFT: remove apexlake
apexlake is unmaintained, so remove it
From some reason orchestrator/heat.py started failing
so fixup those unittests
Change-Id: Ie06508b5ab7c9dcf9fdfca83e173a188a894d564
Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Diffstat (limited to 'yardstick/vTC/apexlake/tests/deployment_unit_test.py')
-rw-r--r-- | yardstick/vTC/apexlake/tests/deployment_unit_test.py | 279 |
1 files changed, 0 insertions, 279 deletions
diff --git a/yardstick/vTC/apexlake/tests/deployment_unit_test.py b/yardstick/vTC/apexlake/tests/deployment_unit_test.py deleted file mode 100644 index 1ff4225d6..000000000 --- a/yardstick/vTC/apexlake/tests/deployment_unit_test.py +++ /dev/null @@ -1,279 +0,0 @@ -# Copyright (c) 2015 Intel Research and Development Ireland Ltd. -# -# 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 __future__ import absolute_import -import unittest -import logging -import mock -import experimental_framework.deployment_unit as mut -import experimental_framework.common as common - -__author__ = 'vmriccox' - - -class DummyHeatManager: - - def __init__(self, param): - self.counts = 0 - pass - - def validate_heat_template(self, template_file): - return True - - def check_stack_status(self, stack_name): - # return 'CREATE_COMPLETE' - self.counts += 1 - if self.counts >= 3: - return 'CREATE_COMPLETE' - else: - return 'CREATE_IN_PROGRESS' - - def delete_stack(self, stack_name): - pass - - -class DummyHeatManagerFailed(DummyHeatManager): - - def check_stack_status(self, stack_name): - return 'CREATE_FAILED' - - def create_stack(self, template_file, stack_name, parameters): - pass - - -class DummyHeatManagerComplete(DummyHeatManager): - - def check_stack_status(self, stack_name): - return 'CREATE_COMPLETE' - - def create_stack(self, template_file, stack_name, parameters): - raise Exception() - - -class DummyHeatManagerFailedException(DummyHeatManagerFailed): - - def create_stack(self, template_file, stack_name, parameters): - raise Exception - - def check_stack_status(self, stack_name): - return '' - - -class DummyHeatManagerDestroy: - - def __init__(self, credentials): - self.delete_stack_counter = 0 - self.check_stack_status_counter = 0 - - def check_stack_status(self, stack_name): - if self.check_stack_status_counter < 2: - self.check_stack_status_counter += 1 - return 'DELETE_IN_PROGRESS' - else: - return 'DELETE_COMPLETE' - - def create_stack(self, template_file, stack_name, parameters): - pass - - def delete_stack(self, stack_name=None): - if stack_name == 'stack': - self.delete_stack_counter += 1 - else: - return self.delete_stack_counter - - def is_stack_deployed(self, stack_name): - return True - - -class DummyHeatManagerDestroyException(DummyHeatManagerDestroy): - - def delete_stack(self, stack_name=None): - raise Exception - - -class DummyHeatManagerReiteration: - - def __init__(self, param): - self.counts = 0 - - def validate_heat_template(self, template_file): - return True - - def check_stack_status(self, stack_name): - return 'CREATE_FAILED' - - def delete_stack(self, stack_name): - pass - - def create_stack(self, template_file=None, stack_name=None, - parameters=None): - if template_file == 'template_reiteration' and \ - stack_name == 'stack_reiteration' and \ - parameters == 'parameters_reiteration': - self.counts += 1 - - -class DummyDeploymentUnit(mut.DeploymentUnit): - - def destroy_heat_template(self, stack_name): - raise Exception - - -@mock.patch("experimental_framework.deployment_unit.time") -class TestDeploymentUnit(unittest.TestCase): - - def setUp(self): - pass - - def tearDown(self): - pass - - @mock.patch('experimental_framework.heat_manager.HeatManager', - side_effect=DummyHeatManager) - def test_constructor_for_sanity(self, mock_heat_manager, mock_time): - du = mut.DeploymentUnit(dict()) - self.assertTrue(isinstance(du.heat_manager, DummyHeatManager)) - mock_heat_manager.assert_called_once_with(dict()) - self.assertEqual(du.deployed_stacks, list()) - - @mock.patch('experimental_framework.heat_manager.HeatManager', - side_effect=DummyHeatManager) - @mock.patch('os.path.isfile') - def test_deploy_heat_template_for_failure(self, mock_os_is_file, - mock_heat_manager, mock_time): - mock_os_is_file.return_value = False - du = mut.DeploymentUnit(dict()) - template_file = '' - stack_name = '' - parameters = '' - self.assertRaises(ValueError, du.deploy_heat_template, template_file, - stack_name, parameters, 0) - - @mock.patch('experimental_framework.heat_manager.HeatManager', - side_effect=DummyHeatManager) - @mock.patch('os.path.isfile') - def test_deploy_heat_template_for_success(self, mock_os_is_file, - mock_heat_manager, mock_time): - mock_os_is_file.return_value = True - du = mut.DeploymentUnit(dict()) - template_file = '' - stack_name = '' - parameters = '' - common.LOG = logging.getLogger() - output = du.deploy_heat_template(template_file, stack_name, - parameters, 0) - self.assertEqual(output, True) - - @mock.patch('experimental_framework.heat_manager.HeatManager', - side_effect=DummyHeatManagerComplete) - @mock.patch('os.path.isfile') - def test_deploy_heat_template_2_for_success(self, mock_os_is_file, - mock_heat_manager, mock_time): - mock_os_is_file.return_value = True - du = mut.DeploymentUnit(dict()) - template_file = '' - stack_name = '' - parameters = '' - common.LOG = logging.getLogger() - output = du.deploy_heat_template(template_file, stack_name, - parameters, 0) - self.assertEqual(output, True) - - @mock.patch('experimental_framework.heat_manager.HeatManager', - side_effect=DummyHeatManagerComplete) - @mock.patch('os.path.isfile') - @mock.patch('experimental_framework.deployment_unit.DeploymentUnit', - side_effect=DummyDeploymentUnit) - def test_deploy_heat_template_3_for_success(self, mock_dep_unit, - mock_os_is_file, - mock_heat_manager, mock_time): - mock_os_is_file.return_value = True - du = mut.DeploymentUnit(dict()) - template_file = '' - stack_name = '' - parameters = '' - common.LOG = logging.getLogger() - output = du.deploy_heat_template(template_file, stack_name, - parameters, 0) - self.assertEqual(output, True) - - @mock.patch('experimental_framework.common.LOG') - @mock.patch('experimental_framework.heat_manager.HeatManager', - side_effect=DummyHeatManagerFailed) - @mock.patch('os.path.isfile') - def test_deploy_heat_template_for_success_2(self, mock_os_is_file, - mock_heat_manager, mock_log, mock_time): - mock_os_is_file.return_value = True - du = DummyDeploymentUnit(dict()) - template_file = '' - stack_name = '' - parameters = '' - output = du.deploy_heat_template(template_file, stack_name, - parameters, 0) - self.assertEqual(output, False) - - @mock.patch('experimental_framework.heat_manager.HeatManager', - side_effect=DummyHeatManagerDestroy) - @mock.patch('experimental_framework.common.LOG') - def test_destroy_heat_template_for_success(self, mock_log, - mock_heat_manager, mock_time): - openstack_credentials = dict() - du = mut.DeploymentUnit(openstack_credentials) - du.deployed_stacks = ['stack'] - stack_name = 'stack' - self.assertTrue(du.destroy_heat_template(stack_name)) - self.assertEqual(du.heat_manager.delete_stack(None), 1) - - @mock.patch('experimental_framework.heat_manager.HeatManager', - side_effect=DummyHeatManagerDestroyException) - @mock.patch('experimental_framework.common.LOG') - def test_destroy_heat_template_for_success_2(self, mock_log, - mock_heat_manager, mock_time): - openstack_credentials = dict() - du = mut.DeploymentUnit(openstack_credentials) - du.deployed_stacks = ['stack'] - stack_name = 'stack' - self.assertFalse(du.destroy_heat_template(stack_name)) - - def test_destroy_all_deployed_stacks_for_success(self, mock_time): - du = DeploymentUnitDestroy() - du.destroy_all_deployed_stacks() - self.assertTrue(du.destroy_heat_template()) - - @mock.patch('experimental_framework.heat_manager.HeatManager', - side_effect=DummyHeatManagerReiteration) - @mock.patch('os.path.isfile') - def test_deploy_heat_template_for_success_3(self, mock_os_is_file, - mock_heat_manager, mock_time): - mock_os_is_file.return_value = True - du = mut.DeploymentUnit(dict()) - template = 'template_reiteration' - stack = 'stack_reiteration' - parameters = 'parameters_reiteration' - output = du.deploy_heat_template(template, stack, parameters, 0) - self.assertFalse(output) - self.assertEqual(du.heat_manager.counts, 4) - - -class DeploymentUnitDestroy(mut.DeploymentUnit): - - def __init__(self): - self.deployed_stacks = ['stack'] - self.heat_manager = DummyHeatManagerDestroy(dict()) - self.destroy_all_deployed_stacks_called_correctly = False - - def destroy_heat_template(self, template_name=None): - if template_name == 'stack': - self.destroy_all_deployed_stacks_called_correctly = True - return self.destroy_all_deployed_stacks_called_correctly |