Belle II Software development
TestClusterControlDrmaa Class Reference
Inheritance diagram for TestClusterControlDrmaa:

Classes

class  SessionMock
 

Public Member Functions

def test_no_drmaa (self)
 
def test_submit_and_monitor_job (self)
 

Detailed Description

Test for for the DRMAA-backend of the clustercontrol

Definition at line 21 of file test_clustercontroldrmaa.py.

Member Function Documentation

◆ test_no_drmaa()

def test_no_drmaa (   self)
Overwrite drmaa module and see what happens ...

Definition at line 69 of file test_clustercontroldrmaa.py.

69 def test_no_drmaa(self):
70 """
71 Overwrite drmaa module and see what happens ...
72 """
73 sys.modules["drmaa"] = None
74 self.assertFalse(Cluster.is_supported())
75

◆ test_submit_and_monitor_job()

def test_submit_and_monitor_job (   self)
Test to submit and monitor a regular job

Definition at line 76 of file test_clustercontroldrmaa.py.

76 def test_submit_and_monitor_job(self):
77 """
78 Test to submit and monitor a regular job
79 """
80
81 with tempfile.TemporaryDirectory() as td:
82 # switch to temp folder as the cluster controller will create
83 # some helper files
84 os.chdir(str(td))
85
86 drmaa_mock = MagicMock()
87 drmaa_mock.Session = (
88 self.SessionMock
89 ) # MagicMock(return_value=session_mock)
90 drmaa_mock.JobState = self.SessionMock.JobState
91
92 sys.modules["drmaa"] = drmaa_mock
93
94 # this just imports the drmaa module which should always work with our
95 # mock
96 self.assertTrue(Cluster.is_supported())
97
98 job = Script(path="myscript1.py", package="test_package", log=None)
99
100 cc = Cluster()
101 cc.execute(job)
102
103 # check if job id has been set
104 self.assertTrue(job.job_id)
105
106 # check on job, not finished yet
107 self.assertFalse(cc.is_job_finished(job)[0])
108
109 # check on job, finished !
110 # change behaviour of jobStatus
111 self.SessionMock.jobStatusReturn = self.SessionMock.JobState.DONE
112
113 self.assertTrue(cc.is_job_finished(job)[0])
114
115 cc.terminate(job)
116
117

The documentation for this class was generated from the following file: