示例#1
0
 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')
    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)
示例#3
0
    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)
示例#4
0
 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)
示例#5
0
    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 = 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'
        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)
示例#6
0
    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)
示例#7
0
    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)
示例#8
0
 def __init__(self):
     BenchmarkingUnit.__init__(self)
示例#9
0
 def __init__(self):
     BenchmarkingUnit.__init__(self)