Esempio n. 1
0
 def populate(engine):
     apps = []
     for n in range(n1):
         par = SimpleParallelTaskCollection(n2)
         par.jobname = 'par{nr}'.format(nr=n)
         engine.add(par)
         apps.append(par)
         for task in par.tasks:
             apps.append(task)
     return apps
def test_ParallelTaskCollection_progress():
    with temporary_core(max_cores=10) as core:
        par = SimpleParallelTaskCollection(5)
        par.attach(core)

        # run until terminated
        while par.execution.state != Run.State.TERMINATED:
            par.progress()
        for task in par.tasks:
            assert task.execution.state == Run.State.TERMINATED
Esempio n. 3
0
def test_engine_kill_ParallelTaskCollection():
    # Creates an engine with 2 cores.
    with temporary_engine(max_cores=2) as engine:
        par = SimpleParallelTaskCollection(3)
        engine.add(par)

        for _ in range(20):
            engine.progress()
            if par.execution.state == 'RUNNING':
                break

        # Because of our noop engine, as soon as the parallel is in
        # running we will have all jobs in SUBMITTED and the others in
        # NEW.
        assert (['SUBMITTED', 'SUBMITTED',
                 'NEW'] == [i.execution.state for i in par.tasks])

        # Killing a parallel should put all the applications in
        # TERMINATED state. However, we need two runs of
        # engine.progress() to update the status of all the jobs
        engine.kill(par)
        assert (['SUBMITTED', 'SUBMITTED',
                 'NEW'] == [i.execution.state for i in par.tasks])

        engine.progress()
        engine.progress()

        assert (['TERMINATED', 'TERMINATED',
                 'TERMINATED'] == [i.execution.state for i in par.tasks])
        assert par.execution.state == 'TERMINATED'
def test_ParallelTaskCollection_redo():
    with temporary_core(max_cores=10) as core:
        par = SimpleParallelTaskCollection(5)
        par.attach(core)

        # run until terminated
        while par.execution.state != Run.State.TERMINATED:
            par.progress()

        par.redo()
        assert par.execution.state == Run.State.NEW
        for task in par.tasks:
            assert task.execution.state == Run.State.NEW
Esempio n. 5
0
def test_engine_redo_ParallelTaskCollection():
    with temporary_engine() as engine:
        par = SimpleParallelTaskCollection(5)
        engine.add(par)

        # run until terminated
        while par.execution.state != Run.State.TERMINATED:
            engine.progress()

        engine.redo(par)
        assert par.execution.state == Run.State.NEW
        for task in par.tasks:
            assert task.execution.state == Run.State.NEW