aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/vTC/apexlake/tests
diff options
context:
space:
mode:
authorVincenzo Riccobene <vincenzox.m.riccobene@intel.com>2015-12-18 16:03:29 +0000
committerJörgen Karlsson <jorgen.w.karlsson@ericsson.com>2015-12-23 14:14:00 +0000
commitfa490948dd370b69e821784e12f67299c7fb0f26 (patch)
tree94a180c30485bb88e71f2e9d02ff150374ebbe1a /yardstick/vTC/apexlake/tests
parent52d1b3111f37a6b8bc2b6a18e3443dc29fcb943b (diff)
Add API to configure and execute ApexLake
Add python module providing API for Yardstick to configure and execute ApexLake and the test cases for the virtual Traffic Classifier. Includes documentation. JIRA: YARDSTICK-215 Change-Id: I87af59c715d789ac78c836123e9ed3d8e0036eec Signed-off-by: Vincenzo Riccobene <vincenzo.m.riccobene@intel.com> Signed-off-by: Vincenzo Riccobene <vincenzox.m.riccobene@intel.com>
Diffstat (limited to 'yardstick/vTC/apexlake/tests')
-rw-r--r--yardstick/vTC/apexlake/tests/api_test.py142
1 files changed, 142 insertions, 0 deletions
diff --git a/yardstick/vTC/apexlake/tests/api_test.py b/yardstick/vTC/apexlake/tests/api_test.py
new file mode 100644
index 000000000..51762801b
--- /dev/null
+++ b/yardstick/vTC/apexlake/tests/api_test.py
@@ -0,0 +1,142 @@
+# 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 os
+import experimental_framework.common as common
+from experimental_framework.api import FrameworkApi
+from experimental_framework.benchmarking_unit import BenchmarkingUnit
+import experimental_framework.benchmarks.\
+ instantiation_validation_benchmark as iv
+
+
+class DummyBenchmarkingUnit(BenchmarkingUnit):
+
+ def __init__(self):
+ BenchmarkingUnit.__init__(self)
+
+ @staticmethod
+ def get_available_test_cases():
+ return ['BenchA', 'BenchB']
+
+ @staticmethod
+ def get_required_benchmarks(required_benchmarks):
+ common.BASE_DIR = "base_dir/"
+ return [iv.InstantiationValidationBenchmark('benchmark', dict())]
+
+
+class DummyBenchmarkingUnit2(BenchmarkingUnit):
+
+ counter_init = 0
+ counter_finalize = 0
+ counter_run = 0
+
+ def __init__(self, base_heat_template, credentials,
+ heat_template_parameters, iterations, test_cases):
+ DummyBenchmarkingUnit.counter_init = 0
+ DummyBenchmarkingUnit.counter_finalize = 0
+ DummyBenchmarkingUnit.counter_run = 0
+
+ def initialize(self):
+ DummyBenchmarkingUnit2.counter_init += 1
+
+ def run_benchmarks(self):
+ DummyBenchmarkingUnit2.counter_run += 1
+
+ def finalize(self):
+ DummyBenchmarkingUnit2.counter_finalize += 1
+
+
+class TestGeneratesTemplate(unittest.TestCase):
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ pass
+
+ @mock.patch('experimental_framework.common.init')
+ def test_init_for_success(self, mock_init):
+ FrameworkApi.init()
+ mock_init.assert_called_once_with(api=True)
+
+ @mock.patch('experimental_framework.benchmarking_unit.BenchmarkingUnit.'
+ 'get_available_test_cases',
+ side_effect=DummyBenchmarkingUnit.get_available_test_cases)
+ def test_get_available_test_cases_for_success(self, mock_bench):
+ expected = ['BenchA', 'BenchB']
+ output = FrameworkApi.get_available_test_cases()
+ self.assertEqual(expected, output)
+
+ @mock.patch('experimental_framework.benchmarking_unit.BenchmarkingUnit.'
+ 'get_required_benchmarks',
+ side_effect=DummyBenchmarkingUnit.get_required_benchmarks)
+ def test_get_test_case_features_for_success(self, mock_get_req_bench):
+
+ expected = dict()
+ expected['description'] = 'Instantiation Validation Benchmark'
+ expected['parameters'] = [
+ iv.THROUGHPUT,
+ iv.VLAN_SENDER,
+ iv.VLAN_RECEIVER]
+ expected['allowed_values'] = dict()
+ expected['allowed_values'][iv.THROUGHPUT] = \
+ map(str, range(0, 100))
+ expected['allowed_values'][iv.VLAN_SENDER] = \
+ map(str, range(-1, 4096))
+ expected['allowed_values'][iv.VLAN_RECEIVER] = \
+ map(str, range(-1, 4096))
+ expected['default_values'] = dict()
+ expected['default_values'][iv.THROUGHPUT] = '1'
+ expected['default_values'][iv.VLAN_SENDER] = '-1'
+ expected['default_values'][iv.VLAN_RECEIVER] = '-1'
+
+ test_case = 'instantiation_validation_benchmark.' \
+ 'InstantiationValidationBenchmark'
+ output = FrameworkApi.get_test_case_features(test_case)
+ self.assertEqual(expected, output)
+
+ def test____for_failure(self):
+ self.assertRaises(
+ ValueError, FrameworkApi.get_test_case_features, 111)
+
+ @mock.patch('experimental_framework.common.LOG')
+ @mock.patch('experimental_framework.common.get_credentials')
+ @mock.patch('experimental_framework.heat_template_generation.'
+ 'generates_templates')
+ @mock.patch('experimental_framework.benchmarking_unit.BenchmarkingUnit',
+ side_effect=DummyBenchmarkingUnit2)
+ def test_execute_framework_for_success(self, mock_b_unit, mock_heat,
+ mock_credentials, mock_log):
+ common.TEMPLATE_DIR = "{}/{}/".format(
+ os.getcwd(), 'tests/data/generated_templates'
+ )
+
+ test_cases = dict()
+ iterations = 1
+ heat_template = 'VTC_base_single_vm_wait.tmp'
+ heat_template_parameters = dict()
+ deployment_configuration = ''
+ openstack_credentials = dict()
+ openstack_credentials['ip_controller'] = ''
+ openstack_credentials['heat_url'] = ''
+ openstack_credentials['user'] = ''
+ openstack_credentials['password'] = ''
+ openstack_credentials['auth_uri'] = ''
+ openstack_credentials['project'] = ''
+ FrameworkApi.execute_framework(
+ test_cases, iterations, heat_template,
+ heat_template_parameters, deployment_configuration,
+ openstack_credentials)