예제 #1
0
def test_missing_job_id_validations_okay(custom_job_id1):
    """
    does parse_job_id still work if you don't define a validation func?
    """
    items = dag_tools.parse_job_id(custom_job_id1, '20130101_876_equal2me')
    nt.assert_equal(items['date'], 20130101)
    nt.assert_equal(items['client_id'], 876)
    nt.assert_equal(items['unvalidated_field'], 'equal2me')
예제 #2
0
def validate_job_id(app_name, job_id, q, timeout):
    """Return True if valid job_id.
    If invalid, do whatever cleanup for this job is necessary and return False.
      --> necessary cleanup may include removing this job_id from queue
    """
    if job_id is None:
        log.info('No jobs found in %d seconds...' % timeout,
                 extra=dict(app_name=app_name))
        return False
    try:
        dt.parse_job_id(app_name, job_id)
    except exceptions.InvalidJobId as err:
        log.error(
            ("Stolos found an invalid job_id.  Removing it from queue"
             " and marking that job_id as failed.  Error details: %s") % err,
            extra=dict(app_name=app_name, job_id=job_id))
        q.consume()
        qb._set_state_unsafe(app_name, job_id, failed=True)
        return False
    return True
예제 #3
0
파일: runner.py 프로젝트: kszucs/stolos
def validate_job_id(app_name, job_id, q, timeout):
    """Return True if valid job_id.
    If invalid, do whatever cleanup for this job is necessary and return False.
      --> necessary cleanup may include removing this job_id from queue
    """
    if job_id is None:
        log.info('No jobs found in %d seconds...' % timeout, extra=dict(
            app_name=app_name))
        return False
    try:
        dt.parse_job_id(app_name, job_id)
    except exceptions.InvalidJobId as err:
        log.error((
            "Stolos found an invalid job_id.  Removing it from queue"
            " and marking that job_id as failed.  Error details: %s") % err,
            extra=dict(app_name=app_name, job_id=job_id))
        q.consume()
        qb._set_state_unsafe(
            app_name, job_id, failed=True)
        return False
    return True
예제 #4
0
def test_job_id_validations(app2, job_id1):
    with nt.assert_raises(exceptions.InvalidJobId):
        dag_tools.parse_job_id(app2, job_id1.replace('profile', ''))

    with nt.assert_raises(exceptions.InvalidJobId):
        dag_tools.parse_job_id(app2, job_id1.replace('1111', '11aa'))

    with nt.assert_raises(exceptions.InvalidJobId):
        dag_tools.parse_job_id(app2, job_id1.replace('20140606', '20149606'))