Esempio n. 1
0
def proc_luna_running(**kw):
    """ Fetch test statuses from Redis, if test finisged notify service via API
        and call reduce job.
    """
    ext = {'test_id': kw.get('redis_value', {}).get('id')}
    logger = get_logger(**ext)

    if not ('t_fqdn' in kw and 't_tank_id' in kw):
        logger.erro('proc_luna_running call. Malformed params:{}'.format(kw))

    try:
    except TankClientError as e:
        logger.error('Tank API call failed: {}'.format(e))
        raise

    if tank_msg['status_code'] != 'FINISHED':
        if kw.get('status') and TestStateTr.tank_by_port(kw.get('status')) != tank_msg['status_code']:
            # test state changes since last check, need to notify
            port_state = TestStateTr.port_by_tank(tank_msg['status_code'])
            redis_value = kw['redis_value']
            redis_value.update({'status': port_state})
            redis.hset(r_adr['monitor_finish'], kw['id'],
                       msgpack.packb(redis_value))
            diff = {
                'status': port_state,
            }
Esempio n. 2
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(),
                })