Пример #1
0
def get_task_and_workflow_options(testkit_cfg):
    parsed_cfg = config_parser_to_butler(testkit_cfg)
    workflow_options, task_options = [], []
    def __get_option_type(val):
        option_type = "pbsmrtpipe.option_types.string"
        if isinstance(val, bool):
            option_type = "pbsmrtpipe.option_types.boolean"
        elif isinstance(val, int):
            option_type = "pbsmrtpipe.option_types.integer"
        elif isinstance(val, float):
            option_type = "pbsmrtpipe.option_types.float"
        return option_type
    if not parsed_cfg.preset_xml in [None, '']:
        presets = parse_pipeline_preset_xml(parsed_cfg.preset_xml)
        for option_id, option_value in presets.task_options:
            log.info("task_option: {i} = {v}".format(i=option_id,
                                                     v=option_value))
            task_options.append(dict(
                optionId=option_id,
                value=option_value,
                optionTypeId=__get_option_type(option_value)))
        for option_id, option_value in presets.workflow_options:
            log.info("workflow_option: {i} = {v}".format(i=option_id,
                                                         v=option_value))
            workflow_options.append(dict(
                optionId=option_id,
                value=option_value,
                optionTypeId=__get_option_type(option_value)))
    return task_options, workflow_options
Пример #2
0
def pipeline_id_from_testkit_cfg(testkit_cfg):
    parsed_cfg = config_parser_to_butler(testkit_cfg)
    parsed_dict = parsed_cfg.__dict__
    tree = ET.parse(parsed_dict['workflow_xml'])
    root = tree.getroot()
    pipeline_id = root[0].attrib['id']
    return pipeline_id
Пример #3
0
def get_task_and_workflow_options(testkit_cfg):
    parsed_cfg = config_parser_to_butler(testkit_cfg)
    workflow_options, task_options = [], []
    def __get_option_type(val):
        option_type = "pbsmrtpipe.option_types.string"
        if isinstance(val, bool):
            option_type = "pbsmrtpipe.option_types.boolean"
        elif isinstance(val, int):
            option_type = "pbsmrtpipe.option_types.integer"
        elif isinstance(val, float):
            option_type = "pbsmrtpipe.option_types.float"
        return option_type
    if not parsed_cfg.preset_xml in [None, '']:
        presets = parse_pipeline_preset_xml(parsed_cfg.preset_xml)
        for option_id, option_value in presets.task_options:
            log.info("task_option: {i} = {v}".format(i=option_id,
                                                     v=option_value))
            task_options.append(dict(
                optionId=option_id,
                value=option_value,
                optionTypeId=__get_option_type(option_value)))
        for option_id, option_value in presets.workflow_options:
            log.info("workflow_option: {i} = {v}".format(i=option_id,
                                                         v=option_value))
            workflow_options.append(dict(
                optionId=option_id,
                value=option_value,
                optionTypeId=__get_option_type(option_value)))
    return task_options, workflow_options
Пример #4
0
def pipeline_id_from_testkit_cfg(testkit_cfg):
    parsed_cfg = config_parser_to_butler(testkit_cfg)
    parsed_dict = parsed_cfg.__dict__
    tree = ET.parse(parsed_dict['workflow_xml'])
    root = tree.getroot()
    pipeline_id = root[0].attrib['id']
    return pipeline_id
Пример #5
0
def run_butler_tests_from_cfg(testkit_cfg,
                              output_dir,
                              output_xml,
                              service_access_layer,
                              services_job_id=None,
                              nunit_out=None):
    job_id = job_id_from_testkit_cfg(testkit_cfg)
    butler = config_parser_to_butler(testkit_cfg)
    test_cases = parse_cfg_file(testkit_cfg)
    _patch_test_cases_with_service_access_layer(test_cases,
                                                service_access_layer,
                                                job_id=services_job_id)
    log.info("running tests...")
    exit_code = run_butler_tests(test_cases=test_cases,
                                 output_dir=output_dir,
                                 output_xml=output_xml,
                                 job_id=job_id,
                                 requirements=butler.requirements)
    if nunit_out is not None and len(butler.xray_tests) > 0:
        write_nunit_output(name=job_id,
                           xunit_out=output_xml,
                           nunit_out=nunit_out,
                           requirements=butler.requirements,
                           tests=butler.xray_tests)
    return exit_code
Пример #6
0
def _args_run_butler(args):
    butler = B.config_parser_to_butler(args.testkit_cfg)

    test_cases = L.parse_cfg_file(args.testkit_cfg)

    if not os.path.exists(butler.output_dir):
        os.mkdir(butler.output_dir)

    output_xml = os.path.join(butler.output_dir, "testkit_xunit.xml")

    force_distribute, force_chunk = resolve_dist_chunk_overrides(args)

    if args.only_tests:
        return run_butler_tests(test_cases, butler.output_dir, output_xml, butler.job_id)
    else:
        rcode = run_butler(
            butler,
            test_cases,
            output_xml,
            log_file=args.log_file,
            log_level=args.log_level,
            force_distribute=force_distribute,
            force_chunk=force_chunk,
        )
        return rcode
Пример #7
0
def pipeline_id_from_testkit_cfg(testkit_cfg):
    parsed_cfg = config_parser_to_butler(testkit_cfg)
    if parsed_cfg.workflow_xml is not None:
        tree = ET.parse(parsed_cfg.workflow_xml)
        root = tree.getroot()
        return root[0].attrib['id']
    else:
        return parsed_cfg.pipeline_id
def pipeline_id_from_testkit_cfg(testkit_cfg):
    parsed_cfg = config_parser_to_butler(testkit_cfg)
    if parsed_cfg.workflow_xml is not None:
        tree = ET.parse(parsed_cfg.workflow_xml)
        root = tree.getroot()
        return root[0].attrib['id']
    else:
        return parsed_cfg.pipeline_id
Пример #9
0
def get_task_and_workflow_options(testkit_cfg):
    parsed_cfg = config_parser_to_butler(testkit_cfg)
    workflow_options, task_options = [], []

    def __get_option_type(val):
        option_type = TaskOptionTypes.STR
        if isinstance(val, bool):
            option_type = TaskOptionTypes.BOOL
        elif isinstance(val, int):
            option_type = TaskOptionTypes.INT
        elif isinstance(val, float):
            option_type = TaskOptionTypes.FLOAT
        elif val is None:
            val = ""
        return option_type, val

    rtasks_d, _, _, _ = L.load_all()
    if not parsed_cfg.preset_xml in [None, '']:
        if not parsed_cfg.preset_json in [None, '']:
            raise ValueError(
                "Please use either preset_json or preset_xml, not both")
        presets = parse_pipeline_preset_xml(parsed_cfg.preset_xml)
        task_opts_d = validate_raw_task_options(rtasks_d,
                                                dict(presets.task_options))
        for option_id, option_value in task_opts_d.iteritems():
            log.info("task_option: {i} = {v}".format(i=option_id,
                                                     v=option_value))
            option_type, option_value = __get_option_type(option_value)
            task_options.append(
                dict(optionId=option_id,
                     value=option_value,
                     optionTypeId=option_type))
        for option_id, option_value in presets.workflow_options:
            log.info("workflow_option: {i} = {v}".format(i=option_id,
                                                         v=option_value))
            workflow_options.append(
                dict(optionId=option_id,
                     value=option_value,
                     optionTypeId=__get_option_type(option_value)[0]))
    elif not parsed_cfg.preset_json in [None, '']:
        presets = parse_pipeline_preset_json(parsed_cfg.preset_json)
        for option_id, option_value in presets.task_options:
            log.info("task_option: {i} = {v}".format(i=option_id,
                                                     v=option_value))
            option_type, option_value = __get_option_type(option_value)
            task_options.append(
                dict(optionId=option_id,
                     value=option_value,
                     optionTypeId=option_type))
        for option_id, option_value in presets.workflow_options:
            log.info("workflow_option: {i} = {v}".format(i=option_id,
                                                         v=option_value))
            workflow_options.append(
                dict(optionId=option_id,
                     value=option_value,
                     optionTypeId=__get_option_type(option_value)[0]))
    return task_options, workflow_options
Пример #10
0
def get_task_and_workflow_options(testkit_cfg):
    parsed_cfg = config_parser_to_butler(testkit_cfg)
    workflow_options, task_options = [], []

    def __get_option_type(val):
        option_type = to_opt_type_ns("string")
        if isinstance(val, bool):
            option_type = to_opt_type_ns("boolean")
        elif isinstance(val, int):
            option_type = to_opt_type_ns("integer")
        elif isinstance(val, float):
            option_type = to_opt_type_ns("float")
        elif val is None:
            val = ""
        return option_type, val

    if not parsed_cfg.preset_xml in [None, '']:
        if not parsed_cfg.preset_json in [None, '']:
            raise ValueError(
                "Please use either preset_json or preset_xml, not both")
        presets = parse_pipeline_preset_xml(parsed_cfg.preset_xml)
        for option_id, option_value in presets.task_options:
            log.info("task_option: {i} = {v}".format(i=option_id,
                                                     v=option_value))
            option_type, option_value = __get_option_type(option_value)
            task_options.append(
                dict(optionId=option_id,
                     value=option_value,
                     optionTypeId=option_type))
        for option_id, option_value in presets.workflow_options:
            log.info("workflow_option: {i} = {v}".format(i=option_id,
                                                         v=option_value))
            workflow_options.append(
                dict(optionId=option_id,
                     value=option_value,
                     optionTypeId=__get_option_type(option_value)[0]))
    elif not parsed_cfg.preset_json in [None, '']:
        presets = parse_pipeline_preset_json(parsed_cfg.preset_json)
        for option_id, option_value in presets.task_options:
            log.info("task_option: {i} = {v}".format(i=option_id,
                                                     v=option_value))
            option_type, option_value = __get_option_type(option_value)
            task_options.append(
                dict(optionId=option_id,
                     value=option_value,
                     optionTypeId=option_type))
        for option_id, option_value in presets.workflow_options:
            log.info("workflow_option: {i} = {v}".format(i=option_id,
                                                         v=option_value))
            workflow_options.append(
                dict(optionId=option_id,
                     value=option_value,
                     optionTypeId=__get_option_type(option_value)[0]))
    return task_options, workflow_options
def get_task_and_workflow_options(testkit_cfg):
    parsed_cfg = config_parser_to_butler(testkit_cfg)
    workflow_options, task_options = [], []
    def __get_option_type(val):
        option_type = to_opt_type_ns("string")
        if isinstance(val, bool):
            option_type = to_opt_type_ns("boolean")
        elif isinstance(val, int):
            option_type = to_opt_type_ns("integer")
        elif isinstance(val, float):
            option_type = to_opt_type_ns("float")
        elif val is None:
            val = ""
        return option_type, val
    if not parsed_cfg.preset_xml in [None, '']:
        if not parsed_cfg.preset_json in [None, '']:
            raise ValueError("Please use either preset_json or preset_xml, not both")
        presets = parse_pipeline_preset_xml(parsed_cfg.preset_xml)
        for option_id, option_value in presets.task_options:
            log.info("task_option: {i} = {v}".format(i=option_id,
                                                     v=option_value))
            option_type, option_value = __get_option_type(option_value)
            task_options.append(dict(
                optionId=option_id,
                value=option_value,
                optionTypeId=option_type))
        for option_id, option_value in presets.workflow_options:
            log.info("workflow_option: {i} = {v}".format(i=option_id,
                                                         v=option_value))
            workflow_options.append(dict(
                optionId=option_id,
                value=option_value,
                optionTypeId=__get_option_type(option_value)[0]))
    elif not parsed_cfg.preset_json in [None, '']:
        presets = parse_pipeline_preset_json(parsed_cfg.preset_json)
        for option_id, option_value in presets.task_options:
            log.info("task_option: {i} = {v}".format(i=option_id,
                                                     v=option_value))
            option_type, option_value = __get_option_type(option_value)
            task_options.append(dict(
                optionId=option_id,
                value=option_value,
                optionTypeId=option_type))
        for option_id, option_value in presets.workflow_options:
            log.info("workflow_option: {i} = {v}".format(i=option_id,
                                                         v=option_value))
            workflow_options.append(dict(
                optionId=option_id,
                value=option_value,
                optionTypeId=__get_option_type(option_value)[0]))
    return task_options, workflow_options
Пример #12
0
def run_butler_tests_from_cfg(testkit_cfg, output_dir, output_xml,
                              service_access_layer, services_job_id=None):
    job_id = job_id_from_testkit_cfg(testkit_cfg)
    butler = config_parser_to_butler(testkit_cfg)
    test_cases = parse_cfg_file(testkit_cfg)
    _patch_test_cases_with_service_access_layer(test_cases,
                                                service_access_layer,
                                                job_id=services_job_id)
    log.info("running tests...")
    exit_code = run_butler_tests(
        test_cases=test_cases,
        output_dir=output_dir,
        output_xml=output_xml,
        job_id=job_id)
    return exit_code
def run_butler_tests_from_cfg(testkit_cfg, output_dir, output_xml,
                              service_access_layer, services_job_id=None):
    job_id = job_id_from_testkit_cfg(testkit_cfg)
    butler = config_parser_to_butler(testkit_cfg)
    test_cases = parse_cfg_file(testkit_cfg)
    _patch_test_cases_with_service_access_layer(test_cases,
                                                service_access_layer,
                                                job_id=services_job_id)
    log.info("running tests...")
    exit_code = run_butler_tests(
        test_cases=test_cases,
        output_dir=output_dir,
        output_xml=output_xml,
        job_id=job_id)
    return exit_code
Пример #14
0
def _args_run_butler(args):

    butler = B.config_parser_to_butler(args.testkit_cfg)

    test_cases = L.parse_cfg_file(args.testkit_cfg)

    if not os.path.exists(butler.output_dir):
        os.mkdir(butler.output_dir)

    output_xml = args.output_xml
    if output_xml is None:
        output_xml = os.path.join(butler.output_dir, 'testkit_xunit.xml')

    if args.log_file is None:
        log_file = os.path.join(butler.output_dir, 'testkit.log')
    else:
        log_file = args.log_file

    force_distribute, force_chunk = resolve_dist_chunk_overrides(args)

    log_level = args.log_level

    # Short hand for --log-level=DEBUG
    if args.debug:
        log_level = logging.DEBUG

    if log_level == logging.DEBUG:
        # The logger isn't setup yet
        print "Args", args

    if args.only_tests:
        # in test only mode, only emit to stdout (to avoid overwritten the
        # log file
        setup_logger(None, level=log_level)
        return run_butler_tests(test_cases, butler.output_dir, output_xml,
                                butler.job_id, butler.requirements)
    else:
        rcode = run_butler(butler,
                           test_cases,
                           output_xml,
                           log_file,
                           log_level=log_level,
                           force_distribute=force_distribute,
                           force_chunk=force_chunk,
                           ignore_test_failures=args.ignore_test_failures)
        return rcode
Пример #15
0
def _args_run_butler(args):

    butler = B.config_parser_to_butler(args.testkit_cfg)

    test_cases = L.parse_cfg_file(args.testkit_cfg)

    if not os.path.exists(butler.output_dir):
        os.mkdir(butler.output_dir)

    output_xml = args.output_xml
    if output_xml is None:
        output_xml = os.path.join(butler.output_dir, 'testkit_xunit.xml')

    if args.log_file is None:
        log_file = os.path.join(butler.output_dir, 'testkit.log')
    else:
        log_file = args.log_file

    force_distribute, force_chunk = resolve_dist_chunk_overrides(args)

    log_level = args.log_level

    # Short hand for --log-level=DEBUG
    if args.debug:
        log_level = logging.DEBUG

    if log_level == logging.DEBUG:
        # The logger isn't setup yet
        print "Args", args

    if args.only_tests:
        # in test only mode, only emit to stdout (to avoid overwritten the
        # log file
        setup_logger(None, level=log_level)
        return run_butler_tests(test_cases, butler.output_dir, output_xml, butler.job_id)
    else:
        rcode = run_butler(butler, test_cases, output_xml, log_file,
                           log_level=log_level,
                           force_distribute=force_distribute,
                           force_chunk=force_chunk,
                           ignore_test_failures=args.ignore_test_failures)
        return rcode
Пример #16
0
def run_services_testkit_job(host, port, testkit_cfg,
                             xml_out="test-output.xml",
                             ignore_test_failures=False,
                             time_out=1800, sleep_time=2):
    """
    Given a testkit.cfg and host/port parameters:
        1. convert the .cfg to a JSON file
        2. connect to the SMRTLink services and start the job, then block
           until it finishes
        3. run the standard test suite on the job output
    """
    butler = config_parser_to_butler(testkit_cfg)
    test_cases = parse_cfg_file(testkit_cfg)
    entrypoints = get_entrypoints(testkit_cfg)
    pipeline_id = pipeline_id_from_testkit_cfg(testkit_cfg)
    job_id = job_id_from_testkit_cfg(testkit_cfg)
    log.info("job_id = {j}".format(j=job_id))
    log.info("pipeline_id = {p}".format(p=pipeline_id))
    log.info("url = {h}:{p}".format(h=host, p=port))
    task_options, workflow_options = get_task_and_workflow_options(testkit_cfg)
    sal = ServiceAccessLayer(host, port, sleep_time=sleep_time)
    service_entrypoints = [ServiceEntryPoint.from_d(x) for x in
                           entrypoints_dicts(entrypoints)]
    for ep, dataset_xml in entrypoints.iteritems():
        log.info("Importing {x}".format(x=dataset_xml))
        sal.run_import_local_dataset(dataset_xml)
    log.info("starting anaylsis job...")
    # XXX note that workflow options are currently ignored
    engine_job = run_analysis_job(sal, job_id, pipeline_id,
                                  service_entrypoints, block=True,
                                  time_out=time_out,
                                  task_options=task_options)
    job_output_path = engine_job.path
    log.info("running tests...")
    exit_code = run_butler_tests(
        test_cases=test_cases,
        output_dir=job_output_path,
        output_xml=xml_out,
        job_id=job_id)
    if ignore_test_failures and engine_job.was_successful():
        return 0
    return exit_code
Пример #17
0
def _args_run_butler(args):
    butler = B.config_parser_to_butler(args.testkit_cfg)

    test_cases = L.parse_cfg_file(args.testkit_cfg)

    if not os.path.exists(butler.output_dir):
        os.mkdir(butler.output_dir)

    output_xml = os.path.join(butler.output_dir, 'testkit_xunit.xml')

    force_distribute, force_chunk = resolve_dist_chunk_overrides(args)

    if args.only_tests:
        return run_butler_tests(test_cases, butler.output_dir, output_xml, butler.job_id)
    else:
        rcode = run_butler(butler, test_cases, output_xml,
                           log_file=args.log_file,
                           log_level=args.log_level,
                           force_distribute=force_distribute, force_chunk=force_chunk)
        return rcode
Пример #18
0
def job_id_from_testkit_cfg(testkit_cfg):
    parsed_cfg = config_parser_to_butler(testkit_cfg)
    return parsed_cfg.job_id
def get_entrypoints(testkit_cfg):
    parsed_cfg = config_parser_to_butler(testkit_cfg)
    entrypoints = parsed_cfg.entry_points
    return entrypoints
def job_id_from_testkit_cfg(testkit_cfg):
    parsed_cfg = config_parser_to_butler(testkit_cfg)
    return parsed_cfg.job_id
Пример #21
0
 def _to_butler(self):
     return B.config_parser_to_butler(self.path)
 def _to_butler(self):
     return B.config_parser_to_butler(self.path)
Пример #23
0
def get_entrypoints(testkit_cfg):
    parsed_cfg = config_parser_to_butler(testkit_cfg)
    entrypoints = parsed_cfg.entry_points
    return entrypoints