Exemple #1
0
def test_check_bevaviour_if_there_are_unknown_pods(
    pending_pods_in_each_check_call: Tuple[PodSequence, ...],
    expected_result_in_each_check_call: Tuple[Result, ...],
    time_time,
    get_value_store,
) -> None:
    """
    We simulate multiple calls to check function at different points in time.
    expected_result_in_each_check_call corresponds to the Results returned at different points in
    time, which are relevant to the behaviour of unknown pods, i.e., check_kube_pod_resources will
    return other Results/Metrics, but will only return one Result, which is related to unknown.
    """
    for pending_pods, expected_result in zip(
        pending_pods_in_each_check_call,
        expected_result_in_each_check_call,
        # strict=True, would be nice
    ):
        assert (
            tuple(
                check_kube_pod_resources(
                    Params(pending="no_levels", free="no_levels"),
                    PodResources(unknown=pending_pods),
                    None,
                )
            )[8]
            == expected_result
        )
Exemple #2
0
def test_check_phase_duration_with_different_pods(
    pending_pods_in_each_check_call: Tuple[PodSequence, ...],
    expected_result_in_each_check_call: Tuple[Result, ...],
    time_time,
    get_value_store,
) -> None:
    """
    We simulate multiple calls to check function at different points in time.
    expected_result_in_each_check_call corresponds to the Results returned at different points in
    time, which are relevant to the behaviour of pending pods, i.e., check_kube_pod_resources will
    return other Results/Metrics, but will only return one Result, which is related to pending.

    Here we focus on different sequences of pending pods.
    """
    params = Params(pending=("levels", (60, 120)),
                    free_node="no_levels",
                    free_cluster="no_levels")
    for pending_pods, expected_result in zip(
            pending_pods_in_each_check_call,
            expected_result_in_each_check_call,
            # strict=True, would be nice
    ):
        assert (tuple(
            check_kube_pod_resources(params,
                                     PodResources(pending=pending_pods),
                                     None))[2] == expected_result)
Exemple #3
0
def test_check_kube_pod_resources_with_capacity_overall_look(
    pending_pods_in_each_check_call: Tuple[PodSequence, ...],
    params_in_each_check_call: Tuple[Params, ...],
    expected_result,
    time_time,
    get_value_store,
) -> None:
    for pod_names, params in zip(pending_pods_in_each_check_call, params_in_each_check_call):
        result = tuple(
            check_kube_pod_resources(
                params=params,
                section_kube_pod_resources=PodResources(pending=pod_names),
                section_kube_allocatable_pods=AllocatablePods(allocatable=110, capacity=110),
            )
        )
    assert result == expected_result
Exemple #4
0
def test_check_phase_duration_with_changing_params(
    params_in_each_check_call: Tuple[Params, ...],
    expected_result_in_each_check_call: Tuple[Result, ...],
    time_time,
    get_value_store,
) -> None:
    """
    We simulate multiple calls to check function at different points in time.
    expected_result_in_each_check_call corresponds to the Results returned at different points in
    time, which are relevant to the behaviour of pending pods, i.e., check_kube_pod_resources will
    return other Results/Metrics, but will only return one Result, which is related to pending.

    Here we focus on activating/deactivating rules.
    """
    for params, expected_result in zip(
            params_in_each_check_call,
            expected_result_in_each_check_call,
            # strict=True, would be nice
    ):
        assert (tuple(
            check_kube_pod_resources(params, PodResources(pending=["pod"]),
                                     None))[2] == expected_result)