def testFailJobOnMerge(self): from Ganga.GPI import CustomMerger self.runJobSlice() tmpdir = tempfile.mktemp() os.mkdir(tmpdir) file_name = os.path.join(tmpdir, 'merge.py') with open(file_name, 'w') as module_file: module_file.write("""def mergefiles(file_list, output_file): '''Free script for merging files''' return False """) cm = CustomMerger(module=file_name) cm.files = ['out.txt', 'out2.txt'] with pytest.raises(PostProcessException): cm.merge(self.jobslice, tmpdir) j = self.jobslice[0].copy() j.splitter = CopySplitter() j.postprocessors = cm j.submit() run_until_state(j, state='failed') assert j.status == 'failed'
def testFailJobOnMerge(self): from Ganga.GPI import CustomMerger self.runJobSlice() tmpdir = tempfile.mktemp() os.mkdir(tmpdir) file_name = os.path.join(tmpdir, 'merge.py') with open(file_name, 'w') as module_file: module_file.write("""def mergefiles(file_list, output_file): '''Free script for merging files''' return False """) cm = CustomMerger(module=file_name) cm.files = ['out.txt', 'out2.txt'] with pytest.raises(PostProcessException): cm.merge(self.jobslice, tmpdir) j = self.jobslice[0].copy() j.splitter = CopySplitter() j.postprocessors = cm j.submit() run_until_state(j, state='failed') assert j.status == 'failed'
def testMergeRemoval(self): from Ganga.GPI import Job, Executable, Local, LocalFile, jobs # see Savannah 33710 j = Job() jobID = j.id # job will run for at least 20 seconds j.application = Executable(exe="sh", args=["-c", "sleep 20; echo foo > out.txt"]) j.backend = Local() j.outputfiles = [LocalFile("out.txt")] j.splitter = CopySplitter() j.postprocessors = MergerTester(files=["out.txt"]) j.postprocessors[0].ignorefailed = True j.postprocessors[0].alwaysfail = True j.postprocessors[0].wait = 10 j.submit() run_until_state(j, state="running") j.remove() with pytest.raises(KeyError): jobs(jobID)
def testMergeThatAlwaysFailsOverwrite(self): from Ganga.GPI import Job, Executable, Local, LocalFile j = Job() j.application = Executable(exe='sh', args=['-c', 'echo foo > out.txt']) j.backend = Local() j.outputfiles = [LocalFile('out.txt')] j.splitter = CopySplitter() j.postprocessors = MergerTester(files=['out.txt'], overwrite=True) j.submit() assert run_until_state(j, 'failed', timeout=60) assert os.path.exists(os.path.join(j.outputdir, 'out.txt.merge_summary')), 'Summary file should be created'
def testMergeThatAlwaysFailsOverwrite(self): from Ganga.GPI import Job, Executable, Local, LocalFile j = Job() j.application = Executable(exe='sh', args=['-c', 'echo foo > out.txt']) j.backend = Local() j.outputfiles = [LocalFile('out.txt')] j.splitter = CopySplitter() j.postprocessors = MergerTester(files=['out.txt'], overwrite=True) j.submit() assert run_until_state(j, 'failed', timeout=60) assert os.path.exists(os.path.join(j.outputdir, 'out.txt.merge_summary')), 'Summary file should be created'
def testMergeRemoval(self): from Ganga.GPI import Job, Executable, Local, LocalFile, jobs # see Savannah 33710 j = Job() jobID = j.id # job will run for at least 20 seconds j.application = Executable(exe='sh', args=['-c', 'sleep 20; echo foo > out.txt']) j.backend = Local() j.outputfiles = [LocalFile('out.txt')] j.splitter = CopySplitter() j.postprocessors = MergerTester(files=['out.txt']) j.postprocessors[0].ignorefailed = True j.postprocessors[0].alwaysfail = True j.postprocessors[0].wait = 10 j.submit() run_until_state(j, state='running') j.remove() with pytest.raises(KeyError): jobs(jobID)
def test_Savannah28511(self): from Ganga.GPI import Job, TestSubmitter j = Job() j.submit() assert run_until_completed(j, timeout=20), 'Job is not completed' j.resubmit() assert run_until_completed(j, timeout=30), 'Job is not completed after fail during resubmit' j._impl.updateStatus('failed') assert run_until_state(j, timeout=20, state='failed'), 'Job is not failed' j.resubmit() assert run_until_completed(j, timeout=20), 'Job is not completed after resubmit'
def test_Savannah28511(self): from Ganga.GPI import Job, TestSubmitter j = Job() j.submit() assert run_until_completed(j, timeout=20), 'Job is not completed' j.resubmit() assert run_until_completed( j, timeout=30), 'Job is not completed after fail during resubmit' j._impl.updateStatus('failed') assert run_until_state(j, timeout=20, state='failed'), 'Job is not failed' j.resubmit() assert run_until_completed( j, timeout=20), 'Job is not completed after resubmit'
def testFailure(self): """ Check a simple job fails and raises the correct exception """ from Ganga.GPI import Job, Dirac, Executable import time j = Job(backend=Dirac()) j.application = Executable(exe='ech') j.application.args = ['Hello World'] j.submit() assert run_until_state(j, 'failed', 220) filepath = os.path.join(j.outputdir, 'Ganga_Executable.log') i = 0 while not os.path.exists(filepath) and i < 10: i = i + 1 time.sleep(5) found = False with open(filepath, 'r') as f: for line in f: if "Exception occured in running process: ['ech', 'Hello World']" in line: found = True assert found
def testFailure(self): """ Check a simple job fails and raises the correct exception """ from Ganga.GPI import Job, Dirac, Executable import time j = Job(backend = Dirac()) j.application = Executable(exe = 'ech') j.application.args = ['Hello World'] j.submit() assert run_until_state(j, 'failed', 220) filepath = os.path.join(j.outputdir, 'Ganga_Executable.log') i = 0 while not os.path.exists(filepath) and i < 10: i=i+1 time.sleep(5) found = False with open(filepath, 'r') as f: for line in f: if "Exception occured in running process: ['ech', 'Hello World']" in line: found = True assert found