Exemplo n.º 1
0
def test_get_default_interactive_config_reads_from_tty():
    with mock.patch(
            "paasta_tools.adhoc_tools.prompt_pick_one",
            autospec=True) as mock_prompt_pick_one, mock.patch(
                "paasta_tools.adhoc_tools.load_adhoc_job_config",
                autospec=True) as mock_load_adhoc_job_config, mock.patch(
                    "paasta_tools.adhoc_tools.load_v2_deployments_json",
                    autospec=True) as mock_load_deployments_json:
        mock_prompt_pick_one.return_value = "fake_deploygroup"
        mock_load_adhoc_job_config.side_effect = NoConfigurationForServiceError
        mock_load_deployments_json.return_value = DeploymentsJsonV2(
            service="fake-service",
            config_dict={
                "deployments": {
                    "fake_deploygroup": {
                        "docker_image": mock.sentinel.docker_image,
                        "git_sha": mock.sentinel.git_sha,
                    }
                },
                "controls": {},
            },
        )
        result = adhoc_tools.get_default_interactive_config(
            "fake_service",
            "fake_cluster",
            "/fake/soa/dir",
            load_deployments=True)
        assert result.get_deploy_group() == "fake_deploygroup"
        assert result.get_docker_image() == mock.sentinel.docker_image
Exemplo n.º 2
0
def test_get_default_interactive_config_reads_from_tty():
    with mock.patch(
        'paasta_tools.adhoc_tools.prompt_pick_one', autospec=True,
    ) as mock_prompt_pick_one, mock.patch(
        'paasta_tools.adhoc_tools.load_adhoc_job_config', autospec=True,
    ) as mock_load_adhoc_job_config, mock.patch(
        'paasta_tools.adhoc_tools.load_v2_deployments_json', autospec=True,
    ) as mock_load_deployments_json:
        mock_prompt_pick_one.return_value = 'fake_deploygroup'
        mock_load_adhoc_job_config.side_effect = NoConfigurationForServiceError
        mock_load_deployments_json.return_value = DeploymentsJsonV2(
            service='fake-service',
            config_dict={
                'deployments': {
                    'fake_deploygroup': {
                        'docker_image': mock.sentinel.docker_image,
                        'git_sha': mock.sentinel.git_sha,
                    },
                },
                'controls': {},
            },
        )
        result = adhoc_tools.get_default_interactive_config(
            'fake_service',
            'fake_cluster',
            '/fake/soa/dir',
            load_deployments=True,
        )
        assert result.get_deploy_group() == 'fake_deploygroup'
        assert result.get_docker_image() == mock.sentinel.docker_image
Exemplo n.º 3
0
def test_get_currently_deployed_sha(mock_load_v2_deployments_json,):
    mock_load_v2_deployments_json.return_value = DeploymentsJsonV2(
        service="fake-service",
        config_dict={
            "controls": {},
            "deployments": {"everything": {"git_sha": "abc", "docker_image": "foo"}},
        },
    )
    actual = deployment_utils.get_currently_deployed_sha(
        service="service", deploy_group="everything"
    )
    assert actual == "abc"
Exemplo n.º 4
0
def test_get_currently_deployed_sha(mock_load_v2_deployments_json, ):
    mock_load_v2_deployments_json.return_value = DeploymentsJsonV2({
        "controls": {},
        "deployments": {
            "everything": {
                "git_sha": "abc",
                "docker_image": "foo",
            },
        },
    })
    actual = deployment_utils.get_currently_deployed_sha(
        service='service', deploy_group='everything')
    assert actual == "abc"
Exemplo n.º 5
0
def deployment_json():
    return DeploymentsJsonV2(
        service="test-service",
        config_dict={
            "deployments": {
                "cluster.non_canary": {
                    "docker_image": "some_image",
                    "git_sha": "some_sha",
                },
                "cluster.canary": {
                    "docker_image": "some_image",
                    "git_sha": "some_sha"
                },
            },
            "controls": {
                "example_happyhour:%s.sample_batch" % TEST_CLUSTER_NAME: {
                    "desired_state": "start",
                    "force_bounce": None
                },
                "example_happyhour:%s.interactive" % TEST_CLUSTER_NAME: {
                    "desired_state": "start",
                    "force_bounce": None
                },
                f"{TEST_SERVICE_NAME}:{TEST_CLUSTER_NAME}.main": {
                    "desired_state": "start",
                    "force_bounce": None,
                },
                f"{TEST_SERVICE_NAME}:{TEST_CLUSTER_NAME}.canary": {
                    "desired_state": "start",
                    "force_bounce": None,
                },
                f"{TEST_SERVICE_NAME}:{TEST_CLUSTER_NAME}.example_chronos_job":
                {
                    "desired_state": "start",
                    "force_bounce": None,
                },
                f"{TEST_SERVICE_NAME}:{TEST_CLUSTER_NAME}.example_child_job": {
                    "desired_state": "start",
                    "force_bounce": None,
                },
                f"{TEST_SERVICE_NAME}:{TEST_CLUSTER_NAME}.sample_batch": {
                    "desired_state": "start",
                    "force_bounce": None,
                },
                f"{TEST_SERVICE_NAME}:{TEST_CLUSTER_NAME}.interactive": {
                    "desired_state": "start",
                    "force_bounce": None,
                },
            },
        },
    )
def deployment_json():
    return DeploymentsJsonV2(
        service='test-service',
        config_dict={
            'deployments': {
                'cluster.non_canary': {
                    'docker_image': 'some_image',
                    'git_sha': 'some_sha',
                },
                'cluster.canary': {
                    'docker_image': 'some_image',
                    'git_sha': 'some_sha',
                },
            },
            'controls': {
                'example_happyhour:%s.sample_batch' % TEST_CLUSTER_NAME: {
                    'desired_state': 'start',
                    'force_bounce': None,
                },
                'example_happyhour:%s.interactive' % TEST_CLUSTER_NAME: {
                    'desired_state': 'start',
                    'force_bounce': None,
                },
                f'{TEST_SERVICE_NAME}:{TEST_CLUSTER_NAME}.main': {
                    'desired_state': 'start',
                    'force_bounce': None,
                },
                f'{TEST_SERVICE_NAME}:{TEST_CLUSTER_NAME}.canary': {
                    'desired_state': 'start',
                    'force_bounce': None,
                },
                f'{TEST_SERVICE_NAME}:{TEST_CLUSTER_NAME}.example_chronos_job':
                {
                    'desired_state': 'start',
                    'force_bounce': None,
                },
                f'{TEST_SERVICE_NAME}:{TEST_CLUSTER_NAME}.example_child_job': {
                    'desired_state': 'start',
                    'force_bounce': None,
                },
                f'{TEST_SERVICE_NAME}:{TEST_CLUSTER_NAME}.sample_batch': {
                    'desired_state': 'start',
                    'force_bounce': None,
                },
                f'{TEST_SERVICE_NAME}:{TEST_CLUSTER_NAME}.interactive': {
                    'desired_state': 'start',
                    'force_bounce': None,
                },
            },
        },
    )
def deployment_json():
    return DeploymentsJsonV2({
        'deployments': {
            'cluster.non_canary': {
                'docker_image': 'some_image',
                'git_sha': 'some_sha',
            },
            'cluster.canary': {
                'docker_image': 'some_image',
                'git_sha': 'some_sha',
            },
        },
        'controls': {
            'example_happyhour:%s.sample_batch' % TEST_CLUSTER_NAME: {
                'desired_state': 'start',
                'force_bounce': None,
            },
            'example_happyhour:%s.interactive' % TEST_CLUSTER_NAME: {
                'desired_state': 'start',
                'force_bounce': None,
            },
            '%s:%s.main' % (TEST_SERVICE_NAME, TEST_CLUSTER_NAME): {
                'desired_state': 'start',
                'force_bounce': None,
            },
            '%s:%s.canary' % (TEST_SERVICE_NAME, TEST_CLUSTER_NAME): {
                'desired_state': 'start',
                'force_bounce': None,
            },
            '%s:%s.example_chronos_job' % (TEST_SERVICE_NAME, TEST_CLUSTER_NAME):
            {
                'desired_state': 'start',
                'force_bounce': None,
            },
            '%s:%s.example_child_job' % (TEST_SERVICE_NAME, TEST_CLUSTER_NAME):
            {
                'desired_state': 'start',
                'force_bounce': None,
            },
            '%s:%s.sample_batch' % (TEST_SERVICE_NAME, TEST_CLUSTER_NAME): {
                'desired_state': 'start',
                'force_bounce': None,
            },
            '%s:%s.interactive' % (TEST_SERVICE_NAME, TEST_CLUSTER_NAME): {
                'desired_state': 'start',
                'force_bounce': None,
            },
        },
    })