# this test should carry on to the end (leaving task #5 ignored) # both worker should complete the run, ignoring task #5 after a few retries from diane_test_applications import crash as application def run(input,config): input.data.commands = [None]*10 input.data.commands[5] = "fail()" input.scheduler.policy.STOP_IF_FAILED_TASKS = False input.scheduler.policy.FAILED_TASK_MAX_ASSIGN = 4 # validation function (accepts application manager) def validate(mgr): assert mgr.N == 10 assert mgr.done_counter == 10 assert mgr.completed_counter == 9 assert mgr.ignored_counter == 1 from diane.test.utils import make_timeout_test, run_test test = make_timeout_test(15,2,validate) if __name__ == '__main__': run_test(test)
from diane.test.utils import make_timeout_test, run_test # FIXME: the exact behabiour of this test case depends if in-process or out-of-process worker proxy is used # FIXME: for the moment LOST policies are not implemented by SimpleTaskScheduler from diane_test_applications import crash as application def run(input, config): input.data.commands = ["time.sleep(1)"] * 10 input.data.commands[5] = "abort()" input.scheduler.policy.STOP_IF_LOST_TASKS = False input.scheduler.policy.LOST_TASK_MAX_ASSIGN = 1 config.RunMaster.LOST_WORKER_TIMEOUT = 2 config.WorkerAgent.HEARTBEAT_DELAY = 0.5 # validation function (accepts application manager) def validate(mgr): assert mgr.N == 10 assert mgr.done_counter == 10 assert mgr.completed_counter == 9 assert mgr.ignored_counter == 1 test = make_timeout_test(30, 2, validate) if __name__ == "__main__": run_test(test)
def run(input,config): input.data.commands = ['time.sleep(0.3)']*10 input.data.commands[2] = 'nameError()' input.scheduler.policy.STOP_IF_FAILED_TASKS = False input.scheduler.policy.FAILED_TASK_MAX_ASSIGN = 1 ################################################################## # The code below is specific to the testing framework. # ---------------------------------------------------------------- # validation function (takes application manager as argument) def validate(mgr): assert mgr.N == 10 assert mgr.done_counter == mgr.N assert mgr.completed_counter == mgr.N-1 assert mgr.ignored_counter == 1 # ---------------------------------------------------------------- # connection to the testing framework from diane.test.utils import make_timeout_test, run_test # do the diane run and start 1 worker # timeout for the run to finish: 30 seconds # use the above validation function after the run has been finished test = make_timeout_test(30,1,validate,false_positives=['NameError']) # a boilerplate code to make this file executable. if __name__ == '__main__': run_test(test)
# ---------------------------------------------------------------- # run parameters. typically this content of a (separate) run file from diane_test_applications import crash as application def run(input,config): input.data.commands = ['time.sleep(0.5)']*500 config.RunMaster.LOST_WORKER_TIMEOUT = 5 config.WorkerAgent.HEARTBEAT_DELAY = 2 # ---------------------------------------------------------------- # validation function (takes application manager as argument) def validate(mgr): assert mgr.N == 500 assert mgr.done_counter == mgr.N assert mgr.completed_counter == mgr.N assert mgr.ignored_counter == 0 # ---------------------------------------------------------------- # connection to the testing framework from diane.test.utils import make_timeout_test, run_test # do the diane run and start 1 worker # timeout for the run to finish: 10 seconds # use the above validation function after the run has been finished test = make_timeout_test(100,50,validate) # a boilerplate code to make this file executable. if __name__ == '__main__': run_test(test)
from diane_test_applications import crash_finalize as application def run(input,config): config.WorkerAgent.HEARTBEAT_DELAY = 100 input.data.commands = ['time.sleep(0.3)']*10 ################################################################## # The code below is specific to the testing framework. # ---------------------------------------------------------------- # validation function (takes application manager as argument) def validate(mgr): assert mgr.N == 10 assert mgr.done_counter == mgr.N assert mgr.completed_counter == mgr.N assert mgr.ignored_counter == 0 # ---------------------------------------------------------------- # connection to the testing framework from diane.test.utils import make_timeout_test, run_test # do the diane run and start 1 worker # timeout for the run to finish: 30 seconds # use the above validation function after the run has been finished test = make_timeout_test(50,1,validate) # a boilerplate code to make this file executable. if __name__ == '__main__': run_test(test)
# this is a classic test example # this test should complete all tasks normally ################################################################## # run parameters. typically this content of a (separate) run file from diane_test_applications import test_config as application def run(input,config): input.data.config_dict = { 'WorkerAgent' : {'HEARTBEAT_TIMEOUT' : 31415} } config.WorkerAgent.HEARTBEAT_TIMEOUT = 31415 input.data.N = 3 ################################################################## # The code below is specific to the testing framework. # ---------------------------------------------------------------- # connection to the testing framework from diane.test.utils import make_timeout_test, run_test # do the diane run and start 1 worker # timeout for the run to finish: 30 seconds # no validation test = make_timeout_test(30,1,None) # a boilerplate code to make this file executable. if __name__ == '__main__': run_test(test)
f.close() diane.util.chmod_executable(fn) # all tasks will share the default parameters (unless set otherwise in individual task) d.input_files = [fn] d.output_files = ['message.out'] d.executable = os.path.basename(fn) # here are tasks differing by arguments to the executable for i in range(20): t = input.data.newTask() t.args = [str(i)] ################################################################## # The code below is specific to the testing framework. # ---------------------------------------------------------------- # connection to the testing framework from diane.test.utils import make_timeout_test, run_test # do the diane run and start 1 worker # timeout for the run to finish: 30 seconds # use the above validation function after the run has been finished test = make_timeout_test(30,3) # a boilerplate code to make this file executable. if __name__ == '__main__': run_test(test)