Ronny Pfannschmidt avatar Ronny Pfannschmidt committed a02c917

rename shedule to manage

Comments (0)

Files changed (8)

juggler/handlers/manage.py

+from logbook import Logger
+from ..model import Task, Project, states as s
+from .utils import watches_for, steps_from_template
+
+log = Logger('manage', level='info')
+
+
+@watches_for(Task, s.new)
+def new_task_generate_steps(db, task):
+    log.debug('get project {}', task.project)
+    project = db.get(task.project, schema=Project)
+    log.debug('got {}', project)
+    bulk = [task]
+    if project.computed_steps:
+        raise NotImplementedError
+        task.status = 'preparing'
+    else:
+        bulk += steps_from_template(project, task)
+        task.status = s.pending
+    log.debug('save_bulk, {}', bulk)
+    db.bulk_save(bulk)
+    log.info('generated steps for {task._id}', task=task)
+
+
+@watches_for(Task, s.claiming)
+def approve_claimed_task(db, task):
+    # this asumes only one claim manager is running ever
+    # we operate on a first come first serve basis
+    all_docs = db.all_current_docs_for(task)
+
+    for doc in all_docs:
+        if doc._rev != task._rev and doc.status != s.claiming:
+            # conflict already solved by one
+            # of the contenders proceeding
+            # delete that exact revision
+            db.delete_doc(task)
+            log.info('claiming {task._id} for {task.owner} failed', task=task)
+
+            break
+    else:
+        # no solution yet, accept the claim
+        task.status = s.claimed
+        db.save_doc(task)
+        log.info('claimed {task._id} for {task.owner}', task=task)

juggler/handlers/shedule.py

-from logbook import Logger
-from ..model import Task, Project, states as s
-from .utils import watches_for, steps_from_template
-
-log = Logger('shedule', level='info')
-
-
-@watches_for(Task, s.new)
-def new_task_generate_steps(db, task):
-    log.debug('get project {}', task.project)
-    project = db.get(task.project, schema=Project)
-    log.debug('got {}', project)
-    bulk = [task]
-    if project.computed_steps:
-        raise NotImplementedError
-        task.status = 'preparing'
-    else:
-        bulk += steps_from_template(project, task)
-        task.status = s.pending
-    log.debug('save_bulk, {}', bulk)
-    db.bulk_save(bulk)
-    log.info('generated steps for {task._id}', task=task)
-
-
-@watches_for(Task, s.claiming)
-def approve_claimed_task(db, task):
-    # this asumes only one claim manager is running ever
-    # we operate on a first come first serve basis
-    all_docs = db.all_current_docs_for(task)
-
-    for doc in all_docs:
-        if doc._rev != task._rev and doc.status != s.claiming:
-            # conflict already solved by one
-            # of the contenders proceeding
-            # delete that exact revision
-            db.delete_doc(task)
-            log.info('claiming {task._id} for {task.owner} failed', task=task)
-
-            break
-    else:
-        # no solution yet, accept the claim
-        task.status = s.claimed
-        db.save_doc(task)
-        log.info('claimed {task._id} for {task.owner}', task=task)

juggler/model/structure.py

     name = StringProperty()
     belongs_to = StringProperty()
     # one of new, stopped, started, disabled
-    #: one of one of cron, shedule, inbox or make
+    #: one of one of cron, manage, inbox or make
     intent = StringProperty()
 
 

juggler/simple_master.py

 from logbook import Logger
-from juggler.handlers import inbox, shedule, utils
+from juggler.handlers import inbox, manage, utils
 
 log = Logger('Master')  # , level='info')
 
     inbox.order_validate,
     inbox.valid_order_prepare,
     inbox.ready_order_generate_tasks,
-    shedule.new_task_generate_steps,
-    shedule.approve_claimed_task,
+    manage.new_task_generate_steps,
+    manage.approve_claimed_task,
 ]
 
 

testing/acceptance/test_scripted_end_to_end.py

 import pytest
 from juggler import async
 from juggler.service import Juggler
-from juggler.handlers import inbox, shedule, slave
+from juggler.handlers import inbox, manage, slave
 from juggler.model import Project, Order
 from juggler.process.subprocess import python_template
 from testing import with_quick_change_timeout
     inbox.order_validate(juggler)
     inbox.valid_order_prepare(juggler)
     inbox.ready_order_generate_tasks(juggler)
-    shedule.new_task_generate_steps(juggler)
+    manage.new_task_generate_steps(juggler)
 
     slave.claim_pending_task(juggler, owner=juggler)
 
-    shedule.approve_claimed_task(juggler)
+    manage.approve_claimed_task(juggler)
     slave.run_one_claimed_task(juggler,
                                owner=juggler.name,
                                run=juggler.run_task)

testing/handlers/test_manage.py

+import pytest
+from juggler import model
+from juggler.handlers import manage
+from testing import with_quick_change_timeout
+
+
+@with_quick_change_timeout
+def test_new_task_generate_steps_programmatic_unimplemented(db):
+    project = model.Project(computed_steps=True)
+    db._.get.return_value = project
+    task = model.Task(status='new', project='blabla')
+    db.save_doc(task)
+    pytest.raises(
+        NotImplementedError,
+        manage.new_task_generate_steps,
+        db)
+
+
+@with_quick_change_timeout
+def test_new_task_generate_from_template(db):
+    project = model.Project(steps=[])
+    db._.get.return_value = project
+    task = model.Task(status='new', project='blabla')
+    db.save_doc(task)
+    manage.new_task_generate_steps(db)
+    items = db._.bulk_save.call_args[0][0]
+    saved_task = items.pop(0)
+    db.refresh(task)
+    assert saved_task.status == task.status
+    assert task.status == 'pending'
+    #XXX: check items
+
+
+@with_quick_change_timeout
+def test_approve_claimed_task_simple(db):
+    task = model.Task(status='claiming', owner='test')
+    db.save_doc(task)
+    manage.approve_claimed_task(db)
+    db.refresh(task)
+    assert task.status == 'claimed'
+
+
+@with_quick_change_timeout
+@pytest.mark.xfail(run=False, reason='tricky')
+def test_approve_claimed_task_two_exist():
+    pass
+
+
+@with_quick_change_timeout
+@pytest.mark.xfail(run=False, reason='tricky')
+def test_approve_claimed_tasks_stat_conflict_solution():
+    pass

testing/handlers/test_shedule.py

-import pytest
-from juggler import model
-from juggler.handlers import shedule
-from testing import with_quick_change_timeout
-
-
-@with_quick_change_timeout
-def test_new_task_generate_steps_programmatic_unimplemented(db):
-    project = model.Project(computed_steps=True)
-    db._.get.return_value = project
-    task = model.Task(status='new', project='blabla')
-    db.save_doc(task)
-    pytest.raises(
-        NotImplementedError,
-        shedule.new_task_generate_steps,
-        db)
-
-
-@with_quick_change_timeout
-def test_new_task_generate_from_template(db):
-    project = model.Project(steps=[])
-    db._.get.return_value = project
-    task = model.Task(status='new', project='blabla')
-    db.save_doc(task)
-    shedule.new_task_generate_steps(db)
-    items = db._.bulk_save.call_args[0][0]
-    saved_task = items.pop(0)
-    db.refresh(task)
-    assert saved_task.status == task.status
-    assert task.status == 'pending'
-    #XXX: check items
-
-
-@with_quick_change_timeout
-def test_approve_claimed_task_simple(db):
-    task = model.Task(status='claiming', owner='test')
-    db.save_doc(task)
-    shedule.approve_claimed_task(db)
-    db.refresh(task)
-    assert task.status == 'claimed'
-
-
-@with_quick_change_timeout
-@pytest.mark.xfail(run=False, reason='tricky')
-def test_approve_claimed_task_two_exist():
-    pass
-
-
-@with_quick_change_timeout
-@pytest.mark.xfail(run=False, reason='tricky')
-def test_approve_claimed_tasks_stat_conflict_solution():
-    pass

tool/drive_slave.py

 
 from juggler import model
 from juggler.handlers.utils import get_database
-from juggler.handlers import shedule
+from juggler.handlers import manage
 from juggler import service
 
 path = py.path.local(__file__).dirpath().dirpath().join('composeapp').strpath
 j.save_doc(task)
 
 print 'approve'
-shedule.approve_claimed_task(j)
+manage.approve_claimed_task(j)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.