def test_are_local_tasks_in_danger_fails_safe_with_false( mock_load_system_paasta_config, ): """If something unexpected happens that we don't know how to interpret, we make sure that we fail with "False" so that processes move on and don't deadlock. In general the answer to "is it safe to drain" is "yes" if mesos can't be reached, etc""" mock_load_system_paasta_config.side_effect = Exception assert paasta_maintenance.are_local_tasks_in_danger() is False
def test_are_local_tasks_in_danger_fails_safe_with_false( mock_load_system_paasta_config, ): """If something unexpected happens that we don't know how to interpret, we make sure that we fail with "False" so that processes move on and don't deadlock. In general the answer to "is it safe to drain" is "yes" if mesos can't be reached, etc""" mock_load_system_paasta_config.side_effect = Exception assert paasta_maintenance.are_local_tasks_in_danger() is False
def test_are_local_tasks_in_danger_is_false_with_an_unhealthy_service( mock_is_healthy_in_haproxy, mock_get_backends, mock_marathon_services_running_here, mock_load_system_paasta_config, ): mock_is_healthy_in_haproxy.return_value = False mock_marathon_services_running_here.return_value = [("service", "instance", 42)] assert paasta_maintenance.are_local_tasks_in_danger() is False mock_is_healthy_in_haproxy.assert_called_once_with(42, mock.ANY)
def test_are_local_tasks_in_danger_is_true_with_an_healthy_service_in_danger( mock_synapse_replication_is_low, mock_is_healthy_in_haproxy, mock_get_backends, mock_marathon_services_running_here, mock_load_system_paasta_config, ): mock_is_healthy_in_haproxy.return_value = True mock_synapse_replication_is_low.return_value = True mock_marathon_services_running_here.return_value = [("service", "instance", 42)] assert paasta_maintenance.are_local_tasks_in_danger() is True mock_is_healthy_in_haproxy.assert_called_once_with(42, mock.ANY) assert mock_synapse_replication_is_low.call_count == 1
def test_are_local_tasks_in_danger_is_false_with_nothing_running( mock_marathon_services_running_here, mock_load_system_paasta_config, ): mock_marathon_services_running_here.return_value = [] assert paasta_maintenance.are_local_tasks_in_danger() is False