Exemplo n.º 1
0
def get_testobjects_promises_for_objspec(context, objspec):
    warnings.warn('Need to be smarter here.')
    objspec.master.load()
    warnings.warn('Select test objects here.')
    objects = sorted(objspec.keys())

    if False:
        warnings.warn("Maybe warn here.")
        if not objects:
            msg = 'Could not find any test objects for %r.' % objspec
            raise ValueError(msg)

    promises = {}
    for id_object in objects:
        params = dict(job_id='%s-instance-%s' % (objspec.name, id_object),
                      command_name='instance_%s' % objspec.name)
        if objspec.instance_method is None:
            job = context.comp_config(get_spec, master_name=objspec.master.name,
                                      objspec_name=objspec.name, id_object=id_object,
                                      **params)
        else:
            job = context.comp_config(instance_object,
                                      master_name=objspec.master.name,
                                      objspec_name=objspec.name, id_object=id_object,
                                      **params)
        promises[id_object] = job.job_id
        db = context.cc.get_compmake_db()
        assert_job_exists(job.job_id, db)
        # print('defined %r -> %s' % (id_object, job.job_id))
        if not job.job_id.endswith(params['job_id']):
            msg = 'Wanted %r but got %r' % (params['job_id'], job.job_id)
            raise ValueError(msg)
    return promises
Exemplo n.º 2
0
def define_tests_some_pairs_(cx, db, objspec1, objspec2, objs1, objs2, func,
                             dynamic, create_reports):
    results = {}
    jobs = {}
    combinations = iterate_context_names_pair(cx,
                                              list(objs1),
                                              list(objs2),
                                              key1=objspec1.name,
                                              key2=objspec2.name)
    for c, id_ob1, id_ob2 in combinations:
        assert_job_exists(objs1[id_ob1], db)
        assert_job_exists(objs2[id_ob2], db)
        ob1 = Promise(objs1[id_ob1])
        ob2 = Promise(objs2[id_ob2])

        params = dict(job_id='f', command_name=func.__name__)
        if dynamic:
            res = c.comp_config_dynamic(wrap_func_pair_dyn, func, id_ob1, ob1,
                                        id_ob2, ob2, **params)
        else:
            res = c.comp_config(wrap_func_pair, func, id_ob1, ob1, id_ob2, ob2,
                                **params)
        results[(id_ob1, id_ob2)] = res
        jobs[(id_ob1, id_ob2)] = res.job_id

    if create_reports:
        r = cx.comp_dynamic(report_results_pairs_jobs, func, objspec1.name,
                            objspec2.name, jobs)
        cx.add_report(r, 'jobs_pairs_some')

        r = cx.comp(report_results_pairs, func, objspec1.name, objspec2.name,
                    results)
        cx.add_report(r, 'pairs_some')
Exemplo n.º 3
0
def define_tests_some_pairs_(cx, db, objspec1, objspec2, objs1, objs2, func, dynamic, create_reports):
    results = {}
    jobs = {}
    combinations = iterate_context_names_pair(cx, list(objs1), list(objs2),
                                              key1=objspec1.name, key2=objspec2.name)
    for c, id_ob1, id_ob2 in combinations:
        assert_job_exists(objs1[id_ob1], db)
        assert_job_exists(objs2[id_ob2], db)
        ob1 = Promise(objs1[id_ob1])
        ob2 = Promise(objs2[id_ob2])

        params = dict(job_id='f', command_name=func.__name__)
        if dynamic:
            res = c.comp_config_dynamic(wrap_func_pair_dyn,
                                        func, id_ob1, ob1, id_ob2, ob2,
                                        **params)
        else:
            res = c.comp_config(wrap_func_pair,
                                func, id_ob1, ob1, id_ob2, ob2,
                                **params)
        results[(id_ob1, id_ob2)] = res
        jobs[(id_ob1, id_ob2)] = res.job_id

    if create_reports:
        r = cx.comp_dynamic(report_results_pairs_jobs,
                            func, objspec1.name, objspec2.name, jobs)
        cx.add_report(r, 'jobs_pairs_some')

        r = cx.comp(report_results_pairs,
                    func, objspec1.name, objspec2.name, results)
        cx.add_report(r, 'pairs_some')
Exemplo n.º 4
0
def define_tests_pairs(context, objspec1, names2test_objects, pairs, create_reports):
    objs1 = names2test_objects[objspec1.name]

    if not pairs:
        print('No %s+x pairs mcdp_lang_tests.' % (objspec1.name))
        return
    else:
        print('%d %s+x pairs mcdp_lang_tests.' % (len(pairs), objspec1.name))

    for x in pairs:
        objspec2 = x['objspec2']
        func = x['function']
        dynamic = x['dynamic']

        cx = context.child(func.__name__)
        cx.add_extra_report_keys(objspec1=objspec1.name, objspec2=objspec2.name,
                                 function=func.__name__, type='pairs')

        objs2 = names2test_objects[objspec2.name]
        if not objs2:
            print('No objects %r for pairs' % objspec2.name)
            continue

        results = {}
        jobs = {}

        db = context.cc.get_compmake_db()

        combinations = iterate_context_names_pair(cx, list(objs1), list(objs2),
                                                  key1=objspec1.name, key2=objspec2.name)
        for c, id_ob1, id_ob2 in combinations:
            assert_job_exists(objs1[id_ob1], db)
            assert_job_exists(objs2[id_ob2], db)
            ob1 = Promise(objs1[id_ob1])
            ob2 = Promise(objs2[id_ob2])

            params = dict(job_id='f', command_name=func.__name__)
            if dynamic:
                res = c.comp_config_dynamic(wrap_func_pair_dyn,
                                            func, id_ob1, ob1, id_ob2, ob2,
                                            **params)
            else:
                res = c.comp_config(wrap_func_pair,
                                    func, id_ob1, ob1, id_ob2, ob2,
                                    **params)
            results[(id_ob1, id_ob2)] = res
            jobs[(id_ob1, id_ob2)] = res.job_id

        warnings.warn('disabled report functionality')

        if create_reports:
            r = cx.comp_dynamic(report_results_pairs_jobs,
                                func, objspec1.name, objspec2.name, jobs)
            cx.add_report(r, 'jobs_pairs')

            r = cx.comp(report_results_pairs,
                        func, objspec1.name, objspec2.name, results)
            cx.add_report(r, 'pairs')
Exemplo n.º 5
0
def define_tests_some(context, objspec, names2test_objects, some,
                      create_reports):

    test_objects = names2test_objects[objspec.name]

    if not test_objects:
        msg = 'No test_objects for objects of kind %r.' % objspec.name
        print(msg)
        return

    if not some:
        msg = 'No mcdp_lang_tests specified for objects of kind %r.' % objspec.name
        print(msg)
        return

    db = context.cc.get_compmake_db()

    for x in some:
        f = x['function']
        which = x['which']
        dynamic = x['dynamic']
        results = {}

        c = context.child(f.__name__)
        c.add_extra_report_keys(objspec=objspec.name, function=f.__name__)

        objects = expand_string(which, list(test_objects))
        if not objects:
            msg = 'Which = %r did not give anything in %r.' % (which,
                                                               test_objects)
            raise ValueError(msg)

        print('Testing %s for %s' % (f, objects))

        it = iterate_context_names(c, objects, key=objspec.name)
        for cc, id_object in it:
            ob_job_id = test_objects[id_object]
            assert_job_exists(ob_job_id, db)
            ob = Promise(ob_job_id)
            # bjob_id = 'f'  # XXX
            job_id = '%s-%s' % (f.__name__, id_object)

            params = dict(job_id=job_id, command_name=f.__name__)
            if dynamic:
                res = cc.comp_config_dynamic(wrap_func_dyn, f, id_object, ob,
                                             **params)
            else:
                res = cc.comp_config(wrap_func, f, id_object, ob, **params)
            results[id_object] = res

        if create_reports:
            r = c.comp(report_results_single, f, objspec.name, results)
            c.add_report(r, 'some')
Exemplo n.º 6
0
def define_tests_some(context, objspec, names2test_objects,
                      some, create_reports):
    test_objects = names2test_objects[objspec.name]

    if not test_objects:
        msg = 'No test_objects for objects of kind %r.' % objspec.name
        print(msg)
        return

    if not some:
        msg = 'No mcdp_lang_tests specified for objects of kind %r.' % objspec.name
        print(msg)
        return

    db = context.cc.get_compmake_db()

    for x in some:
        f = x['function']
        which = x['which']
        dynamic = x['dynamic']
        results = {}

        c = context.child(f.__name__)
        c.add_extra_report_keys(objspec=objspec.name, function=f.__name__)

        objects = expand_string(which, list(test_objects))
        if not objects:
            msg = 'Which = %r did not give anything in %r.' % (which, test_objects)
            raise ValueError(msg)

        print('Testing %s for %s' % (f, objects))

        it = iterate_context_names(c, objects, key=objspec.name)
        for cc, id_object in it:
            ob_job_id = test_objects[id_object]
            assert_job_exists(ob_job_id, db)
            ob = Promise(ob_job_id)
            # bjob_id = 'f'  # XXX
            job_id = '%s-%s' % (f.__name__, id_object)

            params = dict(job_id=job_id, command_name=f.__name__)
            if dynamic:
                res = cc.comp_config_dynamic(wrap_func_dyn, f, id_object, ob,
                                             **params)
            else:
                res = cc.comp_config(wrap_func, f, id_object, ob,
                                     **params)
            results[id_object] = res

        if create_reports:
            r = c.comp(report_results_single, f, objspec.name, results)
            c.add_report(r, 'some')
Exemplo n.º 7
0
def define_tests_single(context, objspec, names2test_objects,
                        functions, create_reports):
    test_objects = names2test_objects[objspec.name]
    if not test_objects:
        msg = 'No test_objects for objects of kind %r.' % objspec.name
        print(msg)
        return

    if not functions:
        msg = 'No mcdp_lang_tests specified for objects of kind %r.' % objspec.name
        print(msg)

    db = context.cc.get_compmake_db()

    for x in functions:
        f = x['function']
        dynamic = x['dynamic']
        results = {}

        c = context.child(f.__name__)
        c.add_extra_report_keys(objspec=objspec.name, function=f.__name__)

        it = iterate_context_names(c, list(test_objects), key=objspec.name)
        for cc, id_object in it:
            ob_job_id = test_objects[id_object]
            assert_job_exists(ob_job_id, db)
            ob = Promise(ob_job_id)
            job_id = 'f'

            params = dict(job_id=job_id, command_name=f.__name__)
            if dynamic:
                res = cc.comp_config_dynamic(wrap_func_dyn, f, id_object, ob,
                                             **params)
            else:
                res = cc.comp_config(wrap_func, f, id_object, ob,
                                     **params)
            results[id_object] = res

        if create_reports:
            r = c.comp(report_results_single, f, objspec.name, results)
            c.add_report(r, 'single')
Exemplo n.º 8
0
def define_tests_single(context, objspec, names2test_objects, functions,
                        create_reports):
    test_objects = names2test_objects[objspec.name]
    if not test_objects:
        msg = 'No test_objects for objects of kind %r.' % objspec.name
        print(msg)
        return

    if not functions:
        msg = 'No mcdp_lang_tests specified for objects of kind %r.' % objspec.name
        print(msg)

    db = context.cc.get_compmake_db()

    for x in functions:
        f = x['function']
        dynamic = x['dynamic']
        results = {}

        c = context.child(f.__name__)
        c.add_extra_report_keys(objspec=objspec.name, function=f.__name__)

        it = iterate_context_names(c, list(test_objects), key=objspec.name)
        for cc, id_object in it:
            ob_job_id = test_objects[id_object]
            assert_job_exists(ob_job_id, db)
            ob = Promise(ob_job_id)
            job_id = 'f'

            params = dict(job_id=job_id, command_name=f.__name__)
            if dynamic:
                res = cc.comp_config_dynamic(wrap_func_dyn, f, id_object, ob,
                                             **params)
            else:
                res = cc.comp_config(wrap_func, f, id_object, ob, **params)
            results[id_object] = res

        if create_reports:
            r = c.comp(report_results_single, f, objspec.name, results)
            c.add_report(r, 'single')
Exemplo n.º 9
0
def get_testobjects_promises_for_objspec(context, objspec):
    warnings.warn('Need to be smarter here.')
    objspec.master.load()
    warnings.warn('Select test objects here.')
    objects = sorted(objspec.keys())

    if False:
        warnings.warn("Maybe warn here.")
        if not objects:
            msg = 'Could not find any test objects for %r.' % objspec
            raise ValueError(msg)

    promises = {}
    for id_object in objects:
        params = dict(job_id='%s-instance-%s' % (objspec.name, id_object),
                      command_name='instance_%s' % objspec.name)
        if objspec.instance_method is None:
            job = context.comp_config(get_spec,
                                      master_name=objspec.master.name,
                                      objspec_name=objspec.name,
                                      id_object=id_object,
                                      **params)
        else:
            job = context.comp_config(instance_object,
                                      master_name=objspec.master.name,
                                      objspec_name=objspec.name,
                                      id_object=id_object,
                                      **params)
        promises[id_object] = job.job_id
        db = context.cc.get_compmake_db()
        assert_job_exists(job.job_id, db)
        # print('defined %r -> %s' % (id_object, job.job_id))
        if not job.job_id.endswith(params['job_id']):
            msg = 'Wanted %r but got %r' % (params['job_id'], job.job_id)
            raise ValueError(msg)
    return promises
Exemplo n.º 10
0
def define_tests_pairs(context, objspec1, names2test_objects, pairs,
                       create_reports):
    objs1 = names2test_objects[objspec1.name]

    if not pairs:
        print('No %s+x pairs mcdp_lang_tests.' % (objspec1.name))
        return
    else:
        print('%d %s+x pairs mcdp_lang_tests.' % (len(pairs), objspec1.name))

    for x in pairs:
        objspec2 = x['objspec2']
        func = x['function']
        dynamic = x['dynamic']

        cx = context.child(func.__name__)
        cx.add_extra_report_keys(objspec1=objspec1.name,
                                 objspec2=objspec2.name,
                                 function=func.__name__,
                                 type='pairs')

        objs2 = names2test_objects[objspec2.name]
        if not objs2:
            print('No objects %r for pairs' % objspec2.name)
            continue

        results = {}
        jobs = {}

        db = context.cc.get_compmake_db()

        combinations = iterate_context_names_pair(cx,
                                                  list(objs1),
                                                  list(objs2),
                                                  key1=objspec1.name,
                                                  key2=objspec2.name)
        for c, id_ob1, id_ob2 in combinations:
            assert_job_exists(objs1[id_ob1], db)
            assert_job_exists(objs2[id_ob2], db)
            ob1 = Promise(objs1[id_ob1])
            ob2 = Promise(objs2[id_ob2])

            params = dict(job_id='f', command_name=func.__name__)
            if dynamic:
                res = c.comp_config_dynamic(wrap_func_pair_dyn, func, id_ob1,
                                            ob1, id_ob2, ob2, **params)
            else:
                res = c.comp_config(wrap_func_pair, func, id_ob1, ob1, id_ob2,
                                    ob2, **params)
            results[(id_ob1, id_ob2)] = res
            jobs[(id_ob1, id_ob2)] = res.job_id

        warnings.warn('disabled report functionality')

        if create_reports:
            r = cx.comp_dynamic(report_results_pairs_jobs, func, objspec1.name,
                                objspec2.name, jobs)
            cx.add_report(r, 'jobs_pairs')

            r = cx.comp(report_results_pairs, func, objspec1.name,
                        objspec2.name, results)
            cx.add_report(r, 'pairs')