Exemple #1
0
def test_check_task_awsem_fails_if_no_job_started(check_task_input, s3):
    # ensure there is no job started
    jobid = 'notmyjobid'
    check_task_input_modified = check_task_input
    check_task_input_modified['jobid'] = jobid
    job_started = "%s.job_started" % jobid
    s3.delete_objects(Delete={'Objects': [{'Key': job_started}]})
    with pytest.raises(EC2StartingException) as excinfo:
        service.handler(check_task_input_modified, '')

    assert 'Failed to find jobid' in str(excinfo.value)
Exemple #2
0
def test_check_task_awsem_fails_if_no_job_started_for_too_long(check_task_input, s3):
    # ensure there is no job started
    jobid = 'notmyjobid'
    check_task_input_modified = check_task_input
    check_task_input_modified['jobid'] = jobid
    check_task_input_modified['config']['start_time'] = datetime.strftime(datetime.now(tzutc()) - timedelta(minutes=13),
                                                                          AWSEM_TIME_STAMP_FORMAT)
    job_started = "%s.job_started" % jobid
    s3.delete_objects(Delete={'Objects': [{'Key': job_started}]})
    with pytest.raises(EC2IdleException) as excinfo:
        service.handler(check_task_input_modified, '')
    assert 'Failed to find jobid' in str(excinfo.value)
Exemple #3
0
def test_check_task_awsem(check_task_input, s3):
    jobid = 'lalala'
    check_task_input_modified = check_task_input
    check_task_input_modified['jobid'] = jobid
    job_started = "%s.job_started" % jobid
    s3.put_object(Body=b'', Key=job_started)
    job_success = "%s.success" % jobid
    s3.put_object(Body=b'', Key=job_success)
    postrunjson = "%s.postrun.json" % jobid
    jsondict = {
        "config": {
            "log_bucket": "somelogbucket"
        },
        "Job": {
            "JOBID": jobid,
            "start_time": '20190814-21:01:07-UTC',
            "App": {},
            "Output": {},
            "Input": {
                'Input_files_data': {},
                'Input_parameters': {},
                'Secondary_files_data': {}
            }
        }
    }
    jsoncontent = json.dumps(jsondict)
    s3.put_object(Body=jsoncontent.encode(), Key=postrunjson)
    with pytest.raises(MetricRetrievalException) as excinfo:
        retval = service.handler(check_task_input_modified, '')
    assert 'error getting metrics' in str(excinfo)
    s3.delete_objects(Delete={'Objects': [{'Key': job_started}]})
    s3.delete_objects(Delete={'Objects': [{'Key': job_success}]})
    s3.delete_objects(Delete={'Objects': [{'Key': postrunjson}]})
Exemple #4
0
def test_check_task_awsem_with_long_postrunjson(check_task_input, s3):
    jobid = 'some_uniq_jobid'
    check_task_input_modified = check_task_input
    check_task_input_modified['jobid'] = jobid
    job_started = "%s.job_started" % jobid
    s3.put_object(Body=b'', Key=job_started)
    job_success = "%s.success" % jobid
    s3.put_object(Body=b'', Key=job_success)
    postrunjson = "%s.postrun.json" % jobid
    verylongstring = ''.join(
        random.choice(string.ascii_uppercase) for _ in range(50000))
    jsondict = {
        "config": {
            "log_bucket": "somelogbucket"
        },
        "Job": {
            "JOBID": jobid,
            "start_time": '20190814-21:01:07-UTC',
            "App": {},
            "Output": {},
            "Input": {
                'Input_files_data': {},
                'Input_parameters': {},
                'Secondary_files_data': {}
            }
        },
        "commands": verylongstring
    }
    jsoncontent = json.dumps(jsondict)
    s3.put_object(Body=jsoncontent.encode(), Key=postrunjson)
    with pytest.raises(MetricRetrievalException) as excinfo:
        retval = service.handler(check_task_input_modified, '')
    assert 'error getting metrics' in str(excinfo.value)
    s3.delete_objects(Delete={'Objects': [{'Key': job_started}]})
    s3.delete_objects(Delete={'Objects': [{'Key': job_success}]})
    s3.delete_objects(Delete={'Objects': [{'Key': postrunjson}]})
Exemple #5
0
def test_check_task_awsem_throws_exception_if_not_done(check_task_input):
    with pytest.raises(StillRunningException) as excinfo:
        service.handler(check_task_input, '')
    assert 'still running' in str(excinfo.value)
    assert 'error' not in check_task_input