Ejemplo n.º 1
0
def test_cleanup(jobs_default, caplog, exc, expect_msg):
	jm = Jobmgr(jobs_default)
	if exc and exc not in (JobBuildingException, JobFailException, KeyboardInterrupt):
		with pytest.raises(exc):
			jm.cleanup(exc())
	else:
		with pytest.raises(SystemExit):
			jm.cleanup(exc and exc())
	assert jm.stop
	for msg in expect_msg:
		assert msg in caplog.text
Ejemplo n.º 2
0
def test_cleanup_with_running_jobs(jobs_all):
    jm = Jobmgr(jobs_all)
    for job in jobs_all:
        job.restore_state()
    with pytest.raises(SystemExit):
        jm.cleanup()
    for job in jm.jobs:
        if job.orig_state in (STATES.SUBMITTING, STATES.RUNNING,
                              STATES.RETRYING):
            assert job.state == STATES.KILLED
        elif job.orig_state in (STATES.BUILT, STATES.DONEFAILED):
            assert job.state == STATES.KILLFAILED
        else:
            assert job.state not in (STATES.KILLED, STATES.KILLFAILED)