ba1e0cc81d315fd085987ceb787ac12a8c986842
[yardstick.git] / yardstick / vTC / apexlake / experimental_framework / benchmarks / multi_tenancy_throughput_benchmark.py
1 # Copyright (c) 2015 Intel Research and Development Ireland Ltd.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15
16 from experimental_framework.benchmarks import rfc2544_throughput_benchmark \
17     as base
18 from experimental_framework import common
19
20
21 class MultiTenancyThroughputBenchmark(base.RFC2544ThroughputBenchmark):
22
23     def __init__(self, name, params):
24         base.RFC2544ThroughputBenchmark.__init__(self, name, params)
25         self.template_file = "{}{}".format(common.get_template_dir(),
26                                            'stress_workload.yaml')
27         self.stack_name = 'neighbour'
28         self.neighbor_stack_names = list()
29
30     def get_features(self):
31         features = super(MultiTenancyThroughputBenchmark, self).get_features()
32         features['description'] = \
33             'RFC 2544 Throughput calculation with ' \
34             'memory-bound noisy neighbors'
35         features['parameters'].append('num_of_neighbours')
36         features['parameters'].append('amount_of_ram')
37         features['parameters'].append('number_of_cores')
38         features['allowed_values']['num_of_neighbours'] = \
39             ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
40         features['allowed_values']['number_of_cores'] = \
41             ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
42         features['allowed_values']['amount_of_ram'] = \
43             ['250M', '1G', '2G', '3G', '4G', '5G', '6G', '7G', '8G', '9G',
44              '10G']
45         features['default_values']['num_of_neighbours'] = '1'
46         features['default_values']['number_of_cores'] = '1'
47         features['default_values']['amount_of_ram'] = '250M'
48         return features
49
50     def init(self):
51         """
52         Initialize the benchmark
53         return: None
54         """
55         common.replace_in_file(self.lua_file, 'local out_file = ""',
56                                'local out_file = "' +
57                                self.results_file + '"')
58         heat_param = dict()
59         heat_param['cores'] = self.params['number_of_cores']
60         heat_param['memory'] = self.params['amount_of_ram']
61         for i in range(0, int(self.params['num_of_neighbours'])):
62             stack_name = self.stack_name + str(i)
63             common.DEPLOYMENT_UNIT.deploy_heat_template(self.template_file,
64                                                         stack_name,
65                                                         heat_param)
66             self.neighbor_stack_names.append(stack_name)
67
68     def finalize(self):
69         """
70         Finalizes the benchmark
71         return: None
72         """
73         common.replace_in_file(self.lua_file, 'local out_file = "' +
74                                self.results_file + '"',
75                                'local out_file = ""')
76         # destroy neighbor stacks
77         for stack_name in self.neighbor_stack_names:
78             common.DEPLOYMENT_UNIT.destroy_heat_template(stack_name)
79         self.neighbor_stack_names = list()