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 from __future__ import absolute_import
 
  17 from experimental_framework import common
 
  18 from experimental_framework.benchmarks import \
 
  19     instantiation_validation_benchmark as base
 
  20 from six.moves import range
 
  23 NUM_OF_NEIGHBORS = 'num_of_neighbours'
 
  24 AMOUNT_OF_RAM = 'amount_of_ram'
 
  25 NUMBER_OF_CORES = 'number_of_cores'
 
  26 NETWORK_NAME = 'network'
 
  27 SUBNET_NAME = 'subnet'
 
  30 class InstantiationValidationNoisyNeighborsBenchmark(
 
  31         base.InstantiationValidationBenchmark):
 
  33     def __init__(self, name, params):
 
  34         base.InstantiationValidationBenchmark.__init__(self, name, params)
 
  36         if common.RELEASE == 'liberty':
 
  37             temp_name = 'stress_workload_liberty.yaml'
 
  39             temp_name = 'stress_workload.yaml'
 
  41         self.template_file = common.get_template_dir() + \
 
  43         self.stack_name = 'neighbour'
 
  44         self.neighbor_stack_names = []
 
  46     def get_features(self):
 
  47         features = super(InstantiationValidationNoisyNeighborsBenchmark,
 
  49         features['description'] = 'Instantiation Validation Benchmark ' \
 
  51         features['parameters'].append(NUM_OF_NEIGHBORS)
 
  52         features['parameters'].append(AMOUNT_OF_RAM)
 
  53         features['parameters'].append(NUMBER_OF_CORES)
 
  54         features['parameters'].append(NETWORK_NAME)
 
  55         features['parameters'].append(SUBNET_NAME)
 
  56         features['allowed_values'][NUM_OF_NEIGHBORS] = \
 
  57             ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
 
  58         features['allowed_values'][NUMBER_OF_CORES] = \
 
  59             ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
 
  60         features['allowed_values'][AMOUNT_OF_RAM] = \
 
  61             ['256M', '1G', '2G', '3G', '4G', '5G', '6G', '7G', '8G', '9G',
 
  63         features['default_values'][NUM_OF_NEIGHBORS] = '1'
 
  64         features['default_values'][NUMBER_OF_CORES] = '1'
 
  65         features['default_values'][AMOUNT_OF_RAM] = '256M'
 
  66         features['default_values'][NETWORK_NAME] = ''
 
  67         features['default_values'][SUBNET_NAME] = ''
 
  71         super(InstantiationValidationNoisyNeighborsBenchmark, self).init()
 
  72         common.replace_in_file(self.lua_file, 'local out_file = ""',
 
  73                                'local out_file = "' +
 
  74                                self.results_file + '"')
 
  76         heat_param['network'] = self.params[NETWORK_NAME]
 
  77         heat_param['subnet'] = self.params[SUBNET_NAME]
 
  78         heat_param['cores'] = self.params['number_of_cores']
 
  79         heat_param['memory'] = self.params['amount_of_ram']
 
  80         for i in range(0, int(self.params['num_of_neighbours'])):
 
  81             stack_name = self.stack_name + str(i)
 
  82             common.DEPLOYMENT_UNIT.deploy_heat_template(self.template_file,
 
  85             self.neighbor_stack_names.append(stack_name)
 
  88         common.replace_in_file(self.lua_file, 'local out_file = "' +
 
  89                                self.results_file + '"',
 
  90                                'local out_file = ""')
 
  91         # destroy neighbor stacks
 
  92         for stack_name in self.neighbor_stack_names:
 
  93             common.DEPLOYMENT_UNIT.destroy_heat_template(stack_name)
 
  94         self.neighbor_stack_names = list()