Ejemplo n.º 1
0
    graph_steps_per_line = 4
    step_log_border_num_stars = 180

    # Parse the CLI arguments
    args = CLIArgs()
    debug = args.args.debug
    machine_cfg_file = args.args.machine_cfg_file
    test_file_name = args.args.test_file_name
    test_suite_name = args.args.test_suite_name
    test_case_name = args.args.test_case_name

    # Set up the logging
    logfile = args.args.logfile
    logging_level = logger.Logger.STR_TO_VAL['debug' if debug else 'info']
    logging = logger.Logger(default_level=logging_level, filename=logfile)
    logging.debug(f"Logging Project: {logging.project}")
    if logfile is not None:
        logfile = os.path.abspath(logfile)

    # Get the selected test case info
    tests = StatePathsYaml(input_file=test_file_name)

    # If requested, display the test suites and test cases based on the
    # CLI input
    if args.args.list:
        print(tests.list_test_info(test_suite=test_suite_name))
        exit()

    # ERROR: no test suite or test case specified
    elif (args.args.test_suite_name is None
Ejemplo n.º 2
0
import copy
import pprint
import typing

import prettytable

from flowtester.logging import logger
from flowtester.state_machine.config.constants \
    import StateMachineConstants as SMConsts
from flowtester.state_machine.validation.validate_engine_cfg import ValidateData

logging = logger.Logger()


class MachineDefinition:
    """

    Using the StateMachineConstants, a well defined state machine should be
    defined (see flowtester.utils.template_builder for additional information
    about the data structure.

    """
    BLANK = ''
    END_STATE = 'END STATE'
    INITIAL_STATE = 'INITIAL STATE'
    NO_VALUE = '--'

    STATE = 'state'
    NOTES = 'notes'
    DESTINATION = 'dest'
    TRIGGER = 'trigger'
Ejemplo n.º 3
0
    """
    Primary execution routine.

    Returns:
        None

    """
    # Get the selected test case info
    tests = StatePathsYaml(input_file=args.args.relative_yaml_path_file).data
    if not args.args.full:
        process_referential_yaml(tests)

    # Write the data to file
    output_file = check_output_file(filename=args.args.output_file)
    output_data_as_yaml(data=tests, filename=output_file)

    logging.info("Done.\n")


if __name__ == '__main__':
    args = CLIArgs()
    debug = args.args.debug

    logging_level = logger.Logger.STR_TO_VAL['debug' if args.args.
                                             debug else 'info']

    logging = logger.Logger(default_level=logging_level)
    logging.debug(f"Logging Project: {logging.project}")

    main()
Ejemplo n.º 4
0
                        type=str,
                        help="Name of yaml template file to create")
    parser.add_argument('-d',
                        '--debug',
                        action="store_true",
                        default=False,
                        help="Enable debug logging")

    args = parser.parse_args()

    return int(args.num_test_cases), args.yaml_out_file, args.debug


if __name__ == '__main__':

    # Parse Args
    number_of_test_cases, yaml_file, debug = get_args()

    # Setup logging
    logging_level = logger.Logger.STR_TO_VAL['debug' if debug else 'info']
    project = logger.Logger.determine_project()
    logging = logger.Logger(project=project, default_level=logging_level)

    # Build model
    model = build_model(num_suites=NUM_SUITES,
                        num_test_cases=number_of_test_cases,
                        num_steps=NUM_STEPS)

    # Write the template to file
    write_to_file(model_list=model, output_file=yaml_file)
Ejemplo n.º 5
0
                            after='exit_state')

    def entry_into_state(self):
        logging.info(
            f"{'-' * self.BORDER_LEN}\nCurrent State: {self.state.upper()}")

    def exit_state(self):
        logging.info(
            f"New State: {self.state.upper()}\n{'*' * self.BORDER_LEN}")
        self.path.append(self.state.upper())


if __name__ == '__main__':
    machine = ServerState(name='VM')
    project = logger.Logger.determine_project()
    logging = logger.Logger(project=project,
                            default_level=logger.Logger.STR_TO_VAL['info'])
    logging.info(f"INITIAL STATE: {machine.state}")
    machine_transitions = [
        machine.CREATE, machine.SUCCESS, machine.PAUSE, machine.DELETE,
        machine.UNPAUSE, machine.DELETE, machine.SUCCESS
    ]

    for trans in machine_transitions:
        try:
            logging.info(f"Requested Transition: {trans.upper()}")
            getattr(machine, trans)()

        except MachineError as exc:
            logging.error(f"\nERROR: {exc}")
            logging.error(f"\tRemaining in '{machine.state.upper()}' state.\n")
            machine.path.append(f"ERR: {machine.state.upper()}")
Ejemplo n.º 6
0
import random
import string
import time
import uuid

import prettytable

from flowtester.logging import logger
from vm_data_model.data_model.vm_data_class import VMData, VMStates

logging = logger.Logger(project='FlowTester')


class VmModel:
    ACTION_DURATION = 0  # in seconds
    PASSWORD_LENGTH = 18  # characters

    def __init__(self) -> None:
        self.data = VMData()

    def __str__(self) -> str:
        cols = ["Attribute", "Value"]
        table = prettytable.PrettyTable()
        table.field_names = cols
        table.align[cols[0]] = 'l'
        for data in self.data.get_data():
            table.add_row(data)
        return table.get_string()

    def log_state(self) -> None:
        logging.info(f"\n{self}")