Пример #1
0
def main():
    global logger
    try:
        config = configparser.ConfigParser()
        config.optionxform = lambda option: option  # overriding to aviod lowercasing the options
        do('parseconfig.ini', 'r', config.read_file)
        logger = get_logger(__name__, config)
        bb_variables = do('bamboo_env_file', 'r', split_option)
        for (k, v) in bb_variables.items():
            key = k.strip('bamboo_')
            if is_config_variable(key):
                option = key.split('_')
                try:
                    if config.has_option(option[0], option[1]):
                        config.set(option[0], option[1], v)
                        logger.info(f'Updated config parameter: [{option[0]}][{option[1]}] = {v}')
                    else:
                        logger.error(f'No [{option[1]}] option found in [{option[0]}] section of parseconfig.ini file')
                except configparser.NoSectionError:
                    logger.error(f'No [{option[0]}] section found in parseconfig.ini file')
        do('parseconfig.ini', 'w', config.write)
        parser = argparse.ArgumentParser()
        parser.add_argument("-s", "--script", help="Script name to run")
        args = parser.parse_known_args()
        script_file = path.join(path.abspath(path.dirname(__file__)), f'{args[0].script}.py')
        script_args = ' '.join(args[1])
        command = f'{script_file} {script_args}'
        logger.info(f'Executing script {command}')
        system(f'python {command}')
    except Exception as e:
        logger.exception(e)
Пример #2
0
def main():

    parser = argparse.ArgumentParser()
    parser.add_argument("-c",
                        "--config",
                        help="Path to alternative config file")
    parser.add_argument("-k",
                        "--trkey",
                        help="TestCycle key to post results into")
    args = parser.parse_args()
    config_path = args.config if args.config else None
    config = read_config(config_path)
    key = args.trkey if args.trkey else None
    logger = get_logger(__name__, config)
    try:
        r_config = config['ROCS']
        testcycle_name = config['EXECUTION']['testcycleName']
        artifact_path = get_full_path(base_path=r_config['pathToArtifact'],
                                      use_relative_path=True)
        if r_config['getResultsFromBamboo'] == 'True':
            get_build_artifact(r_config['bambooBuildLink'], artifact_path)
        j_parser = RocsParser(artifact_path=artifact_path,
                              testcycle_name=testcycle_name,
                              testcycle_key=key,
                              config_path=config_path)
        j_parser.read_files()
        j_parser.do_export_results()
    except Exception as e:
        logger.exception(e)
Пример #3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-n", "--tc_name", help="Test cycle name")
    parser.add_argument("-p",
                        "--j_path",
                        help="Path to json file or folder with files")
    parser.add_argument("-c",
                        "--config",
                        help="Path to alternative config file")
    args = parser.parse_args()
    config_path = args.config if args.config else None
    config = read_config(config_path)
    logger = get_logger(__name__, config)
    try:
        json_path = args.j_path if args.j_path else config['JSON']['jsonPath']
        fh = FilesHandler(config, json_path)
        testcycle_name = args.tc_name if args.tc_name else config['JSON'][
            'testcycleName']
        files_list = fh.get_list_of_files('json')
        logger.info(f'Starting to parse json results. '
                    f'Config path: {config_path}  '
                    f'Tescycle name: {testcycle_name}  '
                    f'Files to proceed: {files_list}  ')
        j_parser = JsonParser(testcycle_name, config_path)
        j_parser.read_files(files_list)
        j_parser.do_export_results()
    except Exception as e:
        logger.exception(e)
Пример #4
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-n", "--tc_name", help="Test cycle name")
    parser.add_argument("-p",
                        "--j_path",
                        help="Path to json file or folder with files")
    parser.add_argument("-l", "--logs", help="Path to test execution logs")
    parser.add_argument("-c",
                        "--config",
                        help="Path to alternative config file")
    args = parser.parse_args()
    config_path = args.config if args.config else None
    config = read_config(config_path)
    logger = get_logger(__name__, config)
    try:
        junit_path = args.j_path if args.j_path else config['JUNIT'][
            'junitPath']
        fh = FilesHandler(config, junit_path)
        testcycle_name = args.tc_name if args.tc_name else config['EXECUTION'][
            'testcycleName']
        logs_path = args.logs if args.logs else \
            (config['JUNIT']['pathToLogs'] if config['JUNIT']['pathToLogs'] != '' else None)
        files_list = fh.get_list_of_files('xml')
        logger.info(f'Starting to parse json results. '
                    f'Config path: {config_path}  '
                    f'Tescycle name: {testcycle_name}  '
                    f'Logs path: {logs_path}   '
                    f'Files to proceed: {files_list}  ')
        j_parser = JunitParser(testcycle_name, config_path, logs_path)
        j_parser.read_files(files_list)
        j_parser.do_export_results()
    except Exception as e:
        logger.exception(e)
Пример #5
0
 def __init__(self, config_path: str = None):
     self.config_path = config_path
     self.config = read_config(config_path)
     self.logger = get_logger(__name__, self.config)
     self.tm = TM4J(self.config_path)
     self.file = None
     self.file_contents = list()
     self.parse_results = list()
     self.export_results = {
         'Files read': 0,
         'Results found': 0,
         'Exported': 0,
         'Failed': 0
     }
Пример #6
0
def main():
    global logger
    parser = argparse.ArgumentParser()
    parser.add_argument("-c",
                        "--config",
                        help="Path to alternative config file")
    parser.add_argument("-d", "--diff", help="Path to diff file to proceed")
    args = parser.parse_args()
    config_path = args.config if args.config else None
    diff_path = args.diff if args.diff else None
    config = read_config(config_path)
    logger = get_logger(__name__, config)
    try:
        files_list = get_list_of_feature_files_to_proceed(config=config,
                                                          diff=diff_path)
        bdd_parser = BddParser(config_path)
        bdd_parser.read_files(files_list)
        bdd_parser.do_export_results()
    except Exception as e:
        logger.exception(e)
Пример #7
0
    def __init__(self, config_path=None):
        self.config = read_config(config_path)
        self._baseurl = self.config['GENERAL']['tm4jUrl']
        self._serviceurl = self._baseurl.replace("atm", "tests")
        self._jira_url = self._baseurl.replace('atm/1.0', 'api/2')
        self._login = self.config['GENERAL']['tm4jLogin']
        self._password = self.config['GENERAL']['tm4jPassword']
        self.project_key = self.config['GENERAL']['tm4jProjectKey']
        self.logger = get_logger(__name__, self.config)
        self._session = Session()
        self._session.auth = (self._login, self._password)
        self._testResultsId = None
        self.testcase = None
        self._tc_internal_id = None
        self.testrun = None
        self._tr_internal_id = None
        self._init_testcase()
        self._init_testrun()

        url = f'{self._serviceurl}/project'
        projects = self._do('get', url, '')

        self._tc_project_id = int(
            [x for x in projects if x['key'] == self.project_key][0]['id'])
Пример #8
0
"""
Module implements multithreading execution os some functions and error handling
"""
from libs.config import gen_config
from concurrent.futures import ThreadPoolExecutor, as_completed
from libs.tm_log import get_logger

logger = get_logger(__name__)


def run_threaded(results_list: list, action: callable, args) -> list:
    threads_qty = int(gen_config['threadsQty'])
    retry_list = list()
    exceptions_list = list()
    future_to_post = {}
    counter = 0
    initial_list_size = len(results_list)
    with ThreadPoolExecutor(threads_qty) as executor:
        for result_to_post in results_list:
            values = add_tuple_to_item(result_to_post, args)
            future_to_post[executor.submit(action, values)] = result_to_post
            logger.debug(f'Added future to post {values}')
        for future in as_completed(future_to_post):
            if future.exception():
                retry_list.append(future_to_post[future])
                exceptions_list.append(future.exception())
            else:
                counter += 1
    logger.info(f'Posted {counter} results')
    if retry_list and (len(retry_list) < initial_list_size):
        logger.info(f'Retrying to post {len(retry_list)} results')