Ejemplo n.º 1
0
def test_threshold_decision_policy():
    decision_policy_args = {
        'threshold': 0.1,
        'current_instances': 10,
    }
    with mock.patch(
        'paasta_tools.autoscaling.autoscaling_service_lib.datetime', autospec=True,
    ), mock.patch(
        'paasta_tools.utils.load_system_paasta_config', autospec=True,
        return_value=mock.Mock(get_zk_hosts=mock.Mock()),
    ):
        assert autoscaling_service_lib.threshold_decision_policy(error=0, **decision_policy_args) == 0
        assert autoscaling_service_lib.threshold_decision_policy(error=0.5, **decision_policy_args) == 1
        assert autoscaling_service_lib.threshold_decision_policy(error=-0.5, **decision_policy_args) == -1
Ejemplo n.º 2
0
def test_threshold_decision_policy():
    decision_policy_args = {
        'threshold': 0.1,
        'current_instances': 10,
    }
    with contextlib.nested(
        mock.patch('paasta_tools.autoscaling.autoscaling_service_lib.datetime', autospec=True),
        mock.patch('paasta_tools.utils.load_system_paasta_config', autospec=True,
                   return_value=mock.Mock(get_zk_hosts=mock.Mock())),
    ) as (
        mock_datetime,
        _,
    ):
        assert autoscaling_service_lib.threshold_decision_policy(error=0, **decision_policy_args) == 0
        assert autoscaling_service_lib.threshold_decision_policy(error=0.5, **decision_policy_args) == 1
        assert autoscaling_service_lib.threshold_decision_policy(error=-0.5, **decision_policy_args) == -1