def test_graph_to_plan_with_jobs_with_lock_pool(mocker, testing_graph):
    # stub out uploads, since it depends on config file stuff and we want to manipulate it
    # get_upload = mocker.patch.object(execute, "get_upload_tasks")
    # get_upload.return_value = []

    with open(os.path.join(test_config_dir, 'config.yml')) as f:
        config_vars = yaml.safe_load(f)
    plan_dict = execute.graph_to_plan_with_jobs(graph_data_dir,
                                                testing_graph,
                                                'abc123',
                                                test_config_dir,
                                                config_vars,
                                                use_lock_pool=True)
    # rsync-recipes, rsync-source, rsync-stats, one artifact resource, and
    # one pool resource per build
    assert len(plan_dict['resources']) == 7
    # pool_resource does not need to be the last resource but is in the current
    # implementation
    pool_resource = plan_dict['resources'][-1]
    assert pool_resource['name'] == 'linux_pool_lock'
    assert pool_resource['type'] == 'pool'
    assert 'uri' in pool_resource['source']
    assert 'branch' in pool_resource['source']
    assert 'private_key' in pool_resource['source']
    # a, b, c
    assert len(plan_dict['jobs']) == 3
    # the order of these is based off the current implementation, may change
    first_job_plan = plan_dict['jobs'][0]['plan']
    pool_task = first_job_plan[1]
    build_task = first_job_plan[2]
    assert pool_task['put'] == 'linux_pool_lock'
    assert pool_task['params']['acquire']
    assert 'ensure' in build_task
    assert build_task['ensure']['put'] == 'linux_pool_lock'
    assert build_task['ensure']['params']['release'] == 'linux_pool_lock'
Exemple #2
0
def test_graph_to_plan_with_jobs(mocker, testing_graph):
    # stub out uploads, since it depends on config file stuff and we want to manipulate it
    # get_upload = mocker.patch.object(execute, "get_upload_tasks")
    # get_upload.return_value = []

    with open(os.path.join(test_config_dir, 'config.yml')) as f:
        config_vars = yaml.load(f)
    plan_dict = execute.graph_to_plan_with_jobs(graph_data_dir, testing_graph,
                                                'abc123', test_config_dir,
                                                config_vars)
    # rsync-recipes, rsync-source, rsync-stats, and one artifact resource per build
    assert len(plan_dict['resources']) == 6
    # a, b, c
    assert len(plan_dict['jobs']) == 3