Ejemplo n.º 1
0
def test_mark_for_deployment_success(
    mock_log,
    mock_run,
):
    mock_run.return_value = (0, 'Interminate!')
    assert mark_for_deployment(fake_args.git_url, fake_args.cluster,
                               fake_args.instance, fake_args.service,
                               fake_args.commit) == 0
Ejemplo n.º 2
0
def test_mark_for_deployment_run_fail(
    mock_log,
    mock_run,
):
    mock_run.return_value = (1, 'Exterminate!')
    actual = mark_for_deployment(fake_args.git_url, fake_args.cluster,
                                 fake_args.instance, fake_args.service,
                                 fake_args.commit)
    assert actual == 1
def test_mark_for_deployment_happy(mock_create_remote_refs):
    actual = mark_for_deployment.mark_for_deployment(
        git_url="fake_git_url",
        cluster="fake_cluster",
        instance="fake_instance",
        service="fake_service",
        commit="fake_commit",
    )
    assert actual == 0
    mock_create_remote_refs.assert_called_once_with(git_url="fake_git_url", ref_mutator=ANY, force=True)
def test_mark_for_deployment_sad(mock_create_remote_refs):
    mock_create_remote_refs.side_effect = Exception("something bad")
    actual = mark_for_deployment.mark_for_deployment(
        git_url="fake_git_url",
        cluster="fake_cluster",
        instance="fake_instance",
        service="fake_service",
        commit="fake_commit",
    )
    assert actual == 1
    mock_create_remote_refs.assert_called_once_with(git_url="fake_git_url", ref_mutator=ANY, force=True)
def test_mark_for_deployment_success(
    mock_log,
    mock_run,
):
    mock_run.return_value = (0, 'Interminate!')
    assert mark_for_deployment(
        fake_args.git_url,
        fake_args.cluster,
        fake_args.instance,
        fake_args.service,
        fake_args.commit
    ) == 0
def test_mark_for_deployment_run_fail(
    mock_log,
    mock_run,
):
    mock_run.return_value = (1, 'Exterminate!')
    actual = mark_for_deployment(
        fake_args.git_url,
        fake_args.cluster,
        fake_args.instance,
        fake_args.service,
        fake_args.commit
    )
    assert actual == 1
Ejemplo n.º 7
0
def test_mark_for_deployment_happy(mock_create_remote_refs):
    actual = mark_for_deployment.mark_for_deployment(
        git_url='fake_git_url',
        cluster='fake_cluster',
        instance='fake_instance',
        service='fake_service',
        commit='fake_commit',
    )
    assert actual == 0
    mock_create_remote_refs.assert_called_once_with(
        git_url='fake_git_url',
        ref_mutator=ANY,
        force=True,
    )
Ejemplo n.º 8
0
def test_mark_for_deployment_sad(mock_create_remote_refs):
    mock_create_remote_refs.side_effect = Exception('something bad')
    actual = mark_for_deployment.mark_for_deployment(
        git_url='fake_git_url',
        cluster='fake_cluster',
        instance='fake_instance',
        service='fake_service',
        commit='fake_commit',
    )
    assert actual == 1
    mock_create_remote_refs.assert_called_once_with(
        git_url='fake_git_url',
        ref_mutator=ANY,
        force=True,
    )
Ejemplo n.º 9
0
def paasta_rollback(args):
    """Call mark_for_deployment with rollback parameters
    :param args: contains all the arguments passed onto the script: service,
    cluster, instance and sha. These arguments will be verified and passed onto
    mark_for_deployment.
    """
    service = figure_out_service_name(args)
    cluster = args.cluster
    git_url = get_git_url(service)
    commit = args.commit
    given_instances = args.instances.split(",")

    if cluster in list_clusters(service):
        service_instances = list_all_instances_for_service(service)
        instances, invalid = validate_given_instances(service_instances, given_instances)

        if len(invalid) > 0:
            print PaastaColors.yellow("These instances are not valid and will be skipped: %s.\n" % (",").join(invalid))

        if len(instances) is 0:
            print PaastaColors.red("ERROR: No valid instances specified for %s.\n" % (service))
            returncode = 1

        for instance in instances:
            returncode = mark_for_deployment(
                git_url=git_url,
                cluster=cluster,
                instance=instance,
                service=service,
                commit=commit,
            )
    else:
        print PaastaColors.red("ERROR: The service %s is not deployed into cluster %s.\n" % (service, cluster))
        returncode = 1

    sys.exit(returncode)