本文整理汇总了Python中radical.utils.testing.get_test_config函数的典型用法代码示例。如果您正苦于以下问题:Python get_test_config函数的具体用法?Python get_test_config怎么用?Python get_test_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_test_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_replica_remove
def test_replica_remove():
""" Test logical file remove, which should remove the file from the remote resource
"""
try:
tc = testing.get_test_config ()
the_url = tc.job_service_url # from test config file
the_session = tc.session # from test config file
replica_url = tc.replica_url
replica_directory = saga.replica.LogicalDirectory(replica_url)
home_dir = os.path.expanduser("~"+"/")
print "Creating temporary file of size %dM : %s" % \
(FILE_SIZE, home_dir+TEMP_FILENAME)
# create a file for us to use
with open(home_dir+TEMP_FILENAME, "wb") as f:
f.write ("x" * (FILE_SIZE * pow(2,20)) )
print "Creating logical directory object"
mydir = saga.replica.LogicalDirectory(replica_url)
print "Uploading temporary"
myfile = saga.replica.LogicalFile(replica_url+TEMP_FILENAME)
myfile.upload(home_dir + TEMP_FILENAME, \
"irods:///this/path/is/ignored/?resource="+IRODS_RESOURCE, saga.replica.OVERWRITE)
print "Removing temporary file."
myfile.remove()
assert True
except saga.SagaException as ex:
# print ex.traceback
assert False, "unexpected exception %s\n%s" % (ex.traceback, ex)
示例2: test_job_service_create
def test_job_service_create():
""" Test service.create_job() - expecting state 'NEW'
"""
js = None
try:
tc = testing.get_test_config ()
js = saga.job.Service(tc.job_service_url, tc.session)
jd = saga.job.Description()
jd.executable = '/bin/sleep'
jd.arguments = ['10']
# add options from the test .cfg file if set
jd = sutc.add_tc_params_to_jd(tc=tc, jd=jd)
j = js.create_job(jd)
assert j.state == j.get_state()
assert j.state == saga.job.NEW
except saga.NotImplemented as ni:
assert tc.notimpl_warn_only, "%s " % ni
if tc.notimpl_warn_only:
print "%s " % ni
except saga.SagaException as se:
assert False, "Unexpected exception: %s" % se
finally:
_silent_close_js(js)
示例3: test_job_wait
def test_job_wait():
""" Test job.wait() - expecting state: DONE (this test might take a while)
"""
js = None
j = None
try:
tc = testing.get_test_config ()
js = saga.job.Service(tc.job_service_url, tc.session)
jd = saga.job.Description()
jd.executable = '/bin/sleep'
jd.arguments = ['10']
# add options from the test .cfg file if set
jd = sutc.add_tc_params_to_jd(tc=tc, jd=jd)
j = js.create_job(jd)
j.run()
j.wait()
assert j.state == saga.job.DONE, "%s != %s" % (j.state, saga.job.DONE)
except saga.NotImplemented as ni:
assert tc.notimpl_warn_only, "%s " % ni
if tc.notimpl_warn_only:
print "%s " % ni
except saga.SagaException as se:
assert False, "Unexpected exception: %s" % se
finally:
_silent_cancel(j)
_silent_close_js(js)
示例4: test_get_exit_code
def test_get_exit_code():
""" Test job.exit_code
"""
js = None
j = None
try:
tc = testing.get_test_config ()
js = saga.job.Service(tc.job_service_url, tc.session)
jd = saga.job.Description()
jd.executable = "/bin/sleep"
# add options from the test .cfg file if set
jd = sutc.add_tc_params_to_jd(tc=tc, jd=jd)
j = js.create_job(jd)
j.run()
j.wait()
ec = j.exit_code
assert ec == 1, "%s != 1" % ec
except saga.NotImplemented as ni:
assert tc.notimpl_warn_only, "%s " % ni
if tc.notimpl_warn_only:
print "%s " % ni
except saga.SagaException as se:
assert False, "Unexpected exception: %s" % se
finally:
_silent_cancel(j)
_silent_close_js(js)
示例5: test_job_suspend_resume
def test_job_suspend_resume():
""" Test job.suspend()/resume() - expecting state: SUSPENDED/RUNNING
"""
js = None
j = None
try:
tc = testing.get_test_config ()
js = saga.job.Service(tc.job_service_url, tc.session)
jd = saga.job.Description()
jd.executable = '/bin/sleep'
jd.arguments = ['20']
# add options from the test .cfg file if set
jd = sutc.add_tc_params_to_jd(tc=tc, jd=jd)
j = js.create_job(jd)
j.run()
j.suspend()
assert j.state == saga.job.SUSPENDED
assert j.state == j.get_state()
j.resume()
assert j.state == saga.job.RUNNING
assert j.state == j.get_state()
except saga.NotImplemented as ni:
assert tc.notimpl_warn_only, "%s " % ni
if tc.notimpl_warn_only:
print "%s " % ni
except saga.SagaException as se:
assert False, "Unexpected exception: %s" % se
finally:
_silent_cancel(j)
_silent_close_js(js)
示例6: test_derive_overlay
def test_derive_overlay():
"""
test overlay derivation
"""
tc = rut.get_test_config()
wl_dict = tc.workload_dict
wl = troy.Workload()
planner = troy.Planner()
# pprint.pprint(wl_dict)
if not 'tasks' in wl_dict:
assert False, "no tasks in workload dict"
if not len(wl_dict['tasks']):
assert False, "zero tasks in workload dict"
for task_dict in wl_dict['tasks']:
task_description = troy.TaskDescription(task_dict)
wl.add_task(task_description)
for relation_dict in wl_dict['relations']:
relation_description = troy.RelationDescription(relation_dict)
wl.add_relation(relation_description)
overlay_id = planner.derive_overlay(wl.id)
overlay = troy.OverlayManager.get_overlay(overlay_id)
if not overlay.description.cores :
assert False, "No cores requested"
if not overlay.description.wall_time :
assert False, "Walltime is zero"
示例7: test_expand_workload
def test_expand_workload():
"""
test workload planning
"""
tc = rut.get_test_config()
wl_dict = tc.workload_dict
wl = troy.Workload()
planner = troy.Planner()
# pprint.pprint(wl_dict)
if not 'tasks' in wl_dict:
assert False, "no tasks in workload dict"
if not len(wl_dict['tasks']):
assert False, "zero tasks in workload dict"
for task_dict in wl_dict['tasks']:
task_description = troy.TaskDescription(task_dict)
wl.add_task(task_description)
for relation_dict in wl_dict['relations']:
relation_description = troy.RelationDescription(relation_dict)
wl.add_relation(relation_description)
if not wl.state is troy.DESCRIBED:
assert False, "Workload state != DESCRIBED"
planner.expand_workload(wl.id)
if not wl.state is troy.PLANNED:
assert False, "Workload state != PLANNED"
示例8: test_list_jobs
def test_list_jobs():
""" Test if a submitted job shows up in Service.list() """
j = None
js = None
try:
tc = testing.get_test_config ()
js = saga.job.Service(tc.job_service_url, tc.session)
# create job service and job
jd = saga.job.Description()
jd.executable = '/bin/sleep'
jd.arguments = ['10']
# add options from the test .cfg file if set
jd = sutc.add_tc_params_to_jd(tc=tc, jd=jd)
j = js.create_job(jd)
# run job - now it has an id, and js must know it
j.run()
all_jobs = js.list()
assert j.id in all_jobs, \
"%s not in %s" % (j.id, all_jobs)
except saga.NotImplemented as ni:
assert tc.notimpl_warn_only, "%s " % ni
if tc.notimpl_warn_only:
print "%s " % ni
except saga.SagaException as se:
assert False, "Unexpected exception: %s" % se
finally:
_silent_cancel(j)
_silent_close_js(js)
示例9: test_jobid_viability
def test_jobid_viability ():
""" Test if jobid represents job """
# The job id for the fork shell adaptor should return a pid which represents
# the actual job instance. We test by killing that pid and checking state.
try:
import os
tc = testing.get_test_config ()
js_url = saga.Url (tc.job_service_url)
if js_url.schema.lower() not in ['fork', 'local', 'ssh'] :
# test not supported for other backends
return
if js_url.host.lower() not in [None, '', 'localhost'] :
# test not supported for other backends
return
js = saga.job.Service ('fork:///')
j = js.run_job ("/bin/sleep 100")
jid = j.id
js_part, j_part = jid.split ('-', 1)
pid = j_part[1:-3]
# kill the children (i.e. the only child) of the pid, which is the
# actual job
os.system ('ps -ef | cut -c 8-21 | grep " %s " | cut -c 1-8 | grep -v " %s " | xargs -r kill' % (pid, pid))
assert (j.state == saga.job.FAILED), 'job.state: %s' % j.state
except saga.SagaException as se:
assert False, "Unexpected exception: %s" % se
示例10: test_job_service_invalid_url
def test_job_service_invalid_url():
""" Test if a non-resolvable hostname results in a proper exception
"""
try:
tc = testing.get_test_config ()
invalid_url = deepcopy(saga.Url(tc.job_service_url))
invalid_url.host = "does.not.exist"
tmp_js = saga.job.Service(invalid_url, tc.session)
_silent_close_js(tmp_js)
assert False, "Expected XYZ exception but got none."
except saga.BadParameter :
assert True
# we don't check DNS anymore, as that can take *ages* -- so we now also
# see Timeout and NoSuccess exceptions...
except saga.Timeout :
assert True
except saga.NoSuccess :
assert True
# other exceptions sould never occur
except saga.SagaException as ex:
assert False, "Expected BadParameter, Timeout or NoSuccess exception, but got %s (%s)" % (type(ex), ex)
示例11: test_get_job
def test_get_job():
""" Test to submit a job, and retrieve it by id """
j = None
js = None
try:
tc = testing.get_test_config ()
js = saga.job.Service(tc.job_service_url, tc.session)
# create job service and job
jd = saga.job.Description()
jd.executable = '/bin/sleep'
jd.arguments = ['10']
# add options from the test .cfg file if set
jd = sutc.add_tc_params_to_jd(tc=tc, jd=jd)
j = js.create_job(jd)
# run job - now it has an id, and js must be able to retrieve it by id
j.run()
j_clone = js.get_job(j.id)
assert j.id in j_clone.id
except saga.NotImplemented as ni:
assert tc.notimpl_warn_only, "%s " % ni
if tc.notimpl_warn_only:
print "%s " % ni
except saga.SagaException as se:
assert False, "Unexpected exception: %s" % se
finally:
_silent_cancel(j)
_silent_close_js(js)
示例12: tearDown
def tearDown(self):
"""Teardown called once per class instance"""
try:
# do the cleanup
tc = testing.get_test_config()
d = saga.filesystem.Directory(tc.filesystem_url)
d.remove(self.uniquefilename1)
d.remove(self.uniquefilename2)
except saga.SagaException as ex:
pass
示例13: helper_multiple_services
def helper_multiple_services(i):
tc = testing.get_test_config ()
js = saga.job.Service(tc.job_service_url, tc.session)
jd = saga.job.Description()
jd.executable = '/bin/sleep'
jd.arguments = ['10']
jd = sutc.add_tc_params_to_jd(tc=tc, jd=jd)
j = js.create_job(jd)
j.run()
assert (j.state in [saga.job.RUNNING, saga.job.PENDING]), "job submission failed"
_silent_cancel(j)
_silent_close_js(js)
示例14: test_nonexisting_file_create_open
def test_nonexisting_file_create_open(self):
""" Testing if opening a non-existing file with the 'create' flag set works.
"""
try:
pass
tc = testing.get_test_config()
nonex_file = deepcopy(saga.Url(tc.filesystem_url))
nonex_file.path += "/%s" % self.uniquefilename1
f = saga.filesystem.File(nonex_file, saga.filesystem.CREATE)
assert f.size == 0 # this should fail if the file doesn't exist!
except saga.SagaException as ex:
assert False, "Unexpected exception: %s" % ex
示例15: test_directory_get_session
def test_directory_get_session(self):
""" Testing if the correct session is being used
"""
try:
tc = testing.get_test_config()
session = tc.session or saga.Session()
d = saga.filesystem.Directory(tc.filesystem_url, session=session)
assert d.get_session() == session, 'Failed setting the session'
except saga.SagaException as ex:
assert False, "Unexpected exception: %s" % ex