Esempio n. 1
0
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()
Esempio n. 2
0
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()
Esempio n. 3
0
def parse(string_table: StringTable) -> Optional[PodContainers]:
    """Parses `string_table` into a PodContainers isinstance
    >>> section_kube_pod_containers_v1 = '{"containers": {"busybox": {"container_id": null, "image_id": "", "name": "busybox", "image": "busybox", "ready": false, "state": {"type": "waiting", "reason": "PodInitializing", "detail": null}, "restart_count": 0}}}'
    >>> parse([[section_kube_pod_containers_v1]])
    PodContainers(containers={'busybox': ContainerStatus(container_id=None, image_id='', name='busybox', image='busybox', ready=False, state=ContainerWaitingState(type='waiting', reason='PodInitializing', detail=None), restart_count=0)})
    >>> section_kube_pod_init_containers_v1 = '{"containers": {"busybox-init": {"container_id": "docker://some-id", "image_id": "docker-pullable://busybox@sha256:some-id", "name": "busybox-init", "image": "busybox:latest", "ready": false, "state": {"type": "waiting", "reason": "CrashLoopBackOff", "detail": "back-off 5m0s restarting failed container=busybox-init pod=failing-initcontainer-64ff5bdcd-vhl59_pod-status(8c812676-6e30-45ae-8271-16a279c95168)"}, "restart_count": 144}}}'
    >>> parse([[section_kube_pod_init_containers_v1]])
    PodContainers(containers={'busybox-init': ContainerStatus(container_id='docker://some-id', image_id='docker-pullable://busybox@sha256:some-id', name='busybox-init', image='busybox:latest', ready=False, state=ContainerWaitingState(type='waiting', reason='CrashLoopBackOff', detail='back-off 5m0s restarting failed container=busybox-init pod=failing-initcontainer-64ff5bdcd-vhl59_pod-status(8c812676-6e30-45ae-8271-16a279c95168)'), restart_count=144)})
    """
    if not string_table:
        return None
    return PodContainers(**json.loads(string_table[0][0]))
def test_schemata_did_not_diverge() -> None:
    assert ClusterInfoA.schema() == ClusterInfoC.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 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 PodResourcesWithCapacityA.schema(
    ) == PodResourcesWithCapacityC.schema()
    assert ResourcesA.schema() == ResourcesC.schema()
    assert StartTimeA.schema() == StartTimeC.schema()
    assert PodInfoA.schema() == PodInfoC.schema()
Esempio n. 5
0
def parse(string_table: StringTable) -> Optional[PodContainers]:
    """Parses `string_table` into a PodContainers instance"""
    if not string_table:
        return None
    return PodContainers(**json.loads(string_table[0][0]))
Esempio n. 6
0
        image_id="some_other_id",
        name="some_name",
        image="some_image",
        ready=False,
        state=state,
        restart_count=0,
    )


@pytest.mark.parametrize(
    "section_kube_pod_containers, section_kube_pod_lifecycle, expected_result",
    [
        pytest.param(
            PodContainers(containers={
                "running":
                _mocked_container_info_from_state(
                    ContainerRunningState(type="running",
                                          start_time=1639135964)),
            }, ),
            PodLifeCycle(phase="running"),
            [Result(state=State.OK, summary="Running")],
            id="A single running container",
        ),
        pytest.param(
            PodContainers(
                containers={
                    "downloading-container":
                    _mocked_container_info_from_state(
                        ContainerWaitingState(type="waiting",
                                              reason="ContainerCreating",
                                              detail=None))
                }),
Esempio n. 7
0
def section(string_table):
    if not string_table:
        return None
    return PodContainers(**json.loads(string_table[0][0]))
Esempio n. 8
0
     dns_policy="ClusterFirst",
     host_ip="192.168.49.2",
     pod_ip="172.17.0.5",
     qos_class="besteffort",
     restart_policy="Never",
     uid="3336928e-b9e1-4774-a5c4-bf45b8f9f24e",
     controllers=[],
 ),
 PodContainers(
     containers={
         "busybox":
         ContainerStatus(
             container_id=None,
             image_id="",
             name="busybox",
             image="busybox",
             ready=False,
             state=ContainerWaitingState(type="waiting",
                                         reason="PodInitializing",
                                         detail=None),
             restart_count=0,
         )
     }),
 PodContainers(
     containers={
         "busybox-init":
         ContainerStatus(
             container_id="some-id",
             image_id="somde-id",
             name="busybox-init",
             image="busybox:latest",