Exemplo n.º 1
0
 def test_get_template_dir_for_success(self):
     template_dir = common.TEMPLATE_DIR
     common.TEMPLATE_DIR = 'base_dir'
     expected = 'base_dir'
     output = common.get_template_dir()
     self.assertEqual(expected, output)
     common.TEMPLATE_DIR = template_dir
Exemplo n.º 2
0
 def test_get_template_dir_for_success(self):
     template_dir = common.TEMPLATE_DIR
     common.TEMPLATE_DIR = 'base_dir'
     expected = 'base_dir'
     output = common.get_template_dir()
     self.assertEqual(expected, output)
     common.TEMPLATE_DIR = template_dir
Exemplo n.º 3
0
    def __init__(self, name, params):
        base.RFC2544ThroughputBenchmark.__init__(self, name, params)

        if common.RELEASE == 'liberty':
            temp_name = 'stress_workload_liberty.yaml'
        else:
            temp_name = 'stress_workload.yaml'

        self.template_file = "{}{}".format(common.get_template_dir(),
                                           temp_name)
        self.stack_name = 'neighbour'
        self.neighbor_stack_names = list()
Exemplo n.º 4
0
    def __init__(self, name, params):
        base.InstantiationValidationBenchmark.__init__(self, name, params)

        if common.RELEASE == 'liberty':
            temp_name = 'stress_workload_liberty.yaml'
        else:
            temp_name = 'stress_workload.yaml'

        self.template_file = common.get_template_dir() + \
            temp_name
        self.stack_name = 'neighbour'
        self.neighbor_stack_names = list()
    def __init__(self, name, params):
        base.RFC2544ThroughputBenchmark.__init__(self, name, params)

        if common.RELEASE == 'liberty':
            temp_name = 'stress_workload_liberty.yaml'
        else:
            temp_name = 'stress_workload.yaml'

        self.template_file = "{}{}".format(common.get_template_dir(),
                                           temp_name)
        self.stack_name = 'neighbour'
        self.neighbor_stack_names = list()
    def __init__(self, name, params):
        base.InstantiationValidationBenchmark.__init__(self, name, params)

        if common.RELEASE == 'liberty':
            temp_name = 'stress_workload_liberty.yaml'
        else:
            temp_name = 'stress_workload.yaml'

        self.template_file = common.get_template_dir() + \
            temp_name
        self.stack_name = 'neighbour'
        self.neighbor_stack_names = list()
Exemplo n.º 7
0
    def __init__(self, heat_template_name, openstack_credentials, heat_template_parameters, iterations, benchmarks):
        # Loads vars from configuration file
        self.template_file_extension = common.TEMPLATE_FILE_EXTENSION
        self.template_dir = common.get_template_dir()
        self.results_directory = common.RESULT_DIR + str(time.time())
        self.fingerprint = common.FINGERPRINT

        # Initializes other internal variable from parameters
        self.template_name = heat_template_name
        self.iterations = iterations
        self.required_benchmarks = benchmarks
        self.template_files = []
        self.benchmarks = list()
        self.benchmark_names = list()
        self.data_manager = data.DataManager(self.results_directory)
        self.heat_template_parameters = heat_template_parameters
        self.template_files = heat.get_all_heat_templates(self.template_dir, self.template_file_extension)
        common.DEPLOYMENT_UNIT = deploy.DeploymentUnit(openstack_credentials)
Exemplo n.º 8
0
    def __init__(self, heat_template_name, openstack_credentials,
                 heat_template_parameters, iterations, benchmarks):
        """
        :param heat_template_name: (str) Name of the heat template.

        :param openstack_credentials: (dict) Credentials for openstack.
                        Required fields are: 'ip_controller', 'heat_url',
                        'user', 'password', 'auth_uri', 'project'.

        :param heat_template_parameters: (dict) parameters to be given as
                        input to the heat template. Required keys depend on
                        the specific heat template.

        :param iterations: (int) number of cycles to be executed.

        :param benchmarks: (list[str]) List of the names of the
                        benchmarks/test_cases to be executed in the cycle.

        :return: None
        """
        # Loads vars from configuration file
        self.template_file_extension = common.TEMPLATE_FILE_EXTENSION
        self.template_dir = common.get_template_dir()
        self.results_directory = str(common.RESULT_DIR) + str(time.time())

        # Initializes other internal variable from parameters
        self.template_name = heat_template_name
        self.iterations = iterations
        self.required_benchmarks = benchmarks
        self.template_files = []
        self.benchmarks = list()
        self.benchmark_names = list()
        # self.data_manager = data.DataManager(self.results_directory)
        self.heat_template_parameters = heat_template_parameters
        self.template_files = \
            heat.get_all_heat_templates(self.template_dir,
                                        self.template_file_extension)
        common.DEPLOYMENT_UNIT = deploy.DeploymentUnit(openstack_credentials)
Exemplo n.º 9
0
    def __init__(self, heat_template_name, openstack_credentials,
                 heat_template_parameters, iterations, benchmarks):
        """
        :param heat_template_name: (str) Name of the heat template.

        :param openstack_credentials: (dict) Credentials for openstack.
                        Required fields are: 'ip_controller', 'heat_url',
                        'user', 'password', 'auth_uri', 'project'.

        :param heat_template_parameters: (dict) parameters to be given as
                        input to the heat template. Required keys depend on
                        the specific heat template.

        :param iterations: (int) number of cycles to be executed.

        :param benchmarks: (list[str]) List of the names of the
                        benchmarks/test_cases to be executed in the cycle.

        :return: None
        """
        # Loads vars from configuration file
        self.template_file_extension = common.TEMPLATE_FILE_EXTENSION
        self.template_dir = common.get_template_dir()
        self.results_directory = str(common.RESULT_DIR) + str(time.time())

        # Initializes other internal variable from parameters
        self.template_name = heat_template_name
        self.iterations = iterations
        self.required_benchmarks = benchmarks
        self.template_files = []
        self.benchmarks = list()
        self.benchmark_names = list()
        # self.data_manager = data.DataManager(self.results_directory)
        self.heat_template_parameters = heat_template_parameters
        self.template_files = \
            heat.get_all_heat_templates(self.template_dir,
                                        self.template_file_extension)
        common.DEPLOYMENT_UNIT = deploy.DeploymentUnit(openstack_credentials)
 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()
Exemplo n.º 11
0
 def __init__(self, name, params):
     base.RFC2544ThroughputBenchmark.__init__(self, name, params)
     self.template_file = common.get_template_dir() + 'stress_workload.yaml'
     self.stack_name = 'neighbour'
     self.neighbor_stack_names = list()
Exemplo n.º 12
0
def generates_templates(base_heat_template, deployment_configuration):
    """
    Generates the heat templates for the experiments
    :return: None
    """
    # Load useful parameters from file
    template_dir = common.get_template_dir()
    template_file_extension = fp.TEMPLATE_FILE_EXTENSION
    template_base_name = base_heat_template

    variables = deployment_configuration

    # Delete the templates eventually generated in previous running of the
    # framework
    common.LOG.info("Removing the heat templates previously generated")
    command = "rm {}{}_*".format(template_dir, template_name)
    os.system(command)

    # Creation of the tree with all the new configurations
    common.LOG.info("Creation of the tree with all the new configurations")
    tree = TreeNode()
    for variable in variables:
        leaves = TreeNode.get_leaves(tree)
        common.LOG.debug("LEAVES: " + str(leaves))
        common.LOG.debug("VALUES: " + str(variables[variable]))

        for value in variables[variable]:
            for leaf in leaves:
                new_node = TreeNode()
                new_node.set_variable_name(variable)
                new_node.set_variable_value(value)
                leaf.add_child(new_node)

    common.LOG.debug("CONFIGURATION TREE: " + str(tree))

    common.LOG.info("Heat Template and metadata file creation")
    leaves = TreeNode.get_leaves(tree)
    counter = 1
    for leaf in leaves:
        heat_template_vars = leaf.get_path()
        if os.path.isabs(template_base_name):
            base_template = template_base_name
        else:
            base_template = template_dir + template_base_name
        new_template = template_dir + template_name
        new_template += "_" + str(counter) + template_file_extension
        shutil.copy(base_template, new_template)

        metadata = {}
        for var in heat_template_vars:
            if var.get_variable_name():
                common.replace_in_file(new_template,
                                       "#" + var.get_variable_name(),
                                       var.get_variable_value())
                metadata[var.get_variable_name()] = var.get_variable_value()

        # Save the metadata on a JSON file
        with open(new_template + ".json", 'w') as outfile:
            # sort keys to maintain persistent order for git
            jsonutils.dump(metadata, outfile, sort_keys=True)

        common.LOG.debug("Heat Templates and Metadata file " + str(counter) +
                         " created")
        counter += 1

    # Creation of the template files
    common.LOG.info(
        str(counter - 1) + " Heat Templates and Metadata files "
        "created")
 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()
Exemplo n.º 14
0
    def execute_framework(test_cases, iterations, heat_template,
                          heat_template_parameters, deployment_configuration,
                          openstack_credentials):
        """
        Executes the framework according the inputs

        :param test_cases: Test cases to be ran on the workload
                            (dict() of dict())

                            Example:
                            test_case = dict()
                            test_case['name'] = 'module.Class'
                            test_case['params'] = dict()
                            test_case['params']['throughput'] = '1'
                            test_case['params']['vlan_sender'] = '1007'
                            test_case['params']['vlan_receiver'] = '1006'
                            test_cases = [test_case]

        :param iterations: Number of cycles to be executed (int)

        :param heat_template: (string) File name of the heat template of the
                            workload to be deployed. It contains the
                            parameters to be evaluated in the form of
                            #parameter_name. (See heat_templates/vTC.yaml as
                            example).

        :param heat_template_parameters: (dict) Parameters to be provided
                            as input to the heat template.
                            See http://docs.openstack.org/developer/heat/
                            template_guide/hot_guide.html - section
                            "Template input parameters" for further info.

        :param deployment_configuration: ( dict[string] = list(strings) ) )
                            Dictionary of parameters representing the
                            deployment configuration of the workload
                            The key is a string corresponding to the name of
                            the parameter, the value is a list of strings
                            representing the value to be assumed by a specific
                            param.
                            The parameters are user defined: they have to
                            correspond to the place holders (#parameter_name)
                            specified in the heat template.

        :return: dict() Containing results
        """
        common.init(api=True)

        # Input Validation
        common.InputValidation.validate_os_credentials(openstack_credentials)
        credentials = openstack_credentials

        msg = 'The provided heat_template does not exist'
        if common.RELEASE == 'liberty':
            heat_template = 'vTC_liberty.yaml'
        else:
            heat_template = 'vTC.yaml'
        template = "{}{}".format(common.get_template_dir(), heat_template)
        common.InputValidation.validate_file_exist(template, msg)

        msg = 'The provided iterations variable must be an integer value'
        common.InputValidation.validate_integer(iterations, msg)

        msg = 'The provided heat_template_parameters variable must be a ' \
              'dictionary'
        common.InputValidation.validate_dictionary(heat_template_parameters,
                                                   msg)
        log_msg = "Generation of all the heat templates " \
                  "required by the experiment"
        common.LOG.info(log_msg)
        heat_template_generation.generates_templates(heat_template,
                                                     deployment_configuration)
        benchmarking_unit = \
            b_unit.BenchmarkingUnit(
                heat_template, credentials, heat_template_parameters,
                iterations, test_cases)
        try:
            common.LOG.info("Benchmarking Unit initialization")
            benchmarking_unit.initialize()
            common.LOG.info("Benchmarking Unit Running")
            results = benchmarking_unit.run_benchmarks()
        finally:
            common.LOG.info("Benchmarking Unit Finalization")
            benchmarking_unit.finalize()
        return results
 def __init__(self, name, params):
     base.RFC2544ThroughputBenchmark.__init__(self, name, params)
     self.template_file = common.get_template_dir() + 'stress_workload.yaml'
     self.stack_name = 'neighbour'
     self.neighbor_stack_names = list()
def generates_templates(base_heat_template, deployment_configuration):
    """
    Generates the heat templates for the experiments
    :return: None
    """
    # Load useful parameters from file
    template_dir = common.get_template_dir()
    template_file_extension = fp.TEMPLATE_FILE_EXTENSION
    template_base_name = base_heat_template

    variables = deployment_configuration

    # Delete the templates eventually generated in previous running of the
    # framework
    common.LOG.info("Removing the heat templates previously generated")
    os.system("rm " + template_dir + template_name + "_*")

    # Creation of the tree with all the new configurations
    common.LOG.info("Creation of the tree with all the new configurations")
    tree = TreeNode()
    for variable in variables:
        leaves = TreeNode.get_leaves(tree)
        common.LOG.debug("LEAVES: " + str(leaves))
        common.LOG.debug("VALUES: " + str(variables[variable]))

        for value in variables[variable]:
            for leaf in leaves:
                new_node = TreeNode()
                new_node.set_variable_name(variable)
                new_node.set_variable_value(value)
                leaf.add_child(new_node)

    common.LOG.debug("CONFIGURATION TREE: " + str(tree))

    common.LOG.info("Heat Template and metadata file creation")
    leaves = TreeNode.get_leaves(tree)
    counter = 1
    for leaf in leaves:
        heat_template_vars = leaf.get_path()
        if os.path.isabs(template_base_name):
            base_template = template_base_name
        else:
            base_template = template_dir + template_base_name
        new_template = template_dir + template_name
        new_template += "_" + str(counter) + template_file_extension
        shutil.copy(base_template, new_template)

        metadata = dict()
        for var in heat_template_vars:
            if var.get_variable_name():
                common.replace_in_file(new_template, "#" +
                                       var.get_variable_name(),
                                       var.get_variable_value())
                metadata[var.get_variable_name()] = var.get_variable_value()

        # Save the metadata on a JSON file
        with open(new_template + ".json", 'w') as outfile:
            json.dump(metadata, outfile)

        common.LOG.debug("Heat Templates and Metadata file " + str(counter) +
                         " created")
        counter += 1

    # Creation of the template files
    common.LOG.info(str(counter - 1) + " Heat Templates and Metadata files "
                                       "created")
Exemplo n.º 17
0
    def execute_framework(
            test_cases,
            iterations,
            heat_template,
            heat_template_parameters,
            deployment_configuration,
            openstack_credentials
    ):
        """
        Executes the framework according the inputs

        :param test_cases: Test cases to be ran on the workload
                            (dict() of dict())

                            Example:
                            test_case = dict()
                            test_case['name'] = 'module.Class'
                            test_case['params'] = dict()
                            test_case['params']['throughput'] = '1'
                            test_case['params']['vlan_sender'] = '1007'
                            test_case['params']['vlan_receiver'] = '1006'
                            test_cases = [test_case]

        :param iterations: Number of cycles to be executed (int)

        :param heat_template: (string) File name of the heat template of the
                            workload to be deployed. It contains the
                            parameters to be evaluated in the form of
                            #parameter_name. (See heat_templates/vTC.yaml as
                            example).

        :param heat_template_parameters: (dict) Parameters to be provided
                            as input to the heat template.
                            See http://docs.openstack.org/developer/heat/
                            template_guide/hot_guide.html - section
                            "Template input parameters" for further info.

        :param deployment_configuration: ( dict[string] = list(strings) ) )
                            Dictionary of parameters representing the
                            deployment configuration of the workload
                            The key is a string corresponding to the name of
                            the parameter, the value is a list of strings
                            representing the value to be assumed by a specific
                            param.
                            The parameters are user defined: they have to
                            correspond to the place holders (#parameter_name)
                            specified in the heat template.

        :return: dict() Containing results
        """
        common.init(api=True)

        # Input Validation
        common.InputValidation.validate_os_credentials(openstack_credentials)
        credentials = openstack_credentials

        msg = 'The provided heat_template does not exist'
        if common.RELEASE == 'liberty':
            heat_template = 'vTC_liberty.yaml'
        else:
            heat_template = 'vTC.yaml'
        template = "{}{}".format(common.get_template_dir(), heat_template)
        common.InputValidation.validate_file_exist(template, msg)

        msg = 'The provided iterations variable must be an integer value'
        common.InputValidation.validate_integer(iterations, msg)

        msg = 'The provided heat_template_parameters variable must be a ' \
              'dictionary'
        common.InputValidation.validate_dictionary(heat_template_parameters,
                                                   msg)
        log_msg = "Generation of all the heat templates " \
                  "required by the experiment"
        common.LOG.info(log_msg)
        heat_template_generation.generates_templates(heat_template,
                                                     deployment_configuration)
        benchmarking_unit = \
            b_unit.BenchmarkingUnit(
                heat_template, credentials, heat_template_parameters,
                iterations, test_cases)
        try:
            common.LOG.info("Benchmarking Unit initialization")
            benchmarking_unit.initialize()
            common.LOG.info("Benchmarking Unit Running")
            results = benchmarking_unit.run_benchmarks()
        finally:
            common.LOG.info("Benchmarking Unit Finalization")
            benchmarking_unit.finalize()
        return results