1 # Copyright (c) 2015 Intel Research and Development Ireland Ltd.
 
   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
 
   7 #      http://www.apache.org/licenses/LICENSE-2.0
 
   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.
 
  16 import instantiation_validation_benchmark as base
 
  17 from experimental_framework import common
 
  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'
 
  27 class InstantiationValidationNoisyNeighborsBenchmark(
 
  28         base.InstantiationValidationBenchmark):
 
  30     def __init__(self, name, params):
 
  31         base.InstantiationValidationBenchmark.__init__(self, name, params)
 
  32         self.template_file = common.get_template_dir() + \
 
  33             'stress_workload.yaml'
 
  34         self.stack_name = 'neighbour'
 
  35         self.neighbor_stack_names = list()
 
  37     def get_features(self):
 
  38         features = super(InstantiationValidationNoisyNeighborsBenchmark,
 
  40         features['description'] = 'Instantiation Validation Benchmark ' \
 
  42         features['parameters'].append(NUM_OF_NEIGHBORS)
 
  43         features['parameters'].append(AMOUNT_OF_RAM)
 
  44         features['parameters'].append(NUMBER_OF_CORES)
 
  45         features['parameters'].append(NETWORK_NAME)
 
  46         features['parameters'].append(SUBNET_NAME)
 
  47         features['allowed_values'][NUM_OF_NEIGHBORS] = \
 
  48             ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
 
  49         features['allowed_values'][NUMBER_OF_CORES] = \
 
  50             ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
 
  51         features['allowed_values'][AMOUNT_OF_RAM] = \
 
  52             ['256M', '1G', '2G', '3G', '4G', '5G', '6G', '7G', '8G', '9G',
 
  54         features['default_values'][NUM_OF_NEIGHBORS] = '1'
 
  55         features['default_values'][NUMBER_OF_CORES] = '1'
 
  56         features['default_values'][AMOUNT_OF_RAM] = '256M'
 
  57         features['default_values'][NETWORK_NAME] = ''
 
  58         features['default_values'][SUBNET_NAME] = ''
 
  62         super(InstantiationValidationNoisyNeighborsBenchmark, self).init()
 
  63         common.replace_in_file(self.lua_file, 'local out_file = ""',
 
  64                                'local out_file = "' +
 
  65                                self.results_file + '"')
 
  67         heat_param['network'] = self.params[NETWORK_NAME]
 
  68         heat_param['subnet'] = self.params[SUBNET_NAME]
 
  69         heat_param['cores'] = self.params['number_of_cores']
 
  70         heat_param['memory'] = self.params['amount_of_ram']
 
  71         for i in range(0, int(self.params['num_of_neighbours'])):
 
  72             stack_name = self.stack_name + str(i)
 
  73             common.DEPLOYMENT_UNIT.deploy_heat_template(self.template_file,
 
  76             self.neighbor_stack_names.append(stack_name)
 
  79         common.replace_in_file(self.lua_file, 'local out_file = "' +
 
  80                                self.results_file + '"',
 
  81                                'local out_file = ""')
 
  82         # destroy neighbor stacks
 
  83         for stack_name in self.neighbor_stack_names:
 
  84             common.DEPLOYMENT_UNIT.destroy_heat_template(stack_name)
 
  85         self.neighbor_stack_names = list()