def test_check_service_replication_for_smartstack_with_different_namespace(
    instance_config, ):
    instance_config.get_instances.return_value = 100
    all_pods = []
    with mock.patch(
            "paasta_tools.check_kubernetes_services_replication.get_proxy_port_for_instance",
            autospec=True,
            return_value=666,
    ), mock.patch(
            "paasta_tools.monitoring_tools.check_replication_for_instance",
            autospec=True,
    ) as mock_check_replication_for_service, mock.patch(
            "paasta_tools.check_kubernetes_services_replication.check_healthy_kubernetes_tasks_for_service_instance",
            autospec=True,
    ) as mock_check_healthy_kubernetes_tasks:
        instance_config.get_registrations.return_value = [
            "some-random-other-namespace"
        ]
        check_kubernetes_services_replication.check_kubernetes_pod_replication(
            instance_config=instance_config,
            all_tasks_or_pods=all_pods,
            replication_checker=None,
            dry_run=True,
        )
        assert not mock_check_replication_for_service.called
        mock_check_healthy_kubernetes_tasks.assert_called_once_with(
            instance_config=instance_config,
            expected_count=100,
            all_pods=[],
            dry_run=True,
        )
Example #2
0
def test_check_service_replication_for_non_smartstack(instance_config):
    instance_config.get_instances.return_value = 100

    with mock.patch(
            "paasta_tools.check_kubernetes_services_replication.get_proxy_port_for_instance",
            autospec=True,
            return_value=None,
    ), mock.patch(
            "paasta_tools.check_kubernetes_services_replication.check_healthy_kubernetes_tasks_for_service_instance",
            autospec=True,
    ) as mock_check_healthy_kubernetes_tasks:
        check_kubernetes_services_replication.check_kubernetes_pod_replication(
            instance_config=instance_config,
            all_tasks_or_pods=[],
            smartstack_replication_checker=None,
        )
        mock_check_healthy_kubernetes_tasks.assert_called_once_with(
            instance_config=instance_config, expected_count=100, all_pods=[])
Example #3
0
def test_check_service_replication_for_normal_smartstack(instance_config):
    instance_config.get_instances.return_value = 100
    all_pods = []
    with mock.patch(
            "paasta_tools.check_kubernetes_services_replication.get_proxy_port_for_instance",
            autospec=True,
            return_value=666,
    ), mock.patch(
            "paasta_tools.monitoring_tools.check_smartstack_replication_for_instance",
            autospec=True,
    ) as mock_check_smartstack_replication_for_service:
        check_kubernetes_services_replication.check_kubernetes_pod_replication(
            instance_config=instance_config,
            all_pods=all_pods,
            smartstack_replication_checker=None,
        )
        mock_check_smartstack_replication_for_service.assert_called_once_with(
            instance_config=instance_config,
            expected_count=100,
            smartstack_replication_checker=None,
        )