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.
15 import experimental_framework.benchmarking_unit as b_unit
16 from experimental_framework import heat_template_generation, common
19 class FrameworkApi(object):
24 Initializes the Framework
31 def get_available_test_cases():
33 Returns a list of available test cases.
34 This list include eventual modules developed by the user, if any.
35 Each test case is returned as a string that represents the full name
36 of the test case and that can be used to get more information
37 calling get_test_case_features(test_case_name)
39 :return: list of strings
41 return b_unit.BenchmarkingUnit.get_available_test_cases()
44 def get_test_case_features(test_case):
46 Returns a list of features (description, requested parameters,
47 allowed values, etc.) for a specified test case.
49 :param test_case: name of the test case (string)
50 The string represents the test case and can be
51 obtained calling "get_available_test_cases()"
54 :return: dict() containing the features of the test case
56 if not isinstance(test_case, str):
57 raise ValueError('The provided test_case parameter has to be '
59 benchmark = b_unit.BenchmarkingUnit.get_required_benchmarks(
61 return benchmark.get_features()
64 def execute_framework(
68 heat_template_parameters,
69 deployment_configuration,
73 Executes the framework according the inputs
75 :param test_cases: Test cases to be ran on the workload
77 Each string represents a test case and it is one
78 of the strings provided by the
79 "get_available_test_cases()" function output.
81 :param iterations: Number of cycles to be executed (int)
83 :param heat_template: (string) File name of the heat template of the
84 workload to be deployed. It contains the
85 parameters to be evaluated in the form of
86 #parameter_name. (See heat_templates/vTC.yaml as
89 :param heat_template_parameters: (dict) Parameters to be provided
90 as input to the heat template.
91 See http://docs.openstack.org/developer/heat/
92 template_guide/hot_guide.html - section
93 "Template input parameters" for further info.
95 :param deployment_configuration: ( dict[string] = list(strings) ) )
96 Dictionary of parameters representing the
97 deployment configuration of the workload
98 The key is a string corresponding to the name of
99 the parameter, the value is a list of strings
100 representing the value to be assumed by a specific
102 The parameters are user defined: they have to
103 correspond to the place holders (#parameter_name)
104 specified in the heat template.
110 common.InputValidation.validate_os_credentials(openstack_credentials)
111 credentials = openstack_credentials
112 msg = 'The provided heat_template does not exist'
113 template = "{}{}".format(common.get_template_dir(), heat_template)
114 common.InputValidation.validate_file_exist(template, msg)
115 msg = 'The provided iterations variable must be an integer value'
116 common.InputValidation.validate_integer(iterations, msg)
117 msg = 'The provided heat_template_parameters variable must be a ' \
119 common.InputValidation.validate_dictionary(heat_template_parameters,
121 log_msg = "Generation of all the heat templates " \
122 "required by the experiment"
123 common.LOG.info(log_msg)
124 heat_template_generation.generates_templates(heat_template,
125 deployment_configuration)
126 benchmarking_unit = \
127 b_unit.BenchmarkingUnit(
128 heat_template, credentials, heat_template_parameters,
129 iterations, test_cases)
131 common.LOG.info("Benchmarking Unit initialization")
132 benchmarking_unit.initialize()
133 common.LOG.info("Benchmarking Unit Running")
134 benchmarking_unit.run_benchmarks()
136 common.LOG.info("Benchmarking Unit Finalization")
137 benchmarking_unit.finalize()