diff options
Diffstat (limited to 'yardstick/vTC/apexlake/tests')
15 files changed, 138 insertions, 84 deletions
diff --git a/yardstick/vTC/apexlake/tests/api_test.py b/yardstick/vTC/apexlake/tests/api_test.py index 4b70b9bd6..b6191ed8f 100644 --- a/yardstick/vTC/apexlake/tests/api_test.py +++ b/yardstick/vTC/apexlake/tests/api_test.py @@ -13,14 +13,18 @@ # limitations under the License. +from __future__ import absolute_import import unittest import mock import os import experimental_framework.common as common +from experimental_framework import APEX_LAKE_ROOT from experimental_framework.api import FrameworkApi from experimental_framework.benchmarking_unit import BenchmarkingUnit import experimental_framework.benchmarks.\ instantiation_validation_benchmark as iv +from six.moves import map +from six.moves import range class DummyBenchmarkingUnit(BenchmarkingUnit): @@ -61,6 +65,7 @@ class DummyBenchmarkingUnit2(BenchmarkingUnit): class TestGeneratesTemplate(unittest.TestCase): + def setUp(self): pass @@ -92,11 +97,11 @@ class TestGeneratesTemplate(unittest.TestCase): iv.VLAN_RECEIVER] expected['allowed_values'] = dict() expected['allowed_values'][iv.THROUGHPUT] = \ - map(str, range(0, 100)) + list(map(str, list(range(0, 100)))) expected['allowed_values'][iv.VLAN_SENDER] = \ - map(str, range(-1, 4096)) + list(map(str, list(range(-1, 4096)))) expected['allowed_values'][iv.VLAN_RECEIVER] = \ - map(str, range(-1, 4096)) + list(map(str, list(range(-1, 4096)))) expected['default_values'] = dict() expected['default_values'][iv.THROUGHPUT] = '1' expected['default_values'][iv.VLAN_SENDER] = '-1' @@ -121,9 +126,8 @@ class TestGeneratesTemplate(unittest.TestCase): def test_execute_framework_for_success(self, mock_b_unit, mock_heat, mock_credentials, mock_log, mock_common_init): - common.TEMPLATE_DIR = "{}/{}/".format( - os.getcwd(), 'tests/data/generated_templates' - ) + common.TEMPLATE_DIR = os.path.join(APEX_LAKE_ROOT, + 'tests/data/generated_templates/') test_cases = dict() iterations = 1 diff --git a/yardstick/vTC/apexlake/tests/base_packet_generator_test.py b/yardstick/vTC/apexlake/tests/base_packet_generator_test.py index b0e27d069..153de171d 100644 --- a/yardstick/vTC/apexlake/tests/base_packet_generator_test.py +++ b/yardstick/vTC/apexlake/tests/base_packet_generator_test.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import absolute_import import unittest from experimental_framework.packet_generators import base_packet_generator diff --git a/yardstick/vTC/apexlake/tests/benchmark_base_class_test.py b/yardstick/vTC/apexlake/tests/benchmark_base_class_test.py index 405c0102f..4e5eb9fb0 100644 --- a/yardstick/vTC/apexlake/tests/benchmark_base_class_test.py +++ b/yardstick/vTC/apexlake/tests/benchmark_base_class_test.py @@ -13,6 +13,7 @@ # limitations under the License. +from __future__ import absolute_import import unittest from experimental_framework.benchmarks import benchmark_base_class as base @@ -45,8 +46,8 @@ class TestBenchmarkBaseClass(unittest.TestCase): params['C'] = 'c' bench_base = DummyBechmarkBaseClass(name, params) self.assertEqual(name, bench_base.name) - self.assertIn('A', bench_base.params.keys()) - self.assertIn('B', bench_base.params.keys()) + self.assertIn('A', list(bench_base.params.keys())) + self.assertIn('B', list(bench_base.params.keys())) self.assertEqual('a', bench_base.params['A']) self.assertEqual('b', bench_base.params['B']) diff --git a/yardstick/vTC/apexlake/tests/benchmarking_unit_test.py b/yardstick/vTC/apexlake/tests/benchmarking_unit_test.py index 652327aab..7b33ba693 100644 --- a/yardstick/vTC/apexlake/tests/benchmarking_unit_test.py +++ b/yardstick/vTC/apexlake/tests/benchmarking_unit_test.py @@ -11,9 +11,12 @@ # 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 os import unittest import mock + +from experimental_framework import APEX_LAKE_ROOT from experimental_framework.benchmarking_unit import BenchmarkingUnit # from experimental_framework.data_manager import DataManager from experimental_framework.deployment_unit import DeploymentUnit @@ -275,7 +278,8 @@ class TestBenchmarkingUnit(unittest.TestCase): mock_rfc2544, mock_log, mock_influx): mock_heat.return_value = list() mock_time.return_value = '12345' - mock_temp_dir.return_value = 'tests/data/test_templates/' + mock_temp_dir.return_value = os.path.join(APEX_LAKE_ROOT, + 'tests/data/test_templates/') common.TEMPLATE_FILE_EXTENSION = '.yaml' common.RESULT_DIR = 'tests/data/results/' common.INFLUXDB_IP = 'InfluxIP' @@ -336,7 +340,8 @@ class TestBenchmarkingUnit(unittest.TestCase): mock_log): mock_heat.return_value = list() mock_time.return_value = '12345' - mock_temp_dir.return_value = 'tests/data/test_templates/' + mock_temp_dir.return_value = os.path.join(APEX_LAKE_ROOT, + 'tests/data/test_templates/') common.TEMPLATE_FILE_EXTENSION = '.yaml' common.RESULT_DIR = 'tests/data/results/' diff --git a/yardstick/vTC/apexlake/tests/common_test.py b/yardstick/vTC/apexlake/tests/common_test.py index 486ed6d25..b8dbfe6b8 100644 --- a/yardstick/vTC/apexlake/tests/common_test.py +++ b/yardstick/vTC/apexlake/tests/common_test.py @@ -12,13 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import absolute_import import unittest import mock import os import logging -import ConfigParser +import six.moves.configparser import experimental_framework.common as common import experimental_framework.constants.conf_file_sections as cf +from experimental_framework import APEX_LAKE_ROOT __author__ = 'vmricco' @@ -47,6 +49,7 @@ def reset_common(): class DummyConfigurationFile(common.ConfigurationFile): + def __init__(self, sections, conf_file=''): pass @@ -58,6 +61,7 @@ class DummyConfigurationFile(common.ConfigurationFile): class DummyConfigurationFile2(common.ConfigurationFile): + def __init__(self, sections): self.pktgen_counter = 0 @@ -74,7 +78,7 @@ class DummyConfigurationFile2(common.ConfigurationFile): self.pktgen_counter += 1 return 'dpdk_pktgen' if variable_name == cf.CFSP_DPDK_PKTGEN_DIRECTORY: - return os.getcwd() + return APEX_LAKE_ROOT if variable_name == cf.CFSP_DPDK_PROGRAM_NAME: return 'program' if variable_name == cf.CFSP_DPDK_COREMASK: @@ -86,7 +90,7 @@ class DummyConfigurationFile2(common.ConfigurationFile): if variable_name == cf.CFSP_DPDK_BUS_SLOT_NIC_2: return 'bus_slot_nic_2' if variable_name == cf.CFSP_DPDK_DPDK_DIRECTORY: - return os.getcwd() + return APEX_LAKE_ROOT def get_variable_list(self, section): if section == cf.CFS_PKTGEN: @@ -114,8 +118,7 @@ class TestCommonInit(unittest.TestCase): def setUp(self): common.CONF_FILE = DummyConfigurationFile('') - self.dir = '{}/{}'.format(os.getcwd(), - 'experimental_framework/') + self.dir = os.path.join(APEX_LAKE_ROOT, 'experimental_framework/') def tearDown(self): reset_common() @@ -131,7 +134,8 @@ class TestCommonInit(unittest.TestCase): init_general_vars, init_conf_file, mock_getcwd): mock_getcwd.return_value = self.dir common.init(True) - init_pkgen.assert_called_once() + if common.CONF_FILE.get_variable_list(cf.CFS_PKTGEN): + init_pkgen.assert_called_once() init_conf_file.assert_called_once() init_general_vars.assert_called_once() init_log.assert_called_once() @@ -144,7 +148,7 @@ class TestCommonInit(unittest.TestCase): @mock.patch('experimental_framework.common.LOG') def test_init_general_vars_for_success(self, mock_log, mock_makedirs, mock_path_exists, mock_val_file): - common.BASE_DIR = "{}/".format(os.getcwd()) + common.BASE_DIR = APEX_LAKE_ROOT mock_path_exists.return_value = False mock_val_file.return_value = True common.init_general_vars() @@ -160,15 +164,19 @@ class TestCommonInit2(unittest.TestCase): def setUp(self): common.CONF_FILE = DummyConfigurationFile2('') - self.dir = '{}/{}'.format(os.getcwd(), 'experimental_framework/') + self.dir = os.path.join(APEX_LAKE_ROOT, 'experimental_framework') def tearDown(self): reset_common() common.CONF_FILE = None + @mock.patch('experimental_framework.common.InputValidation') + @mock.patch('os.path.exists') + @mock.patch('os.makedirs') @mock.patch('experimental_framework.common.LOG') - def test_init_general_vars_2_for_success(self, mock_log): - common.BASE_DIR = "{}/".format(os.getcwd()) + def test_init_general_vars_2_for_success(self, mock_log, mock_makedirs, + mock_path_exists, mock_val_file): + common.BASE_DIR = APEX_LAKE_ROOT common.init_general_vars() self.assertEqual(common.TEMPLATE_FILE_EXTENSION, '.yaml') self.assertEqual(common.TEMPLATE_DIR, '/tmp/apexlake/heat_templates/') @@ -183,14 +191,16 @@ class TestCommonInit2(unittest.TestCase): def test_init_pktgen_for_success(self): common.init_pktgen() self.assertEqual(common.PKTGEN, 'dpdk_pktgen') - directory = self.dir.split('experimental_framework/')[0] + directory = self.dir.split('experimental_framework')[0] self.assertEqual(common.PKTGEN_DIR, directory) self.assertEqual(common.PKTGEN_PROGRAM, 'program') self.assertEqual(common.PKTGEN_COREMASK, 'coremask') self.assertEqual(common.PKTGEN_MEMCHANNEL, 'memchannel') self.assertEqual(common.PKTGEN_BUS_SLOT_NIC_1, 'bus_slot_nic_1') self.assertEqual(common.PKTGEN_BUS_SLOT_NIC_2, 'bus_slot_nic_2') - expected_dir = "{}/".format(os.getcwd()) + # we always add '/' to end of dirs for some reason + # probably because we aren't using os.path.join everywhere + expected_dir = APEX_LAKE_ROOT + '/' self.assertEqual(common.PKTGEN_DPDK_DIRECTORY, expected_dir) def test_init_pktgen_for_failure(self): @@ -260,8 +270,8 @@ class TestConfigFileClass(unittest.TestCase): 'Deployment-parameters', 'Testcase-parameters' ] - c_file = './tests/data/common/conf.cfg' - common.BASE_DIR = os.getcwd() + c_file = os.path.join(APEX_LAKE_ROOT, 'tests/data/common/conf.cfg') + common.BASE_DIR = APEX_LAKE_ROOT self.conf_file = common.ConfigurationFile(self.sections, c_file) def tearDown(self): @@ -275,7 +285,8 @@ class TestConfigFileClass(unittest.TestCase): sections = ['General', 'OpenStack', 'Experiment-VNF', 'PacketGen', 'Deployment-parameters', 'Testcase-parameters'] c = DummyConfigurationFile3( - sections, config_file='./tests/data/common/conf.cfg') + sections, config_file=os.path.join(APEX_LAKE_ROOT, + 'tests/data/common/conf.cfg')) self.assertEqual( DummyConfigurationFile3._config_section_map('', '', True), 6) @@ -285,8 +296,9 @@ class TestConfigFileClass(unittest.TestCase): def test__config_section_map_for_success(self): general_section = 'General' # openstack_section = 'OpenStack' - config_file = 'tests/data/common/conf.cfg' - config = ConfigParser.ConfigParser() + config_file = os.path.join(APEX_LAKE_ROOT, + 'tests/data/common/conf.cfg') + config = six.moves.configparser.ConfigParser() config.read(config_file) expected = { @@ -361,8 +373,9 @@ class TestCommonMethods(unittest.TestCase): 'Deployment-parameters', 'Testcase-parameters' ] - config_file = './tests/data/common/conf.cfg' - common.BASE_DIR = os.getcwd() + config_file = os.path.join(APEX_LAKE_ROOT, + 'tests/data/common/conf.cfg') + common.BASE_DIR = APEX_LAKE_ROOT common.CONF_FILE = DummyConfigurationFile4(self.sections, config_file) def tearDown(self): @@ -397,13 +410,14 @@ class TestCommonMethods(unittest.TestCase): self.assertEqual(expected, output) def test_get_file_first_line_for_success(self): - file = 'tests/data/common/conf.cfg' + file = os.path.join(APEX_LAKE_ROOT, 'tests/data/common/conf.cfg') expected = '[General]\n' output = common.get_file_first_line(file) self.assertEqual(expected, output) def test_replace_in_file_for_success(self): - filename = 'tests/data/common/file_replacement.txt' + filename = os.path.join(APEX_LAKE_ROOT, + 'tests/data/common/file_replacement.txt') text_to_search = 'replacement of' text_to_replace = '***' common.replace_in_file(filename, text_to_search, text_to_replace) @@ -542,27 +556,14 @@ class TestinputValidation(unittest.TestCase): list(), '' ) - def test_validate_file_exist_for_success(self): - filename = 'tests/data/common/file_replacement.txt' - output = common.InputValidation.validate_file_exist(filename, '') - self.assertTrue(output) - - def test_validate_file_exist_for_failure(self): - filename = 'tests/data/common/file_replacement' - self.assertRaises( - ValueError, - common.InputValidation.validate_file_exist, - filename, '' - ) - def test_validate_directory_exist_and_format_for_success(self): - directory = 'tests/data/common/' + directory = os.path.join(APEX_LAKE_ROOT, 'tests/data/common/') output = common.InputValidation.\ validate_directory_exist_and_format(directory, '') self.assertTrue(output) def test_validate_directory_exist_and_format_for_failure(self): - directory = 'tests/data/com/' + directory = os.path.join(APEX_LAKE_ROOT, 'tests/data/com/') self.assertRaises( ValueError, common.InputValidation.validate_directory_exist_and_format, diff --git a/yardstick/vTC/apexlake/tests/conf_file_sections_test.py b/yardstick/vTC/apexlake/tests/conf_file_sections_test.py index 2b03edb04..abf4134a5 100644 --- a/yardstick/vTC/apexlake/tests/conf_file_sections_test.py +++ b/yardstick/vTC/apexlake/tests/conf_file_sections_test.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import absolute_import import unittest from experimental_framework.constants import conf_file_sections as cfs diff --git a/yardstick/vTC/apexlake/tests/deployment_unit_test.py b/yardstick/vTC/apexlake/tests/deployment_unit_test.py index cec834e56..5a9178f53 100644 --- a/yardstick/vTC/apexlake/tests/deployment_unit_test.py +++ b/yardstick/vTC/apexlake/tests/deployment_unit_test.py @@ -12,6 +12,7 @@ # 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 diff --git a/yardstick/vTC/apexlake/tests/dpdk_packet_generator_test.py b/yardstick/vTC/apexlake/tests/dpdk_packet_generator_test.py index bad250e7b..96ead5ef7 100644 --- a/yardstick/vTC/apexlake/tests/dpdk_packet_generator_test.py +++ b/yardstick/vTC/apexlake/tests/dpdk_packet_generator_test.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import absolute_import import unittest import mock from experimental_framework.constants import conf_file_sections as conf_file @@ -287,10 +288,10 @@ class TestDpdkPacketGenSendTraffic(unittest.TestCase): mock_dir_name, mock_os_path, mock_os_system): - ''' + """ Calls the packet generator and starts to send traffic Blocking call - ''' + """ mock_get_core_nics.return_value = "{corenics}" mock_os_path.realpath.return_value = 'pktgen_dir_test' mock_os_path.dirname.return_value = 'current_directory' diff --git a/yardstick/vTC/apexlake/tests/generates_template_test.py b/yardstick/vTC/apexlake/tests/generates_template_test.py index dad3177d6..cc3e1bf6e 100644 --- a/yardstick/vTC/apexlake/tests/generates_template_test.py +++ b/yardstick/vTC/apexlake/tests/generates_template_test.py @@ -12,11 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import absolute_import import unittest import experimental_framework.heat_template_generation as heat_gen import mock import os import experimental_framework.common as common +from experimental_framework import APEX_LAKE_ROOT __author__ = 'gpetralx' @@ -45,6 +47,7 @@ def reset_common(): class TestGeneratesTemplate(unittest.TestCase): + def setUp(self): self.deployment_configuration = { 'vnic_type': ['normal', 'direct'], @@ -61,9 +64,11 @@ class TestGeneratesTemplate(unittest.TestCase): @mock.patch('experimental_framework.common.get_template_dir') def test_generates_template_for_success(self, mock_template_dir, mock_log): - generated_templates_dir = 'tests/data/generated_templates/' + generated_templates_dir = os.path.join( + APEX_LAKE_ROOT, 'tests/data/generated_templates/') mock_template_dir.return_value = generated_templates_dir - test_templates = 'tests/data/test_templates/' + test_templates = os.path.join(APEX_LAKE_ROOT, + 'tests/data/test_templates/') heat_gen.generates_templates(self.template_name, self.deployment_configuration) for dirname, dirnames, filenames in os.walk(test_templates): @@ -73,8 +78,9 @@ class TestGeneratesTemplate(unittest.TestCase): self.assertListEqual(test.readlines(), generated.readlines()) - t_name = '/tests/data/generated_templates/VTC_base_single_vm_wait.tmp' - self.template_name = "{}{}".format(os.getcwd(), t_name) + self.template_name = os.path.join( + APEX_LAKE_ROOT, + 'tests/data/generated_templates/VTC_base_single_vm_wait.tmp') heat_gen.generates_templates(self.template_name, self.deployment_configuration) for dirname, dirnames, filenames in os.walk(test_templates): @@ -86,7 +92,8 @@ class TestGeneratesTemplate(unittest.TestCase): @mock.patch('experimental_framework.common.get_template_dir') def test_get_all_heat_templates_for_success(self, template_dir): - generated_templates = 'tests/data/generated_templates/' + generated_templates = os.path.join(APEX_LAKE_ROOT, + 'tests/data/generated_templates/') template_dir.return_value = generated_templates extension = '.yaml' expected = ['experiment_1.yaml', 'experiment_2.yaml'] diff --git a/yardstick/vTC/apexlake/tests/heat_manager_test.py b/yardstick/vTC/apexlake/tests/heat_manager_test.py index 0fe8554cd..58bd75560 100644 --- a/yardstick/vTC/apexlake/tests/heat_manager_test.py +++ b/yardstick/vTC/apexlake/tests/heat_manager_test.py @@ -12,11 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import print_function + +from __future__ import absolute_import +import os import unittest import logging import experimental_framework.common as common -from experimental_framework import heat_manager +from experimental_framework import heat_manager, APEX_LAKE_ROOT import mock __author__ = 'gpetralx' @@ -27,6 +31,7 @@ def get_mock_heat(version, *args, **kwargs): class MockStacks(object): + def __init__(self, stacks): self.stacks = stacks @@ -34,7 +39,7 @@ class MockStacks(object): list_name = list() for stack in self.stacks: list_name.append(stack.stack_name) - print list_name + print(list_name) return self.stacks def validate(self, template=None): @@ -47,11 +52,12 @@ class MockStacks(object): def create(self, stack_name=None, files=None, template=None, parameters=None): - print stack_name + print(stack_name) self.stacks.append(MockStack(stack_name)) class MockStacks_2(object): + def __init__(self, stacks): self.stacks = stacks @@ -60,6 +66,7 @@ class MockStacks_2(object): class MockStack(object): + def __init__(self, stack_name): self.name = stack_name @@ -80,6 +87,7 @@ class MockStack(object): class MockHeat(object): + def __init__(self): stacks = [MockStack('stack_1'), MockStack('stack_2')] self.stacks_list = MockStacks(stacks) @@ -90,18 +98,21 @@ class MockHeat(object): class MockHeat_2(MockHeat): + def __init__(self): stacks = [MockStack('stack_1'), MockStack('stack_2')] self.stacks_list = MockStacks_2(stacks) class HeatManagerMock(heat_manager.HeatManager): + def init_heat(self): if self.heat is None: self.heat = MockHeat() class HeatManagerMock_2(heat_manager.HeatManager): + def init_heat(self): if self.heat is None: self.heat = MockHeat_2() @@ -134,8 +145,9 @@ class TestHeatManager(unittest.TestCase): self.heat_manager.check_stack_status('stack_x')) def test_validate_template_for_success(self): - template_file = \ - 'tests/data/test_templates/VTC_base_single_vm_wait_1.yaml' + template_file = os.path.join( + APEX_LAKE_ROOT, + 'tests/data/test_templates/VTC_base_single_vm_wait_1.yaml') with self.assertRaises(ValueError): self.heat_manager.validate_heat_template(template_file) @@ -180,11 +192,13 @@ class TestHeatManager_2(unittest.TestCase): class ServiceCatalog(): + def url_for(self, service_type): return 'http://heat_url' class KeystoneMock(object): + @property def auth_token(self): return 'token' @@ -193,6 +207,7 @@ class KeystoneMock(object): class TestHeatInit(unittest.TestCase): + def setUp(self): credentials = dict() credentials['ip_controller'] = '1.1.1.1' @@ -216,5 +231,5 @@ class TestHeatInit(unittest.TestCase): tenant_name='project', password='password', auth_url='auth_uri') - heat_client.assert_called_once_with('1', endpoint='http://heat_url', + heat_client.assert_called_once_with('1', endpoint='http://heat_url', token='token') diff --git a/yardstick/vTC/apexlake/tests/instantiation_validation_bench_test.py b/yardstick/vTC/apexlake/tests/instantiation_validation_bench_test.py index 369129a00..2bd8b7b38 100644 --- a/yardstick/vTC/apexlake/tests/instantiation_validation_bench_test.py +++ b/yardstick/vTC/apexlake/tests/instantiation_validation_bench_test.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import absolute_import import unittest import mock import os @@ -21,6 +22,8 @@ import experimental_framework.benchmarks.\ instantiation_validation_benchmark as iv_module from experimental_framework.benchmarks.\ instantiation_validation_benchmark import InstantiationValidationBenchmark +from six.moves import map +from six.moves import range kill_counter = [0, 0] @@ -204,11 +207,11 @@ class InstantiationValidationInitTest(unittest.TestCase): ] expected['allowed_values'] = dict() expected['allowed_values'][iv_module.THROUGHPUT] = \ - map(str, range(0, 100)) + list(map(str, list(range(0, 100)))) expected['allowed_values'][iv_module.VLAN_SENDER] = \ - map(str, range(-1, 4096)) + list(map(str, list(range(-1, 4096)))) expected['allowed_values'][iv_module.VLAN_RECEIVER] = \ - map(str, range(-1, 4096)) + list(map(str, list(range(-1, 4096)))) expected['default_values'] = dict() expected['default_values'][iv_module.THROUGHPUT] = '1' expected['default_values'][iv_module.VLAN_SENDER] = '-1' @@ -216,7 +219,7 @@ class InstantiationValidationInitTest(unittest.TestCase): output = self.iv.get_features() self.assertEqual(expected, output) - @mock.patch('commands.getoutput') + @mock.patch('subprocess.check_output') def test__get_pids_for_success(self, mock_getoutput): expected = [1234] mock_getoutput.return_value = '1234' diff --git a/yardstick/vTC/apexlake/tests/instantiation_validation_noisy_bench_test.py b/yardstick/vTC/apexlake/tests/instantiation_validation_noisy_bench_test.py index f65600f6e..f9aa9473f 100644 --- a/yardstick/vTC/apexlake/tests/instantiation_validation_noisy_bench_test.py +++ b/yardstick/vTC/apexlake/tests/instantiation_validation_noisy_bench_test.py @@ -12,13 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import absolute_import import unittest import mock -import os + +from six.moves import range + import experimental_framework.common as common import experimental_framework.deployment_unit as deploy import experimental_framework.benchmarks.\ instantiation_validation_noisy_neighbors_benchmark as mut +from experimental_framework import APEX_LAKE_ROOT class InstantiationValidationInitTest(unittest.TestCase): @@ -34,7 +38,7 @@ class InstantiationValidationInitTest(unittest.TestCase): openstack_credentials['heat_url'] = '' openstack_credentials['password'] = '' common.DEPLOYMENT_UNIT = deploy.DeploymentUnit(openstack_credentials) - common.BASE_DIR = os.getcwd() + common.BASE_DIR = APEX_LAKE_ROOT common.TEMPLATE_DIR = 'tests/data/generated_templates' self.iv = mut.\ InstantiationValidationNoisyNeighborsBenchmark(name, params) @@ -72,9 +76,11 @@ class InstantiationValidationInitTest(unittest.TestCase): expected['parameters'].append(mut.NUM_OF_NEIGHBORS) expected['parameters'].append(mut.AMOUNT_OF_RAM) expected['parameters'].append(mut.NUMBER_OF_CORES) - expected['allowed_values']['throughput'] = map(str, range(0, 100)) - expected['allowed_values']['vlan_sender'] = map(str, range(-1, 4096)) - expected['allowed_values']['vlan_receiver'] = map(str, range(-1, 4096)) + expected['allowed_values']['throughput'] = [str(x) for x in range(100)] + expected['allowed_values']['vlan_sender'] = [str(x) for x in + range(-1, 4096)] + expected['allowed_values']['vlan_receiver'] = [str(x) for x in + range(-1, 4096)] expected['allowed_values'][mut.NUM_OF_NEIGHBORS] = \ ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'] expected['allowed_values'][mut.NUMBER_OF_CORES] = \ @@ -115,10 +121,10 @@ class InstantiationValidationInitTest(unittest.TestCase): 'num_of_neighbours': 1} self.iv.template_file = 'template.yaml' self.iv.init() - mock_replace.assert_called_once_wih('file', - 'local out_file = ""', - 'local out_file = "' + - 'res_file' + '"') + mock_replace.assert_called_once_with('file', + 'local out_file = ""', + 'local out_file = "' + + 'res_file' + '"') mock_deploy_heat.assert_called_once_with('template.yaml', 'neighbour0', {'cores': 1, @@ -131,12 +137,14 @@ class InstantiationValidationInitTest(unittest.TestCase): @mock.patch('experimental_framework.common.' 'DEPLOYMENT_UNIT.destroy_heat_template') def test_finalize_for_success(self, mock_heat_destroy, mock_replace): + self.iv.lua_file = 'file' + self.iv.results_file = 'res_file' self.iv.neighbor_stack_names = ['neighbor0'] stack_name = 'neighbor0' self.iv.finalize() mock_heat_destroy.assert_called_once_with(stack_name) - mock_replace.assert_called_once_wih('file', - 'local out_file = ""', - 'local out_file = "' + - 'res_file' + '"') + mock_replace.assert_called_once_with('file', + 'local out_file = "' + + 'res_file' + '"', + 'local out_file = ""') self.assertEqual(self.iv.neighbor_stack_names, list()) diff --git a/yardstick/vTC/apexlake/tests/multi_tenancy_throughput_benchmark_test.py b/yardstick/vTC/apexlake/tests/multi_tenancy_throughput_benchmark_test.py index fc5a7fddb..39b38d7d3 100644 --- a/yardstick/vTC/apexlake/tests/multi_tenancy_throughput_benchmark_test.py +++ b/yardstick/vTC/apexlake/tests/multi_tenancy_throughput_benchmark_test.py @@ -12,17 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import absolute_import import unittest import mock import os import experimental_framework.common as common from experimental_framework.benchmarks \ import multi_tenancy_throughput_benchmark as bench +from six.moves import range __author__ = 'gpetralx' class MockDeploymentUnit(object): + def deploy_heat_template(self, temp_file, stack_name, heat_param): pass @@ -35,6 +38,7 @@ def get_deployment_unit(): class TestMultiTenancyThroughputBenchmark(unittest.TestCase): + def setUp(self): name = 'benchmark' params = dict() @@ -47,9 +51,9 @@ class TestMultiTenancyThroughputBenchmark(unittest.TestCase): def test_get_features_for_sanity(self): output = self.benchmark.get_features() self.assertIsInstance(output, dict) - self.assertIn('parameters', output.keys()) - self.assertIn('allowed_values', output.keys()) - self.assertIn('default_values', output.keys()) + self.assertIn('parameters', list(output.keys())) + self.assertIn('allowed_values', list(output.keys())) + self.assertIn('default_values', list(output.keys())) self.assertIsInstance(output['parameters'], list) self.assertIsInstance(output['allowed_values'], dict) self.assertIsInstance(output['default_values'], dict) diff --git a/yardstick/vTC/apexlake/tests/rfc2544_throughput_benchmark_test.py b/yardstick/vTC/apexlake/tests/rfc2544_throughput_benchmark_test.py index ef3b0dabb..487de7775 100644 --- a/yardstick/vTC/apexlake/tests/rfc2544_throughput_benchmark_test.py +++ b/yardstick/vTC/apexlake/tests/rfc2544_throughput_benchmark_test.py @@ -13,6 +13,7 @@ # limitations under the License. +from __future__ import absolute_import import unittest import mock import os @@ -37,9 +38,9 @@ class RFC2544ThroughputBenchmarkRunTest(unittest.TestCase): def test_get_features_for_sanity(self): output = self.benchmark.get_features() self.assertIsInstance(output, dict) - self.assertIn('parameters', output.keys()) - self.assertIn('allowed_values', output.keys()) - self.assertIn('default_values', output.keys()) + self.assertIn('parameters', list(output.keys())) + self.assertIn('allowed_values', list(output.keys())) + self.assertIn('default_values', list(output.keys())) self.assertIsInstance(output['parameters'], list) self.assertIsInstance(output['allowed_values'], dict) self.assertIsInstance(output['default_values'], dict) @@ -74,7 +75,6 @@ class RFC2544ThroughputBenchmarkRunTest(unittest.TestCase): output = self.benchmark.run() self.assertEqual(expected, output) conf_lua_file_mock.assert_called_once() - reset_lua_file_mock.assert_called_once() dpdk_instance = mock_dpdk() dpdk_instance.init_dpdk_pktgen.assert_called_once_with( dpdk_interfaces=2, pcap_file_0='packet_1.pcap', diff --git a/yardstick/vTC/apexlake/tests/tree_node_test.py b/yardstick/vTC/apexlake/tests/tree_node_test.py index e51343f0e..fb38b69bd 100644 --- a/yardstick/vTC/apexlake/tests/tree_node_test.py +++ b/yardstick/vTC/apexlake/tests/tree_node_test.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import absolute_import import unittest import experimental_framework.heat_template_generation as heat_gen @@ -19,6 +20,7 @@ __author__ = 'gpetralx' class TestTreeNode(unittest.TestCase): + def setUp(self): self.tree = heat_gen.TreeNode() |