def test_schemata_did_not_diverge() -> None: assert ClusterInfoA.schema() == ClusterInfoC.schema() assert agent.CollectorProcessingLogs.schema( ) == check.CollectorProcessingLogs.schema() assert agent.CollectorComponentsMetadata.schema( ) == check.CollectorComponentsMetadata.schema() assert ContainerCountA.schema() == ContainerCountC.schema() assert ContainerRunningStateA.schema() == ContainerRunningStateC.schema() assert ContainerTerminatedStateA.schema( ) == ContainerTerminatedStateC.schema() assert ContainerWaitingStateA.schema() == ContainerWaitingStateC.schema() assert agent.DeploymentConditions.schema( ) == check.DeploymentConditions.schema() assert KubeletInfoA.schema() == KubeletInfoC.schema() assert NodeCountA.schema() == NodeCountC.schema() assert NodeInfoA.schema() == NodeInfoC.schema() assert PodConditionA.schema() == PodConditionC.schema() assert PodConditionsA.schema() == PodConditionsC.schema() assert PodContainersA.schema() == PodContainersC.schema() assert PodResourcesA.schema() == PodResourcesC.schema() assert PodLifeCycleA.schema() == PodLifeCycleC.schema() assert AllocatablePodsA.schema() == AllocatablePodsC.schema() assert ResourcesA.schema() == ResourcesC.schema() assert StartTimeA.schema() == StartTimeC.schema() assert PodInfoA.schema() == PodInfoC.schema() assert ReplicasA.schema() == ReplicasC.schema() assert agent.DeploymentStrategy.schema( ) == k8s_check.DeploymentStrategy.schema() assert agent.NodeConditions.schema() == check.NodeConditions.schema() assert agent.PerformanceUsage.schema( ) == k8s_check.PerformanceUsage.schema()
def test_schemata_did_not_diverge() -> None: assert ClusterInfoA.schema() == ClusterInfoC.schema() assert agent.CollectorLogs.schema() == check.CollectorLogs.schema() assert ContainerCountA.schema() == ContainerCountC.schema() assert ContainerInfoA.schema() == ContainerInfoC.schema() assert ContainerRunningStateA.schema() == ContainerRunningStateC.schema() assert ContainerTerminatedStateA.schema( ) == ContainerTerminatedStateC.schema() assert ContainerWaitingStateA.schema() == ContainerWaitingStateC.schema() assert agent.DeploymentConditions.schema( ) == check.DeploymentConditions.schema() assert KubeletInfoA.schema() == KubeletInfoC.schema() assert MemoryA.schema() == MemoryC.schema() assert NodeCountA.schema() == NodeCountC.schema() assert NodeInfoA.schema() == NodeInfoC.schema() assert PodConditionA.schema() == PodConditionC.schema() assert PodConditionsA.schema() == PodConditionsC.schema() assert PodContainersA.schema() == PodContainersC.schema() assert PodResourcesA.schema() == PodResourcesC.schema() assert PodLifeCycleA.schema() == PodLifeCycleC.schema() assert AllocatablePodsA.schema() == AllocatablePodsC.schema() assert ResourcesA.schema() == ResourcesC.schema() assert StartTimeA.schema() == StartTimeC.schema() assert PodInfoA.schema() == PodInfoC.schema() assert ReplicasA.schema() == ReplicasC.schema() assert DeploymentSpecA.schema() == DeploymentSpecC.schema()
def test_check_replicas_with_none_value(): check_result = list( check_kube_replicas( {}, Replicas( replicas=None, updated=0, available=0, ready=0, unavailable=0, ), None, )) assert len(check_result) == 0
def test_discover_kube_replicas() -> None: replicas = Replicas( replicas=3, updated=0, available=0, ready=3, unavailable=3, ) strategy = DeploymentStrategy(strategy=RollingUpdate( max_surge="25%", max_unavailable="25%", )) assert list(discover_kube_replicas(replicas, strategy)) == [Service()] assert list(discover_kube_replicas(replicas, None)) == [Service()] assert list(discover_kube_replicas(None, strategy)) == [] assert list(discover_kube_replicas(None, None)) == []
def test_parse_kube_replicas() -> None: assert parse_kube_replicas([[ json.dumps({ "replicas": 3, "updated": 0, "available": 0, "ready": 3, "unavailable": 0, }) ]]) == Replicas( replicas=3, updated=0, available=0, ready=3, unavailable=0, )
def test_check_kube_replicas() -> None: assert list( check_kube_replicas( {}, Replicas( replicas=3, updated=3, available=3, ready=3, unavailable=0, ), None, )) == [ Result(state=State.OK, summary="Ready: 3/3"), Result(state=State.OK, summary="Up-to-date: 3/3"), Metric("kube_desired_replicas", 3.0, boundaries=(0.0, 3.0)), Metric("kube_ready_replicas", 3.0, boundaries=(0.0, 3.0)), Metric("kube_updated_replicas", 3.0, boundaries=(0.0, 3.0)), ]
Result(state=State.OK, summary="Up-to-date: 3/3"), Metric("kube_desired_replicas", 3.0, boundaries=(0.0, 3.0)), Metric("kube_ready_replicas", 3.0, boundaries=(0.0, 3.0)), Metric("kube_updated_replicas", 3.0, boundaries=(0.0, 3.0)), ] @pytest.mark.parametrize( "params,replicas,spec,value_store,expected_check_result", [ pytest.param( {"update_duration": "no_levels"}, Replicas( replicas=3, updated=0, available=3, ready=3, unavailable=0, ), DeploymentSpec( strategy=RollingUpdate( max_surge="25%", max_unavailable="25%", ), ), {"update_started_timestamp": 100.0}, [ Result(state=State.OK, summary="Ready: 3/3"), Result(state=State.OK, summary="Up-to-date: 0/3"), Metric("kube_desired_replicas", 3.0, boundaries=(0.0, 3.0)), Metric("kube_ready_replicas", 3.0, boundaries=(0.0, 3.0)),