summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincenzo Riccobene <vincenzox.m.riccobene@intel.com>2015-12-11 22:00:14 +0000
committerJörgen Karlsson <jorgen.w.karlsson@ericsson.com>2015-12-15 16:08:22 +0000
commit88db82cc1abb506e719054adce6b3033afdc8131 (patch)
treecacca28b871b543b94dc3771ce1b827b3cc2d031
parentd8377e956f73f70cb70b62a3c31677460ea85f6e (diff)
Add support to the test case required by YARDSTICK-146
Add supporto to ApexLake for the test case to validate the vTC instantiation on OpenStack JIRA: YARDSTICK-146 Change-Id: Ib154bac19ec1c32a508682235478a3c7fc530299 Signed-off-by: Vincenzo Riccobene <vincenzox.m.riccobene@intel.com>
-rw-r--r--yardstick/vTC/apexlake/experimental_framework/benchmarks/instantiation_validation_noisy_neighbors_benchmark.py77
-rw-r--r--yardstick/vTC/apexlake/tests/instantiation_validation_noisy_bench_test.py121
2 files changed, 198 insertions, 0 deletions
diff --git a/yardstick/vTC/apexlake/experimental_framework/benchmarks/instantiation_validation_noisy_neighbors_benchmark.py b/yardstick/vTC/apexlake/experimental_framework/benchmarks/instantiation_validation_noisy_neighbors_benchmark.py
new file mode 100644
index 000000000..4e3b640d8
--- /dev/null
+++ b/yardstick/vTC/apexlake/experimental_framework/benchmarks/instantiation_validation_noisy_neighbors_benchmark.py
@@ -0,0 +1,77 @@
+# Copyright (c) 2015 Intel Research and Development Ireland Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import instantiation_validation_benchmark as base
+from experimental_framework import common
+
+
+NUM_OF_NEIGHBORS = 'num_of_neighbours'
+AMOUNT_OF_RAM = 'amount_of_ram'
+NUMBER_OF_CORES = 'number_of_cores'
+
+
+class InstantiationValidationNoisyNeighborsBenchmark(
+ base.InstantiationValidationBenchmark):
+
+ def __init__(self, name, params):
+ base.InstantiationValidationBenchmark.__init__(self, name, params)
+ self.template_file = common.get_template_dir() + \
+ 'stress_workload.yaml'
+ self.stack_name = 'neighbour'
+ self.neighbor_stack_names = list()
+
+ def get_features(self):
+ features = super(InstantiationValidationNoisyNeighborsBenchmark,
+ self).get_features()
+ features['description'] = 'Instantiation Validation Benchmark ' \
+ 'with noisy neghbors'
+ features['parameters'].append(NUM_OF_NEIGHBORS)
+ features['parameters'].append(AMOUNT_OF_RAM)
+ features['parameters'].append(NUMBER_OF_CORES)
+ features['allowed_values'][NUM_OF_NEIGHBORS] = \
+ ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
+ features['allowed_values'][NUMBER_OF_CORES] = \
+ ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
+ features['allowed_values'][AMOUNT_OF_RAM] = \
+ ['250M', '1G', '2G', '3G', '4G', '5G', '6G', '7G', '8G', '9G',
+ '10G']
+ features['default_values'][NUM_OF_NEIGHBORS] = '1'
+ features['default_values'][NUMBER_OF_CORES] = '1'
+ features['default_values'][AMOUNT_OF_RAM] = '250M'
+ return features
+
+ def init(self):
+ super(InstantiationValidationNoisyNeighborsBenchmark, self).init()
+ common.replace_in_file(self.lua_file, 'local out_file = ""',
+ 'local out_file = "' +
+ self.results_file + '"')
+ heat_param = dict()
+ heat_param['cores'] = self.params['number_of_cores']
+ heat_param['memory'] = self.params['amount_of_ram']
+ for i in range(0, int(self.params['num_of_neighbours'])):
+ stack_name = self.stack_name + str(i)
+ common.DEPLOYMENT_UNIT.deploy_heat_template(self.template_file,
+ stack_name,
+ heat_param)
+ self.neighbor_stack_names.append(stack_name)
+
+ def finalize(self):
+ common.replace_in_file(self.lua_file, 'local out_file = "' +
+ self.results_file + '"',
+ 'local out_file = ""')
+ # destroy neighbor stacks
+ for stack_name in self.neighbor_stack_names:
+ common.DEPLOYMENT_UNIT.destroy_heat_template(stack_name)
+ self.neighbor_stack_names = list()
diff --git a/yardstick/vTC/apexlake/tests/instantiation_validation_noisy_bench_test.py b/yardstick/vTC/apexlake/tests/instantiation_validation_noisy_bench_test.py
new file mode 100644
index 000000000..bbdf73947
--- /dev/null
+++ b/yardstick/vTC/apexlake/tests/instantiation_validation_noisy_bench_test.py
@@ -0,0 +1,121 @@
+# Copyright (c) 2015 Intel Research and Development Ireland Ltd.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import unittest
+import mock
+
+
+import experimental_framework.benchmarks.\
+ instantiation_validation_noisy_neighbors_benchmark as mut
+
+
+class InstantiationValidationInitTest(unittest.TestCase):
+
+ def setUp(self):
+ name = 'instantiation_validation_noisy'
+ params = {'param': 'value'}
+ self.iv = mut.\
+ InstantiationValidationNoisyNeighborsBenchmark(name, params)
+
+ def tearDown(self):
+ pass
+
+ @mock.patch('experimental_framework.benchmarks.'
+ 'instantiation_validation_benchmark.'
+ 'InstantiationValidationBenchmark')
+ @mock.patch('experimental_framework.common.get_template_dir')
+ def test___init___for_success(self, mock_get_template_dir,
+ mock_instant_validation):
+ mock_get_template_dir.return_value = '/directory/'
+ name = 'instantiation_validation_noisy'
+ params = {'param': 'value'}
+ obj = mut.InstantiationValidationNoisyNeighborsBenchmark(name, params)
+ self.assertEqual(obj.template_file, '/directory/stress_workload.yaml')
+ self.assertEqual(obj.stack_name, 'neighbour')
+ self.assertEqual(obj.neighbor_stack_names, list())
+
+ def test_get_features_for_success(self):
+ expected = dict()
+ expected['description'] = 'Instantiation Validation Benchmark with ' \
+ 'noisy neghbors'
+ expected['parameters'] = list()
+ expected['allowed_values'] = dict()
+ expected['default_values'] = dict()
+ expected['parameters'].append('throughput')
+ expected['parameters'].append('vlan_sender')
+ expected['parameters'].append('vlan_receiver')
+ expected['parameters'].append(mut.NUM_OF_NEIGHBORS)
+ expected['parameters'].append(mut.AMOUNT_OF_RAM)
+ expected['parameters'].append(mut.NUMBER_OF_CORES)
+ expected['allowed_values']['throughput'] = map(str, range(0, 100))
+ expected['allowed_values']['vlan_sender'] = map(str, range(-1, 4096))
+ expected['allowed_values']['vlan_receiver'] = map(str, range(-1, 4096))
+ expected['allowed_values'][mut.NUM_OF_NEIGHBORS] = \
+ ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
+ expected['allowed_values'][mut.NUMBER_OF_CORES] = \
+ ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
+ expected['allowed_values'][mut.AMOUNT_OF_RAM] = \
+ ['250M', '1G', '2G', '3G', '4G', '5G', '6G', '7G', '8G', '9G',
+ '10G']
+ expected['default_values']['throughput'] = '1'
+ expected['default_values']['vlan_sender'] = '-1'
+ expected['default_values']['vlan_receiver'] = '-1'
+ expected['default_values'][mut.NUM_OF_NEIGHBORS] = '1'
+ expected['default_values'][mut.NUMBER_OF_CORES] = '1'
+ expected['default_values'][mut.AMOUNT_OF_RAM] = '250M'
+ output = self.iv.get_features()
+ self.assertEqual(expected['description'], output['description'])
+
+ for item in output['parameters']:
+ self.assertIn(item, expected['parameters'])
+ for key in output['allowed_values'].keys():
+ self.assertEqual(expected['allowed_values'][key],
+ output['allowed_values'][key])
+ for key in output['default_values'].keys():
+ self.assertEqual(expected['default_values'][key],
+ output['default_values'][key])
+
+ @mock.patch('experimental_framework.common.replace_in_file')
+ @mock.patch('experimental_framework.common.'
+ 'DEPLOYMENT_UNIT.deploy_heat_template')
+ def test_init_for_success(self, mock_deploy_heat, mock_replace):
+ self.iv.lua_file = 'file'
+ self.iv.results_file = 'res_file'
+ self.iv.params = {'number_of_cores': 1,
+ 'amount_of_ram': 1,
+ 'num_of_neighbours': 1}
+ self.iv.template_file = 'template.yaml'
+ self.iv.init()
+ mock_replace.assert_called_once_wih('file',
+ 'local out_file = ""',
+ 'local out_file = "' +
+ 'res_file' + '"')
+ mock_deploy_heat.assert_called_once_with('template.yaml',
+ 'neighbour0',
+ {'cores': 1, 'memory': 1})
+ self.assertEqual(self.iv.neighbor_stack_names, ['neighbour0'])
+
+ @mock.patch('experimental_framework.common.replace_in_file')
+ @mock.patch('experimental_framework.common.'
+ 'DEPLOYMENT_UNIT.destroy_heat_template')
+ def test_finalize_for_success(self, mock_heat_destroy, mock_replace):
+ self.iv.neighbor_stack_names = ['neighbor0']
+ stack_name = 'neighbor0'
+ self.iv.finalize()
+ mock_heat_destroy.assert_called_once_with(stack_name)
+ mock_replace.assert_called_once_wih('file',
+ 'local out_file = ""',
+ 'local out_file = "' +
+ 'res_file' + '"')
+ self.assertEqual(self.iv.neighbor_stack_names, list())