def test__issue_213(self): """ Test if we can wait for different pilot states. """ session = radical.pilot.Session(database_url=DBURL, database_name=DBNAME) c = radical.pilot.Context('ssh') c.user_id = self.test_ssh_uid c.user_key = self.test_ssh_key session.add_context(c) pm = radical.pilot.PilotManager(session=session) cpd = radical.pilot.ComputePilotDescription() cpd.resource = self.test_resource cpd.cores = self.test_cores cpd.runtime = self.test_runtime cpd.sandbox = self.test_workdir pilot = pm.submit_pilots(pilot_descriptions=cpd) assert pilot is not None pilot.wait(state=radical.pilot.PMGR_ACTIVE, timeout=self.test_timeout*60) assert pilot.state == radical.pilot.PMGR_ACTIVE # the pilot should finish after it has reached run_time pilot.wait(timeout=self.test_timeout*60) assert pilot.state == radical.pilot.DONE session.close()
def test__issue_213(self): """ Test if we can wait for different pilot states. """ session = radical.pilot.Session(database_url=DBURL, database_name=DBNAME) c = radical.pilot.Context('ssh') c.user_id = self.test_ssh_uid c.user_key = self.test_ssh_key session.add_context(c) pm = radical.pilot.PilotManager(session=session) cpd = radical.pilot.ComputePilotDescription() cpd.resource = self.test_resource cpd.cores = self.test_cores cpd.runtime = self.test_runtime cpd.sandbox = self.test_workdir pilot = pm.submit_pilots(pilot_descriptions=cpd) assert pilot is not None pilot.wait(state=radical.pilot.PMGR_ACTIVE, timeout=self.test_timeout * 60) assert pilot.state == radical.pilot.PMGR_ACTIVE # the pilot should finish after it has reached run_time pilot.wait(timeout=self.test_timeout * 60) assert pilot.state == radical.pilot.DONE session.close()
def test__add_resource_config_2(self): """ Test if we can wait for different pilot states. """ session = radical.pilot.Session(database_url=DBURL) rc = radical.pilot.ResourceConfig("mylocalhost") rc.task_launch_method = "LOCAL" rc.mpi_launch_method = "MPIRUN" rc.job_manager_endpoint = "fork://localhost" rc.filesystem_endpoint = "file://localhost/" rc.bootstrapper = "default_bootstrapper.sh" rc.pilot_agent = "radical-pilot-agent-multicore.py" pm = radical.pilot.PilotManager(session=session) session.add_resource_config(rc) pd = radical.pilot.ComputePilotDescription() pd.resource = "mylocalhost" pd.cores = 1 pd.runtime = 1 # minutes pd.sandbox = "/tmp/radical.pilot.sandbox.unittests" pd.cleanup = True pilot = pm.submit_pilots(pd) pilot.wait(timeout=5 * 60) pilot.cancel() session.close()
def test__add_resource_config_2(self): """ Test if we can wait for different pilot states. """ session = radical.pilot.Session(database_url=DBURL) rc = radical.pilot.ResourceConfig("mylocalhost") rc.task_launch_method = "LOCAL" rc.mpi_launch_method = "MPIRUN" rc.job_manager_endpoint = "fork://localhost" rc.filesystem_endpoint = "file://localhost/" rc.bootstrapper = "default_bootstrapper.sh" rc.pilot_agent = "radical-pilot-agent-multicore.py" pm = radical.pilot.PilotManager(session=session) session.add_resource_config(rc) pd = radical.pilot.ComputePilotDescription() pd.resource = "mylocalhost" pd.cores = 1 pd.runtime = 1 # minutes pd.sandbox = "/tmp/radical.pilot.sandbox.unittests" pd.cleanup = True pilot = pm.submit_pilots(pd) pilot.wait(timeout=5*60) pilot.cancel() session.close()
def test__pilot_errors(self): """ Test if pilot errors are raised properly. """ session = radical.pilot.Session(database_url=DBURL, database_name=DBNAME) pm = radical.pilot.PilotManager(session=session) cpd = radical.pilot.ComputePilotDescription() cpd.resource = "local.localhost" cpd.cores = 1 cpd.runtime = 1 cpd.sandbox = "/non-/existing/directory..." cpd.cleanup = True pilot = pm.submit_pilots(pilot_descriptions=cpd) pilot.wait(timeout=5*60) assert pilot.state == radical.pilot.FAILED, "State is '%s' instead of 'Failed'." % pilot.state cpd = radical.pilot.ComputePilotDescription() cpd.resource = "local.localhost" cpd.cores = 100000000000 # This should fail - at least in 2014 ;-) cpd.runtime = 1 cpd.sandbox = "/tmp/radical.pilot.sandbox.unittests" cpd.cleanup = True pilot = pm.submit_pilots(pilot_descriptions=cpd) pilot.wait(timeout=5*60) assert pilot.state == radical.pilot.FAILED, ("state should be %s and not %s" % (radical.pilot.FAILED, pilot.state)) session.close()
def test__pilot_cancel(self): """ Test if we can cancel a pilot. """ session = radical.pilot.Session(database_url=DBURL, database_name=DBNAME) pm = radical.pilot.PilotManager(session=session) cpd = radical.pilot.ComputePilotDescription() cpd.resource = "local.localhost" cpd.cores = 1 cpd.runtime = 1 cpd.sandbox = "/tmp/radical.pilot.sandbox.unittests" cpd.cleanup = True pilot = pm.submit_pilots(pilot_descriptions=cpd) assert pilot is not None assert pilot.start_time is None assert pilot.stop_time is None pilot.wait(state=[radical.pilot.PMGR_ACTIVE, radical.pilot.FAILED], timeout=5*60) assert pilot.submission_time is not None assert pilot.state == radical.pilot.PMGR_ACTIVE assert pilot.start_time is not None # the pilot should finish after it has reached run_time pilot.cancel() pilot.wait(timeout=5*60) assert pilot.state == radical.pilot.CANCELED assert pilot.stop_time is not None session.close()
def test__pilot_wait(self): """ Test if we can wait for different pilot states. """ session = radical.pilot.Session(database_url=DBURL) pm = radical.pilot.PilotManager(session=session) cpd = radical.pilot.ComputePilotDescription() cpd.resource = "local.localhost" cpd.cores = 1 cpd.runtime = 1 cpd.sandbox = "/tmp/radical.pilot.sandbox.unittests" cpd.cleanup = True pilot = pm.submit_pilots(pilot_descriptions=cpd) assert pilot is not None assert pilot.start_time is None assert pilot.stop_time is None pilot.wait(state=[radical.pilot.PMGR_ACTIVE, radical.pilot.FAILED], timeout=5*60) assert pilot.submission_time is not None assert pilot.state == radical.pilot.PMGR_ACTIVE assert pilot.start_time is not None assert pilot.log is not None assert pilot.sandbox == "file://localhost%s/pilot-%s/" % (cpd.sandbox, pilot.uid) # the pilot should finish after it has reached run_time pilot.wait(timeout=5*60) assert pilot.state == radical.pilot.DONE assert pilot.stop_time is not None session.close()
def test__pilot_wait(self): """ Test if we can wait for different pilot states. """ session = radical.pilot.Session(database_url=DBURL) pm = radical.pilot.PilotManager(session=session) cpd = radical.pilot.ComputePilotDescription() cpd.resource = "local.localhost" cpd.cores = 1 cpd.runtime = 1 cpd.sandbox = "/tmp/radical.pilot.sandbox.unittests" cpd.cleanup = True pilot = pm.submit_pilots(pilot_descriptions=cpd) assert pilot is not None assert pilot.start_time is None assert pilot.stop_time is None pilot.wait(state=[radical.pilot.ACTIVE, radical.pilot.FAILED], timeout=5*60) assert pilot.submission_time is not None assert pilot.state == radical.pilot.ACTIVE assert pilot.start_time is not None assert pilot.log is not None assert pilot.sandbox == "file://localhost%s/pilot-%s/" % (cpd.sandbox, pilot.uid) # the pilot should finish after it has reached run_time pilot.wait(timeout=5*60) assert pilot.state == radical.pilot.DONE assert pilot.stop_time is not None session.close()
def test__pilot_cancel(self): """ Test if we can cancel a pilot. """ session = radical.pilot.Session(database_url=DBURL, database_name=DBNAME) pm = radical.pilot.PilotManager(session=session) cpd = radical.pilot.ComputePilotDescription() cpd.resource = "local.localhost" cpd.cores = 1 cpd.runtime = 1 cpd.sandbox = "/tmp/radical.pilot.sandbox.unittests" cpd.cleanup = True pilot = pm.submit_pilots(pilot_descriptions=cpd) assert pilot is not None assert pilot.start_time is None assert pilot.stop_time is None pilot.wait(state=[radical.pilot.ACTIVE, radical.pilot.FAILED], timeout=5*60) assert pilot.submission_time is not None assert pilot.state == radical.pilot.ACTIVE assert pilot.start_time is not None # the pilot should finish after it has reached run_time pilot.cancel() pilot.wait(timeout=5*60) assert pilot.state == radical.pilot.CANCELED assert pilot.stop_time is not None session.close()
def test__issue_169_part_1(self): """ https://github.com/radical-cybertools/radical.pilot/issues/169 """ session = radical.pilot.Session(database_url=DBURL, database_name=DBNAME) pm = radical.pilot.PilotManager(session=session) cpd = radical.pilot.ComputePilotDescription() cpd.resource = "local.localhost" cpd.cores = 1 cpd.runtime = 1 cpd.sandbox = "/non-/existing/directory..." cpd.cleanup = True for i in range(0, 8): pilot = pm.submit_pilots(pilot_descriptions=cpd) pilot.wait(state=radical.pilot.FAILED, timeout=5*60) assert pilot.state == radical.pilot.FAILED, "State is %s instead of 'Failed'." % pilot.state session.close()
def test__issue_18_part_1(self): """ https://github.com/radical-cybertools/radical.pilot/issues/18 """ import saga session = radical.pilot.Session(database_url=DBURL, database_name=DBNAME) pm = radical.pilot.PilotManager(session=session) cpd = radical.pilot.ComputePilotDescription() cpd.resource = "local.localhost" cpd.cores = 1 cpd.runtime = 5 cpd.sandbox = "/tmp/radical.pilot.sandbox.unittests" cpd.cleanup = True pilot = pm.submit_pilots(pilot_descriptions=cpd) pilot.wait(state=radical.pilot.PMGR_ACTIVE, timeout=5 * 60) # Now we extract the saga job id from the logs and KILL THE PROCESS saga_id = None for log_entry in pilot.log: if "SAGA job submitted with job id" in log_entry: saga_id = log_entry.replace("SAGA job submitted with job id ", "") if saga_id is None: assert False, "Couldn't find SAGA Job ID in logs." # KILL THE AGENT PROCESS. s = saga.job.Service("fork://localhost") j = s.get_job(saga_id) j.cancel() pilot.wait(timeout=60) assert pilot.state == radical.pilot.FAILED session.close()
def test__remote_pilot_cancel(self): """ Test if we can cancel a pilot. """ session = radical.pilot.Session(database_url=DBURL, database_name=DBNAME) c = radical.pilot.Context('ssh') c.user_id = self.test_ssh_uid c.user_key = self.test_ssh_key session.add_context(c) pm = radical.pilot.PilotManager(session=session) cpd = radical.pilot.ComputePilotDescription() cpd.resource = self.test_resource cpd.cores = self.test_cores cpd.runtime = 2 cpd.sandbox = self.test_workdir pilot = pm.submit_pilots(pilot_descriptions=cpd) assert pilot is not None #assert cu.start_time is None #assert cu.start_time is None pilot.wait(state=radical.pilot.ACTIVE, timeout=5 * 60) assert pilot.state == radical.pilot.ACTIVE, "Expected state 'ACTIVE' but got %s" % pilot.state assert pilot.submission_time is not None assert pilot.start_time is not None # the pilot should finish after it has reached run_time pilot.cancel() pilot.wait(timeout=5 * 60) assert pilot.state == radical.pilot.CANCELED assert pilot.stop_time is not None session.close()
def test__issue_18_part_1(self): """ https://github.com/radical-cybertools/radical.pilot/issues/18 """ import saga session = radical.pilot.Session(database_url=DBURL, database_name=DBNAME) pm = radical.pilot.PilotManager(session=session) cpd = radical.pilot.ComputePilotDescription() cpd.resource = "local.localhost" cpd.cores = 1 cpd.runtime = 5 cpd.sandbox = "/tmp/radical.pilot.sandbox.unittests" cpd.cleanup = True pilot = pm.submit_pilots(pilot_descriptions=cpd) pilot.wait(state=radical.pilot.ACTIVE, timeout=5*60) # Now we extract the saga job id from the logs and KILL THE PROCESS saga_id = None for log_entry in pilot.log: if "SAGA job submitted with job id" in log_entry: saga_id = log_entry.replace("SAGA job submitted with job id ", "") if saga_id is None: assert False, "Couldn't find SAGA Job ID in logs." # KILL THE AGENT PROCESS. s = saga.job.Service("fork://localhost") j = s.get_job(saga_id) j.cancel() pilot.wait(timeout=60) assert pilot.state == radical.pilot.FAILED session.close()
def test__remote_pilot_cancel(self): """ Test if we can cancel a pilot. """ session = radical.pilot.Session(database_url=DBURL, database_name=DBNAME) c = radical.pilot.Context('ssh') c.user_id = self.test_ssh_uid c.user_key = self.test_ssh_key session.add_context(c) pm = radical.pilot.PilotManager(session=session) cpd = radical.pilot.ComputePilotDescription() cpd.resource = self.test_resource cpd.cores = self.test_cores cpd.runtime = 2 cpd.sandbox = self.test_workdir pilot = pm.submit_pilots(pilot_descriptions=cpd) assert pilot is not None #assert cu.start_time is None #assert cu.start_time is None pilot.wait(state=radical.pilot.ACTIVE, timeout=5*60) assert pilot.state == radical.pilot.ACTIVE, "Expected state 'ACTIVE' but got %s" % pilot.state assert pilot.submission_time is not None assert pilot.start_time is not None # the pilot should finish after it has reached run_time pilot.cancel() pilot.wait(timeout=5*60) assert pilot.state == radical.pilot.CANCELED assert pilot.stop_time is not None session.close()