Exemplo n.º 1
0
def on_user_add(login, src_case_id=66):
    """
    Create default case for new user.
    Args:
        login - str.
    """
    t_start = dt.datetime.now()
    log_ext = {'task_name': 'on_user_add', 'wroker_ver': __version__}
    logger = get_logger(**log_ext)
    src_case = lunaport_c1.case_get(src_case_id)
    dst_case = {
        'name': '{}_sandbox'.format(login),
        'descr': src_case['descr'],
        'oracle': src_case['oracle'],
    }
    lunaport_c1.case_post(dst_case)
Exemplo n.º 2
0
def on_user_add(login, src_case_id=66):
    """
    Create default case for new user.
    Args:
        login - str.
    """
    t_start = dt.datetime.now()
    log_ext = {
        'task_name': 'on_user_add',
        'wroker_ver': __version__
    }
    logger = get_logger(**log_ext)
    src_case = lunaport_c1.case_get(src_case_id)
    dst_case = {
        'name': '{}_sandbox'.format(login),
        'descr': src_case['descr'],
        'oracle': src_case['oracle'],
    }
    lunaport_c1.case_post(dst_case)
Exemplo n.º 3
0
def proc_tank_scheduled(redis_msg, **kw):
    ext = {'test_id': redis_msg.get('id')}
    logger = get_logger(**ext)
    try:
    except TankClientError as e:
        logger.error('Tank API call failed: {}'.format(e))
        raise

    if tank_msg['status_code'] == 'PREPARING':
        return

    try:
        lunaport_msg = lunaport_c1.test_get(redis_msg['id'])
        case_struct = lunaport_c1.case_get(lunaport_msg.get('case_id'))
    except LunaportClientError as e:
        logger.error('Lunaport client call failed:{}'.format(e))
        raise

    if tank_msg['status_code'] == 'FINISHED' and tank_msg['exit_code'] == 1:
        # Test was scheduled but excution failed
        redis.hdel(r_adr['monitor_start'], kw['id'])
        notify_test('on_start_failed', lunaport_msg, None, case=case_struct,
                    tank_msg=tank_msg)
        return

    diff = {
        'status': TestStateTr.port_by_tank(tank_msg.get('status_code')),
    }
    t_summary = {}
    if tank_msg.get('lunapark_id'):
        try:
                l_test_id=tank_msg['lunapark_id']).json().pop()
            t_summary.update({'t_tank_id': redis_msg['t_tank_id']})
            diff.update({
                'lunapark': t_summary,
            })
            if t_summary.get('fd'):
                diff.update({
                    'started_at': msk_iso_to_utc(t_summary['fd']).isoformat(),
                })
Exemplo n.º 4
0
            if not eval_only:
                logger.error('Lunaport client call failed:{}'.format(e))
                raise

    exec_time = str(dt.datetime.now() - t_start)
    msg = [
        'Test:{} ',
        ' Phout reduced in: {} ',
        ' phout_df size:{} bytes({} MB)',
    ]
    logger.info('|'.join(msg).format(test_id, exec_time, *df_size(phout_df)))

    # assert
    t_start = dt.datetime.now()
    try:
        case_struct = lunaport_c1.case_get(test_struct['case']['id'])
    except LunaportClientError as e:
        logger.error('Lunaport client call failed:{}'.format(e))
        raise

    asserts = t_assert.get_asserts()
    exec_wrap = lambda oracle_part: t_assert.exec_assert(
        test_id, phout_df, res, oracle_part, asserts, logger=logger)

    t_evaluation = map(exec_wrap, case_struct['oracle'])
    t_resolution = all([el['passed'] for el in t_evaluation])
    try:
        eval_struct, eval_loc = lunaport_c1.eval_post(
            test_id, case_struct['oracle'], t_evaluation, t_resolution)
    except LunaportClientError as e:
        logger.error('Lunaport client call failed:{}'.format(e))