Example #1
0
def test_graph_ok_multi_deps():
    ok = [('cleanup', ['update_shared_repos']),
          ('clobber', ['checkout_tools']), ('check_ami', []),
          ('check_slavealloc', []),
          ('killprocs', ['update_shared_repos']),
          ('checkout_tools', ['check_ami', 'check_slavealloc']),
          ('purge_builds', ['clobber']),
          ('update_shared_repos', ['purge_builds']),
          ('buildbot', ['cleanup', 'killprocs']),
          ('done', ['buildbot'])]

    graph = TaskGraph(map(TaskConfig.fromtuple, ok))
    task_order = graph.sequential_ordering()

    #  We shouldn't test against a literal expected list here as there are
    #  a couple of parallelisable tasks.
    assert task_order.index('cleanup') > task_order.index('update_shared_repos')
    assert task_order[-1] == 'done'
    assert task_order.index('checkout_tools') > task_order.index('check_ami')
    assert task_order.index('checkout_tools') > task_order.index('check_slavealloc')
    assert task_order.index('buildbot') > task_order.index('cleanup')
    assert task_order.index('buildbot') > task_order.index('killprocs')
Example #2
0
def test_graph_ok_multi_deps():
    ok = [('cleanup', ['update_shared_repos']),
          ('clobber', ['checkout_tools']), ('check_ami', []),
          ('check_slavealloc', []),
          ('killprocs', ['update_shared_repos']),
          ('checkout_tools', ['check_ami', 'check_slavealloc']),
          ('purge_builds', ['clobber']),
          ('update_shared_repos', ['purge_builds']),
          ('buildbot', ['cleanup', 'killprocs']),
          ('done', ['buildbot'])]

    graph = TaskGraph(map(TaskConfig.fromtuple, ok))
    task_order = graph.sequential_ordering()

    #  We shouldn't test against a literal expected list here as there are
    #  a couple of parallelisable tasks.
    assert task_order.index('cleanup') > task_order.index('update_shared_repos')
    assert task_order[-1] == 'done'
    assert task_order.index('checkout_tools') > task_order.index('check_ami')
    assert task_order.index('checkout_tools') > task_order.index('check_slavealloc')
    assert task_order.index('buildbot') > task_order.index('cleanup')
    assert task_order.index('buildbot') > task_order.index('killprocs')
Example #3
0
def test_graph_cycle():
    # extra dependency on orange causes a cycle
    cycle = [('apples', []), ('final', ['bees']), ('bees', ['birds']),
             ('oranges', ['apples', 'bees']), ('birds', ['oranges'])]
    graph = TaskGraph(map(TaskConfig.fromtuple, cycle))
    graph.sequential_ordering()
Example #4
0
def test_graph_ok_single_deps():
    ok = [('apples', []), ('final', ['bees']), ('bees', ['birds']),
          ('oranges', ['apples']), ('birds', ['oranges'])]
    graph = TaskGraph(map(TaskConfig.fromtuple, ok))
    task_order = graph.sequential_ordering()
    assert task_order == ['apples', 'oranges', 'birds', 'bees', 'final']
Example #5
0
def test_graph_cycle():
    # extra dependency on orange causes a cycle
    cycle = [('apples', []), ('final', ['bees']), ('bees', ['birds']),
             ('oranges', ['apples', 'bees']), ('birds', ['oranges'])]
    graph = TaskGraph(map(TaskConfig.fromtuple, cycle))
    graph.sequential_ordering()
Example #6
0
def test_graph_missing():
    missing_birds = [('apples', []), ('final', ['bees']), ('bees', ['birds']),
                     ('oranges', ['apples'])]
    TaskGraph(map(TaskConfig.fromtuple, missing_birds))
Example #7
0
def test_graph_ok_single_deps():
    ok = [('apples', []), ('final', ['bees']), ('bees', ['birds']),
          ('oranges', ['apples']), ('birds', ['oranges'])]
    graph = TaskGraph(map(TaskConfig.fromtuple, ok))
    task_order = graph.sequential_ordering()
    assert task_order == ['apples', 'oranges', 'birds', 'bees', 'final']
Example #8
0
def test_graph_ok_no_deps():
    ok = [('a', []), ('z', []), ('y', []), ('0', []), ('9', [])]
    graph = TaskGraph(map(TaskConfig.fromtuple, ok))
    task_order = graph.sequential_ordering()
    assert task_order == ['0', '9', 'a', 'y', 'z']