def test_cleanup(): store, space = jug.jug.init('jug/tests/jugfiles/tasklets.py', 'dict_store') simple_execute() h = jug.task.alltasks[-1].hash() l = store.getlock(h) del jug.task.alltasks[-1] assert store.can_load(h) assert not l.is_locked() l.get() assert store.can_load(h) assert l.is_locked() opts = Options(default_options) opts.cleanup_locks_only = True jug.jug.cleanup(store, opts) assert store.can_load(h) assert not l.is_locked() opts.cleanup_locks_only = False jug.jug.cleanup(store, opts) assert not store.can_load(h) assert not l.is_locked()
def test_complex(): store, space = jug.jug.init('jug/tests/jugfiles/tasklets.py', 'dict_store') simple_execute() store, space = jug.jug.init('jug/tests/jugfiles/tasklets.py', store) opts = Options(default_options) opts.invalid_name = space['t'].name h = space['t'].hash() assert store.can_load(h) jug.jug.invalidate(store, opts) assert not store.can_load(h)
def test_complex(): jugfile = os.path.join(_jugdir, 'tasklets.py') store, space = jug.jug.init(jugfile, 'dict_store') simple_execute() store, space = jug.jug.init(jugfile, store) opts = Options(default_options) opts.invalid_name = space['t'].name h = space['t'].hash() assert store.can_load(h) jug.subcommands.invalidate.invalidate(store, opts) assert not store.can_load(h)
def test_cleanup(): store, space = jug.jug.init('jug/tests/jugfiles/tasklets.py', 'dict_store') h = space['t'].hash() simple_execute() opts = Options(default_options) opts.cleanup_locks_only = True assert store.can_load(h) jug.jug.cleanup(store, opts) assert store.can_load(h) opts.cleanup_locks_only = False jug.jug.cleanup(store, opts) assert not store.can_load(h)
def test_cleanup(): jugfile = os.path.join(_jugdir, 'tasklets.py') store, space = jug.jug.init(jugfile, 'dict_store') h = space['t'].hash() simple_execute() opts = Options(default_options) opts.cleanup_locks_only = True assert store.can_load(h) jug.subcommands.cleanup.cleanup(store, opts) assert store.can_load(h) opts.cleanup_locks_only = False jug.subcommands.cleanup.cleanup(store, opts) assert not store.can_load(h)
def test_jug_invalidate(): def setAi(i): A[i] = True N = 1024 A = [False for i in range(N)] setall = [Task(setAi, i) for i in range(N)] store = dict_store() jug.task.Task.store = store for t in setall: t.run() opts = Options(default_options) opts.invalid_name = setall[0].name jug.jug.invalidate(store, opts) assert not list(store.store.keys()), list(store.store.keys()) jug.task.Task.store = dict_store()
def test_jug_invalidate(): def setAi(i): A[i] = True N = 1024 A = [False for i in range(N)] setall = [Task(setAi, i) for i in range(N)] store = dict_store() jug.task.Task.store = store for t in setall: t.run() opts = Options(default_options) opts.invalid_name = setall[0].name jug.subcommands.invalidate.invalidate(store, opts) assert not list(store.store.keys()), list(store.store.keys()) jug.task.Task.store = dict_store()
def test_cleanup_failed_only(): jugfile = os.path.join(_jugdir, 'tasklets.py') store, space = jug.jug.init(jugfile, 'dict_store') h = space['t'].hash() # With locked tasks we need to bypass execute waiting mechanisms from jug.task import alltasks from jug.jug import execution_loop opts = Options(default_options) opts.execute_nr_wait_cycles = 1 opts.execute_wait_cycle_time = 0 opts.execute_keep_failed = True execution_loop(alltasks, opts) # Fail one task manually lock = store.getlock(h) assert lock.get() assert lock.fail() assert lock.is_failed() # Keep locks should not remove failed tasks opts = Options(default_options) opts.cleanup_keep_locks = True jug.subcommands.cleanup.cleanup(store, opts) assert lock.is_locked() assert lock.is_failed() # Failed only should remove failed tasks opts = Options(default_options) opts.cleanup_failed_only = True jug.subcommands.cleanup.cleanup(store, opts) assert not lock.is_locked() assert not lock.is_failed()