1eab70c6747da20c54cc740c68da0f94b4bb992f
[yardstick.git] /
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 import instantiation_validation_benchmark as base
17 from experimental_framework import common
18
19
20 NUM_OF_NEIGHBORS = 'num_of_neighbours'
21 AMOUNT_OF_RAM = 'amount_of_ram'
22 NUMBER_OF_CORES = 'number_of_cores'
23 NETWORK_NAME = 'network'
24 SUBNET_NAME = 'subnet'
25
26
27 class InstantiationValidationNoisyNeighborsBenchmark(
28         base.InstantiationValidationBenchmark):
29
30     def __init__(self, name, params):
31         base.InstantiationValidationBenchmark.__init__(self, name, params)
32
33         if common.RELEASE == 'liberty':
34             temp_name = 'stress_workload_liberty.yaml'
35         else:
36             temp_name = 'stress_workload.yaml'
37
38         self.template_file = common.get_template_dir() + \
39             temp_name
40         self.stack_name = 'neighbour'
41         self.neighbor_stack_names = list()
42
43     def get_features(self):
44         features = super(InstantiationValidationNoisyNeighborsBenchmark,
45                          self).get_features()
46         features['description'] = 'Instantiation Validation Benchmark ' \
47                                   'with noisy neghbors'
48         features['parameters'].append(NUM_OF_NEIGHBORS)
49         features['parameters'].append(AMOUNT_OF_RAM)
50         features['parameters'].append(NUMBER_OF_CORES)
51         features['parameters'].append(NETWORK_NAME)
52         features['parameters'].append(SUBNET_NAME)
53         features['allowed_values'][NUM_OF_NEIGHBORS] = \
54             ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
55         features['allowed_values'][NUMBER_OF_CORES] = \
56             ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
57         features['allowed_values'][AMOUNT_OF_RAM] = \
58             ['256M', '1G', '2G', '3G', '4G', '5G', '6G', '7G', '8G', '9G',
59              '10G']
60         features['default_values'][NUM_OF_NEIGHBORS] = '1'
61         features['default_values'][NUMBER_OF_CORES] = '1'
62         features['default_values'][AMOUNT_OF_RAM] = '256M'
63         features['default_values'][NETWORK_NAME] = ''
64         features['default_values'][SUBNET_NAME] = ''
65         return features
66
67     def init(self):
68         super(InstantiationValidationNoisyNeighborsBenchmark, self).init()
69         common.replace_in_file(self.lua_file, 'local out_file = ""',
70                                'local out_file = "' +
71                                self.results_file + '"')
72         heat_param = dict()
73         heat_param['network'] = self.params[NETWORK_NAME]
74         heat_param['subnet'] = self.params[SUBNET_NAME]
75         heat_param['cores'] = self.params['number_of_cores']
76         heat_param['memory'] = self.params['amount_of_ram']
77         for i in range(0, int(self.params['num_of_neighbours'])):
78             stack_name = self.stack_name + str(i)
79             common.DEPLOYMENT_UNIT.deploy_heat_template(self.template_file,
80                                                         stack_name,
81                                                         heat_param)
82             self.neighbor_stack_names.append(stack_name)
83
84     def finalize(self):
85         common.replace_in_file(self.lua_file, 'local out_file = "' +
86                                self.results_file + '"',
87                                'local out_file = ""')
88         # destroy neighbor stacks
89         for stack_name in self.neighbor_stack_names:
90             common.DEPLOYMENT_UNIT.destroy_heat_template(stack_name)
91         self.neighbor_stack_names = list()