aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/vTC
diff options
context:
space:
mode:
authorVincenzo Riccobene <vincenzox.m.riccobene@intel.com>2015-12-23 15:14:52 +0000
committerVincenzo Riccobene <vincenzox.m.riccobene@intel.com>2015-12-23 15:46:29 +0000
commit20ff6c8a9b3b073beea7651626f63b4283147d6f (patch)
tree1e96414e68656d12dd821121af382eaeb5b381b1 /yardstick/vTC
parent70b7c1865adcb69aff6e8aac0c9c796dba4e04b4 (diff)
Add some other tests to ApexLake
Include some other tests to reach the required coverage JIRA: YARDSTICK-35 Change-Id: Ie47b0ca9451d4dcc0f5e31ba98f8c38923689475 Signed-off-by: Vincenzo Riccobene <vincenzox.m.riccobene@intel.com>
Diffstat (limited to 'yardstick/vTC')
-rw-r--r--yardstick/vTC/apexlake/__init__.py17
-rw-r--r--yardstick/vTC/apexlake/tests/conf_file_sections_test.py30
-rw-r--r--yardstick/vTC/apexlake/tests/experiment_test.py94
-rw-r--r--yardstick/vTC/apexlake/tests/tree_node_test.py97
4 files changed, 238 insertions, 0 deletions
diff --git a/yardstick/vTC/apexlake/__init__.py b/yardstick/vTC/apexlake/__init__.py
new file mode 100644
index 000000000..8898092d0
--- /dev/null
+++ b/yardstick/vTC/apexlake/__init__.py
@@ -0,0 +1,17 @@
+# 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.
+
+"""
+Benchmarking Framework
+"""
diff --git a/yardstick/vTC/apexlake/tests/conf_file_sections_test.py b/yardstick/vTC/apexlake/tests/conf_file_sections_test.py
new file mode 100644
index 000000000..d2157fcce
--- /dev/null
+++ b/yardstick/vTC/apexlake/tests/conf_file_sections_test.py
@@ -0,0 +1,30 @@
+# 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.
+
+__author__ = 'vmriccox'
+
+
+import unittest
+from experimental_framework.constants import conf_file_sections as cfs
+
+
+class TestConfFileSection(unittest.TestCase):
+
+ def setUp(self):
+ pass
+
+ def test_get_sections_api_for_success(self):
+ expected = ['PacketGen', 'General', 'InfluxDB']
+ output = cfs.get_sections_api()
+ self.assertEqual(expected, output)
diff --git a/yardstick/vTC/apexlake/tests/experiment_test.py b/yardstick/vTC/apexlake/tests/experiment_test.py
new file mode 100644
index 000000000..47d1fbb77
--- /dev/null
+++ b/yardstick/vTC/apexlake/tests/experiment_test.py
@@ -0,0 +1,94 @@
+# 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.
+
+__author__ = 'gpetralx'
+
+import unittest
+from experimental_framework import data_manager
+
+
+class TestExperiment(unittest.TestCase):
+ def setUp(self):
+ self.exp = data_manager.Experiment('experiment_1')
+
+ def tearDown(self):
+ pass
+
+ def test_add_experiment_metadata(self):
+ with self.assertRaises(ValueError):
+ self.exp.add_experiment_metadata('metadata')
+
+ metadata = {
+ 'item_1': 'value_1',
+ 'item_2': 'value_2',
+ 'item_3': 'value_3'
+ }
+ self.exp.add_experiment_metadata(metadata)
+ self.assertDictEqual(metadata, self.exp._metadata)
+ self.assertDictEqual(metadata, self.exp.get_metadata())
+
+ def test_experiment_configuration(self):
+ with self.assertRaises(ValueError):
+ self.exp.add_experiment_configuration('configuration')
+ configuration = {
+ 'item_1': 'value_1',
+ 'item_2': 'value_2',
+ 'item_3': 'value_3'
+ }
+ self.exp.add_experiment_configuration(configuration)
+ self.assertDictEqual(configuration, self.exp._configuration)
+ self.assertDictEqual(configuration, self.exp.get_configuration())
+
+ def test_add_benchmark(self):
+ with self.assertRaises(ValueError):
+ self.exp.add_benchmark(1)
+ self.exp.add_benchmark('benchmark_1')
+ self.assertListEqual(list(), self.exp._benchmarks['benchmark_1'])
+
+ def test_add_datapoint(self):
+ with self.assertRaises(ValueError):
+ self.exp.add_data_point('benchmark_1', 'datapoint')
+
+ data_point_1 = {
+ 'point_1': 'value_1',
+ 'point_2': 'value_2',
+ 'point_3': 'value_3'
+ }
+
+ with self.assertRaises(ValueError):
+ self.exp.add_data_point('benchmark_1', data_point_1)
+
+ self.exp.add_benchmark('benchmark_1')
+ self.exp.add_data_point('benchmark_1', data_point_1)
+ self.assertListEqual([data_point_1],
+ self.exp._benchmarks['benchmark_1'])
+
+ def test_get_data_points(self):
+ self.assertListEqual(list(), self.exp.get_data_points('benchmark_1'))
+ data_point_1 = {
+ 'point_1': 'value_1',
+ 'point_2': 'value_2',
+ 'point_3': 'value_3'
+ }
+ self.exp.add_benchmark('benchmark_1')
+ self.exp.add_data_point('benchmark_1', data_point_1)
+ self.assertListEqual([data_point_1],
+ self.exp.get_data_points('benchmark_1'))
+
+ def test_get_benchmarks(self):
+ self.exp.add_benchmark('benchmark_1')
+ self.exp.add_benchmark('benchmark_2')
+ self.exp.add_benchmark('benchmark_3')
+ expected = ['benchmark_3', 'benchmark_2', 'benchmark_1']
+ self.assertListEqual(expected, self.exp.get_benchmarks())
diff --git a/yardstick/vTC/apexlake/tests/tree_node_test.py b/yardstick/vTC/apexlake/tests/tree_node_test.py
new file mode 100644
index 000000000..8b302c912
--- /dev/null
+++ b/yardstick/vTC/apexlake/tests/tree_node_test.py
@@ -0,0 +1,97 @@
+# 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.
+
+__author__ = 'gpetralx'
+
+
+import unittest
+import experimental_framework.heat_template_generation as heat_gen
+
+
+class TestTreeNode(unittest.TestCase):
+ def setUp(self):
+ self.tree = heat_gen.TreeNode()
+
+ def tearDown(self):
+ pass
+
+ def test_add_child_for_success(self):
+ child = heat_gen.TreeNode()
+ self.tree.add_child(child)
+ self.assertIn(child, self.tree.down)
+
+ def test_get_parent_for_success(self):
+ self.assertIsNone(self.tree.get_parent())
+ child = heat_gen.TreeNode()
+ self.tree.add_child(child)
+ self.assertEqual(self.tree, child.get_parent())
+
+ def test_get_children_for_success(self):
+ self.assertListEqual(list(), self.tree.get_children())
+ child = heat_gen.TreeNode()
+ self.tree.add_child(child)
+ children = [child]
+ self.assertListEqual(children, self.tree.get_children())
+
+ def test_variable_name_for_success(self):
+ self.assertEqual('', self.tree.get_variable_name())
+ variable_name = 'test'
+ self.tree.set_variable_name(variable_name)
+ self.assertEqual(variable_name, self.tree.get_variable_name())
+
+ def test_variable_value_for_success(self):
+ self.assertEqual(0, self.tree.get_variable_value())
+ variable_value = 1
+ self.tree.set_variable_value(variable_value)
+ self.assertEqual(variable_value, self.tree.get_variable_value())
+
+ def test_get_path_for_success(self):
+ child_1 = heat_gen.TreeNode()
+ self.tree.add_child(child_1)
+ child_2 = heat_gen.TreeNode()
+ child_1.add_child(child_2)
+ child_3 = heat_gen.TreeNode()
+ child_2.add_child(child_3)
+
+ path = [self.tree, child_1, child_2, child_3]
+
+ self.assertListEqual(path, child_3.get_path())
+
+ def test_str_for_success(self):
+ name = 'name'
+ value = 0
+ self.tree.set_variable_name(name)
+ self.tree.set_variable_value(value)
+ self.assertEqual(name + " --> " + str(value), str(self.tree))
+
+ def test_repr_for_success(self):
+ name = 'name'
+ value = 0
+ self.tree.set_variable_name(name)
+ self.tree.set_variable_value(value)
+ self.assertEqual(name + " = " + str(value), repr(self.tree))
+
+ def test_get_leaves_for_success(self):
+ child_1 = heat_gen.TreeNode()
+ self.tree.add_child(child_1)
+ child_2 = heat_gen.TreeNode()
+ child_1.add_child(child_2)
+ child_3 = heat_gen.TreeNode()
+ child_2.add_child(child_3)
+ child_4 = heat_gen.TreeNode()
+ child_2.add_child(child_4)
+ child_5 = heat_gen.TreeNode()
+ child_2.add_child(child_5)
+ leaves = [child_3, child_4, child_5]
+ self.assertListEqual(leaves, heat_gen.TreeNode.get_leaves(self.tree))