summaryrefslogtreecommitdiffstats
path: root/yardstick/__init__.py
blob: 1ad6eb0b10cf79af9d869a71c5bff893f8df8ea1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
##############################################################################
# Copyright (c) 2015 Ericsson AB and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

from __future__ import absolute_import
import logging
import os
import sys

import yardstick.vTC.apexlake as apexlake
from yardstick.common import constants
from yardstick.common import utils as yardstick_utils

# Hack to be able to run apexlake unit tests
# without having to install apexlake.
sys.path.append(os.path.dirname(apexlake.__file__))

yardstick_utils.makedirs(constants.YARDSTICK_LOG_DIR)
LOG_FILE = os.path.join(constants.YARDSTICK_LOG_DIR, 'yardstick.log')
LOG_FORMATTER = ('%(asctime)s '
                 '%(name)s %(filename)s:%(lineno)d '
                 '%(levelname)s %(message)s')

_LOG_FORMATTER = logging.Formatter(LOG_FORMATTER)
_LOG_STREAM_HDLR = logging.StreamHandler()
_LOG_FILE_HDLR = logging.FileHandler(LOG_FILE)

LOG = logging.getLogger(__name__)


def _init_logging():

    _LOG_STREAM_HDLR.setFormatter(_LOG_FORMATTER)

    # don't append to log file, clobber
    _LOG_FILE_HDLR.setFormatter(_LOG_FORMATTER)
    # set log file to store debug info
    _LOG_FILE_HDLR.setLevel(logging.DEBUG)

    del logging.root.handlers[:]
    logging.root.addHandler(_LOG_STREAM_HDLR)
    logging.root.addHandler(_LOG_FILE_HDLR)
    logging.debug("logging.root.handlers = %s", logging.root.handlers)

    if os.environ.get('CI_DEBUG', '').lower() in {'1', 1, 'y', "yes", "true"}:
        LOG.setLevel(logging.DEBUG)
    else:
        LOG.setLevel(logging.INFO)
/ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ .highlight .sc { color: #e6db74 } /* Literal.String.Char */ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */ .highlight .se { color: #ae81ff } /* Literal.String.Escape */ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */ .highlight .sx { color: #e6db74 } /* Literal.String.Other */ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ } @media (prefers-color-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
# 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.

import unittest
import mock
from experimental_framework.benchmarking_unit import BenchmarkingUnit
# from experimental_framework.data_manager import DataManager
from experimental_framework.deployment_unit import DeploymentUnit
import experimental_framework.common as common
from experimental_framework.benchmarks.rfc2544_throughput_benchmark import \
    RFC2544ThroughputBenchmark

__author__ = 'vmriccox'


# class DummyDataManager(DataManager):
#
#     def __init__(self, experiment_directory):
#         self.experiment_directory = experiment_directory
#         self.experiments = dict()
#         self.new_exp_counter = 0
#         self.add_bench_counter = 0
#         self.close_experiment_1_counter = 0
#         self.close_experiment_2_counter = 0
#         self.generate_csv_counter = 0
#
#     def create_new_experiment(self, experiment_name, get_counter=None):
#         if not get_counter:
#             self.new_exp_counter += 1
#         else:
#             return self.new_exp_counter
#
#   def add_benchmark(self, experiment_name, benchmark_name, get_counter=None):
#         if not get_counter:
#             self.add_bench_counter += 1
#         else:
#             return self.add_bench_counter
#
#     def close_experiment(self, experiment, get_counter=None):
#         if get_counter:
#             return [self.close_experiment_1_counter,
#                     self.close_experiment_2_counter]
#         if experiment == 'VTC_base_single_vm_wait_1':
#             self.close_experiment_1_counter += 1
#         if experiment == 'VTC_base_single_vm_wait_2':
#             self.close_experiment_2_counter += 1
#
#     def generate_result_csv_file(self, get_counter=None):
#         if get_counter:
#             return self.generate_csv_counter
#         else:
#             self.generate_csv_counter += 1
#
#     def add_metadata(self, experiment_name, metadata):
#         pass
#
#     def add_configuration(self, experiment_name, configuration):
#         pass
#
#     def add_data_points(self, experiment_name, benchmark_name, result):
#         pass


class Dummy_2544(RFC2544ThroughputBenchmark):

    def __init__(self, name, params):
        self.name = name
        self.init_counter = 0
        self.finalize_counter = 0
        self.run_counter = 0
        self.params = params

    def init(self, get_counter=None):
        if get_counter:
            return self.init_counter
        else:
            self.init_counter += 1

    def finalize(self, get_counter=None):
        if get_counter:
            return self.finalize_counter
        else:
            self.finalize_counter += 1

    def run(self, get_counter=None):
        if get_counter:
            return self.run_counter
        else:
            self.run_counter += 1
        return {'throughput': 10}


class DummyDeploymentUnit(DeploymentUnit):

    def __init__(self, openstack_credentials):
        pass

    def deploy_heat_template(self, template_file, stack_name, parameters,
                             attempt=0):
        return False


class TestBenchmarkingUnit(unittest.TestCase):

    def setUp(self):
        pass

    def tearDown(self):
        pass

    @mock.patch('time.time')
    @mock.patch('experimental_framework.common.get_template_dir')
    # @mock.patch('experimental_framework.data_manager.DataManager',
    #             side_effect=DummyDataManager)
    @mock.patch('experimental_framework.deployment_unit.DeploymentUnit')
    @mock.patch('experimental_framework.benchmarking_unit.heat.'
                'get_all_heat_templates')
    def test___init__(self, mock_heat, mock_dep_unit,
                      # mock_data_manager,
                      mock_temp_dir, mock_time):
        mock_heat.return_value = list()
        mock_time.return_value = '12345'
        mock_temp_dir.return_value = 'tests/data/results/'
        common.TEMPLATE_FILE_EXTENSION = '.ext'
        common.RESULT_DIR = 'tests/data/results/'
        heat_template_name = 'name'
        openstack_credentials = {
            'name': 'aaa',
            'surname': 'bbb'
        }
        heat_template_parameters = {
            'param_1': 'name_1',
            'param_2': 'name_2'
        }
        iterations = 1
        benchmarks = ['bench_1', 'bench_2']
        bu = BenchmarkingUnit(heat_template_name,
                              openstack_credentials,
                              heat_template_parameters,
                              iterations,
                              benchmarks)
        self.assertEqual(bu.required_benchmarks, benchmarks)
        bu.heat_template_parameters = heat_template_parameters
        # mock_data_manager.assert_called_once_with('tests/data/results/12345')
        mock_dep_unit.assert_called_once_with(openstack_credentials)
        mock_heat.assert_called_once_with('tests/data/results/', '.ext')

    @mock.patch('experimental_framework.benchmarks.'
                'rfc2544_throughput_benchmark', side_effect=Dummy_2544)
    @mock.patch('time.time')
    @mock.patch('experimental_framework.common.get_template_dir')
    # @mock.patch('experimental_framework.data_manager.DataManager',
    #             side_effect=DummyDataManager)
    @mock.patch('experimental_framework.deployment_unit.DeploymentUnit')
    @mock.patch('experimental_framework.benchmarking_unit.'
                'heat.get_all_heat_templates')
    def test_initialize_for_success(self, mock_heat, mock_dep_unit,
                                    # mock_data_manager,
                                    mock_temp_dir,
                                    mock_time, mock_rfc2544):
        mock_heat.return_value = list()
        mock_time.return_value = '12345'
        mock_temp_dir.return_value = 'tests/data/test_templates/'
        common.TEMPLATE_FILE_EXTENSION = '.yaml'
        common.RESULT_DIR = 'tests/data/results/'

        heat_template_name = 'VTC_base_single_vm_wait_'
        openstack_credentials = {
            'name': 'aaa',
            'surname': 'bbb'
        }
        heat_template_parameters = {
            'param_1': 'name_1',
            'param_2': 'name_2'
        }
        iterations = 1
        benchmarks = [
            {
                'name':
                    'rfc2544_throughput_benchmark.RFC2544ThroughputBenchmark',
                'params': dict()
            }
        ]
        bu = BenchmarkingUnit(heat_template_name,
                              openstack_credentials,
                              heat_template_parameters,
                              iterations,
                              benchmarks)
        self.assertEqual(bu.required_benchmarks, benchmarks)
        bu.heat_template_parameters = heat_template_parameters
        bu.template_files = ['VTC_base_single_vm_wait_1.yaml',
                             'VTC_base_single_vm_wait_2.yaml']
        bu.initialize()
        self.assertTrue(len(bu.benchmarks) == 1)
        self.assertEqual(bu.benchmarks[0].__class__,
                         Dummy_2544)
        # self.assertEqual(bu.data_manager.create_new_experiment('', True), 2)
        # self.assertEqual(bu.data_manager.add_benchmark('', '', True), 2)

    @mock.patch('experimental_framework.benchmarks.'
                'rfc2544_throughput_benchmark', side_effect=Dummy_2544)
    @mock.patch('time.time')
    @mock.patch('experimental_framework.common.get_template_dir')
    # @mock.patch('experimental_framework.data_manager.DataManager',
    #             side_effect=DummyDataManager)
    @mock.patch('experimental_framework.deployment_unit.DeploymentUnit')
    @mock.patch('experimental_framework.benchmarking_unit.'
                'heat.get_all_heat_templates')
    def test_finalize_for_success(
            self, mock_heat, mock_dep_unit,
            # mock_data_manager,
            mock_temp_dir, mock_time, mock_rfc2544):
        mock_heat.return_value = list()
        mock_time.return_value = '12345'
        mock_temp_dir.return_value = 'tests/data/test_templates/'
        common.TEMPLATE_FILE_EXTENSION = '.yaml'
        common.RESULT_DIR = 'tests/data/results/'

        heat_template_name = 'VTC_base_single_vm_wait_'
        openstack_credentials = {
            'name': 'aaa',
            'surname': 'bbb'
        }
        heat_template_parameters = {
            'param_1': 'name_1',
            'param_2': 'name_2'
        }
        iterations = 1
        benchmarks = [
            {
                'name':
                    'rfc2544_throughput_benchmark.RFC2544ThroughputBenchmark',
                'params': dict()
            }
        ]
        bu = BenchmarkingUnit(heat_template_name,
                              openstack_credentials,
                              heat_template_parameters,
                              iterations,
                              benchmarks)
        bu.heat_template_parameters = heat_template_parameters
        bu.template_files = ['VTC_base_single_vm_wait_1.yaml',
                             'VTC_base_single_vm_wait_2.yaml']
        bu.finalize()
        # self.assertEqual(bu.data_manager.close_experiment('', True), [1, 1])
        # self.assertEqual(bu.data_manager.generate_result_csv_file(True), 1)

    @mock.patch('experimental_framework.common.push_data_influxdb')
    @mock.patch('experimental_framework.common.LOG')
    @mock.patch('experimental_framework.benchmarks.'
                'rfc2544_throughput_benchmark', side_effect=Dummy_2544)
    @mock.patch('time.time')
    @mock.patch('experimental_framework.common.get_template_dir')
    # @mock.patch('experimental_framework.data_manager.DataManager',
    #             side_effect=DummyDataManager)
    @mock.patch('experimental_framework.common.DEPLOYMENT_UNIT')
    @mock.patch('experimental_framework.deployment_unit.DeploymentUnit')
    @mock.patch('experimental_framework.benchmarking_unit.'
                'heat.get_all_heat_templates')
    def test_run_benchmarks_for_success(self, mock_heat, mock_common_dep_unit,
                                        mock_dep_unit,
                                        # mock_data_manager,
                                        mock_temp_dir, mock_time,
                                        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/'
        common.TEMPLATE_FILE_EXTENSION = '.yaml'
        common.RESULT_DIR = 'tests/data/results/'
        common.INFLUXDB_IP = 'InfluxIP'
        common.INFLUXDB_PORT = '8086'
        common.INFLUXDB_DB_NAME = 'test_db'

        heat_template_name = 'VTC_base_single_vm_wait_'
        openstack_credentials = {
            'name': 'aaa',
            'surname': 'bbb'
        }
        heat_template_parameters = {
            'param_1': 'name_1',
            'param_2': 'name_2'
        }
        iterations = 1
        benchmarks = [
            {
                'name':
                    'rfc2544_throughput_benchmark.RFC2544ThroughputBenchmark',
                'params': dict()
            }
        ]
        bu = BenchmarkingUnit(heat_template_name,
                              openstack_credentials,
                              heat_template_parameters,
                              iterations,
                              benchmarks)
        # bu.data_manager = DummyDataManager('tests/data/results/12345')
        bu.template_files = ['VTC_base_single_vm_wait_1.yaml',
                             'VTC_base_single_vm_wait_2.yaml']
        bu.benchmarks = [Dummy_2544('dummy', {'param1': 'val1'})]
        bu.run_benchmarks()
        self.assertEqual(bu.benchmarks[0].init(True), 2)
        self.assertEqual(bu.benchmarks[0].finalize(True), 2)
        self.assertEqual(bu.benchmarks[0].run(True), 2)
        # expected_metric = \
        #     'throughput,vnic_type=direct,ram=1024,benchmark=dummy,' \
        #     'vcpus=2,experiment_name=VTC_base_single_vm_wait_2,' \
        #     'param1=val1 value=10 12345000000000'
        # mock_influx.assert_called_with(expected_metric)

    @mock.patch('experimental_framework.common.LOG')
    @mock.patch('experimental_framework.benchmarks.'
                'rfc2544_throughput_benchmark', side_effect=Dummy_2544)
    @mock.patch('time.time')
    @mock.patch('experimental_framework.common.get_template_dir')
    # @mock.patch('experimental_framework.data_manager.DataManager',
    #             side_effect=DummyDataManager)
    @mock.patch('experimental_framework.common.DEPLOYMENT_UNIT')
    @mock.patch('experimental_framework.deployment_unit.DeploymentUnit')
    @mock.patch('experimental_framework.benchmarking_unit.'
                'heat.get_all_heat_templates')
    def test_run_benchmarks_2_for_success(
            self, mock_heat, mock_common_dep_unit, mock_dep_unit,
            # mock_data_manager,
            mock_temp_dir, mock_time, mock_rfc2544,
            mock_log):
        mock_heat.return_value = list()
        mock_time.return_value = '12345'
        mock_temp_dir.return_value = 'tests/data/test_templates/'
        common.TEMPLATE_FILE_EXTENSION = '.yaml'
        common.RESULT_DIR = 'tests/data/results/'

        heat_template_name = 'VTC_base_single_vm_wait_'
        openstack_credentials = {
            'name': 'aaa',
            'surname': 'bbb'
        }
        heat_template_parameters = {
            'param_1': 'name_1',
            'param_2': 'name_2'
        }
        iterations = 1
        benchmarks = [
            {
                'name':
                    'rfc2544_throughput_benchmark.RFC2544ThroughputBenchmark',
                'params': dict()
            }
        ]
        bu = BenchmarkingUnit(heat_template_name,
                              openstack_credentials,
                              heat_template_parameters,
                              iterations,
                              benchmarks)
        # bu.data_manager = DummyDataManager('tests/data/results/12345')
        bu.template_files = ['VTC_base_single_vm_wait_1.yaml',
                             'VTC_base_single_vm_wait_2.yaml']
        bu.benchmarks = [Dummy_2544('dummy', dict())]
        common.DEPLOYMENT_UNIT = DummyDeploymentUnit(dict())
        bu.run_benchmarks()
        self.assertEqual(bu.benchmarks[0].init(True), 2)
        self.assertEqual(bu.benchmarks[0].finalize(True), 0)
        self.assertEqual(bu.benchmarks[0].run(True), 0)

    @mock.patch('experimental_framework.common.LOG')
    @mock.patch('experimental_framework.benchmarks.'
                'rfc2544_throughput_benchmark', side_effect=Dummy_2544)
    @mock.patch('time.time')
    @mock.patch('experimental_framework.common.get_template_dir')
    # @mock.patch('experimental_framework.data_manager.DataManager',
    #             side_effect=DummyDataManager)
    @mock.patch('experimental_framework.common.DEPLOYMENT_UNIT')
    @mock.patch('experimental_framework.deployment_unit.DeploymentUnit')
    @mock.patch('experimental_framework.benchmarking_unit.'
                'heat.get_all_heat_templates')
    def test_get_benchmark_name_for_success(
            self, mock_heat, mock_common_dep_unit, mock_dep_unit,
            # mock_data_manager,
            mock_temp_dir, mock_time, mock_rfc2544,
            mock_log):
        mock_heat.return_value = list()
        mock_time.return_value = '12345'
        mock_temp_dir.return_value = 'tests/data/test_templates/'
        common.TEMPLATE_FILE_EXTENSION = '.yaml'
        common.RESULT_DIR = 'tests/data/results/'

        heat_template_name = 'VTC_base_single_vm_wait_'
        openstack_credentials = {
            'name': 'aaa',
            'surname': 'bbb'
        }
        heat_template_parameters = {
            'param_1': 'name_1',
            'param_2': 'name_2'
        }
        iterations = 1
        benchmarks = [
            {
                'name':
                    'rfc2544_throughput_benchmark.RFC2544ThroughputBenchmark',
                'params': dict()
            }
        ]
        bu = BenchmarkingUnit(heat_template_name,
                              openstack_credentials,
                              heat_template_parameters,
                              iterations,
                              benchmarks)

        expected = 'rfc2544_throughput_benchmark.RFC2544ThroughputBenchmark_0'
        output = bu.get_benchmark_name(
            'rfc2544_throughput_benchmark.RFC2544ThroughputBenchmark')
        self.assertEqual(expected, output)

        expected = 'rfc2544_throughput_benchmark.RFC2544ThroughputBenchmark_1'
        output = bu.get_benchmark_name(
            'rfc2544_throughput_benchmark.RFC2544ThroughputBenchmark')
        self.assertEqual(expected, output)

    @mock.patch('experimental_framework.common.LOG')
    @mock.patch('experimental_framework.benchmarks.'
                'rfc2544_throughput_benchmark', side_effect=Dummy_2544)
    @mock.patch('time.time')
    @mock.patch('experimental_framework.common.get_template_dir')
    # @mock.patch('experimental_framework.data_manager.DataManager',
    #             side_effect=DummyDataManager)
    @mock.patch('experimental_framework.common.DEPLOYMENT_UNIT')
    @mock.patch('experimental_framework.deployment_unit.DeploymentUnit')
    @mock.patch('experimental_framework.benchmarking_unit.'
                'heat.get_all_heat_templates')
    def test_get_required_benchmarks_for_success(
            self, mock_heat, mock_common_dep_unit, mock_dep_unit,
            # mock_data_manager,
            mock_temp_dir, mock_time, mock_rfc2544,
            mock_log):
        mock_heat.return_value = list()
        mock_time.return_value = '12345'
        mock_temp_dir.return_value = 'tests/data/test_templates/'
        common.TEMPLATE_FILE_EXTENSION = '.yaml'
        common.RESULT_DIR = 'tests/data/results/'
        openstack_credentials = {
            'name': 'aaa',
            'surname': 'bbb'
        }
        heat_template_parameters = {
            'param_1': 'name_1',
            'param_2': 'name_2'
        }
        iterations = 1
        benchmarks = [
            {
                'name':
                    'rfc2544_throughput_benchmark.RFC2544ThroughputBenchmark',
                'params': dict()
            }
        ]
        bu = BenchmarkingUnit('',
                              openstack_credentials,
                              heat_template_parameters,
                              iterations,
                              benchmarks)
        req_benchs = \
            ['rfc2544_throughput_benchmark.RFC2544ThroughputBenchmark']
        output = bu.get_required_benchmarks(req_benchs)
        self.assertEqual(len(req_benchs), 1)
        self.assertEqual(output[0].__class__, Dummy_2544)