예제 #1
0
def test_failed_at_benchmark_container_but_sidecar_still_running():
    status = V1PodStatus(
        phase="Running",
        container_statuses=[
            V1ContainerStatus(
                image="benchmarkai/hello-world",
                name="benchmark",
                image_id="",
                ready=False,
                restart_count=0,
                state=V1ContainerState(
                    terminated=CONTAINER_STATE_TERMINATED_AND_FAILED),
            ),
            V1ContainerStatus(
                image="benchmarkai/metrics-pusher",
                name="sidecar",
                image_id="",
                ready=True,
                restart_count=0,
                state=V1ContainerState(running=V1ContainerStateRunning()),
            ),
        ],
    )

    pod = V1Pod(metadata=V1ObjectMeta(name="pod-name"), status=status)
    inferrer = SingleNodeStrategyKubernetesStatusInferrer(
        V1JobStatus(active=1), pods=[pod])
    # TODO: Not sure if this is the status we want
    assert inferrer.status() == BenchmarkJobStatus.RUNNING_AT_MAIN_CONTAINERS
예제 #2
0
def test_failed_at_sidecar_container_and_pod_terminated():
    status = V1PodStatus(
        phase="Failed",
        container_statuses=[
            V1ContainerStatus(
                image="benchmarkai/hello-world",
                name="benchmark",
                image_id="",
                ready=True,
                restart_count=0,
                state=V1ContainerState(
                    terminated=CONTAINER_STATE_TERMINATED_AND_SUCCEEDED),
            ),
            V1ContainerStatus(
                image="benchmarkai/metrics-pusher",
                name="sidecar",
                image_id="",
                ready=True,
                restart_count=0,
                state=V1ContainerState(
                    terminated=CONTAINER_STATE_TERMINATED_AND_FAILED),
            ),
        ],
    )

    pod = V1Pod(metadata=V1ObjectMeta(name="pod-name"), status=status)
    inferrer = SingleNodeStrategyKubernetesStatusInferrer(
        V1JobStatus(active=1), pods=[pod])
    assert inferrer.status() == BenchmarkJobStatus.FAILED_AT_SIDECAR_CONTAINER
예제 #3
0
def test_waiting_for_benchmark_container():
    status = V1PodStatus(
        phase="Pending",
        container_statuses=[
            V1ContainerStatus(
                image="benchmarkai/hello-world",
                name="benchmark",
                image_id="",
                ready=False,
                restart_count=0,
                state=V1ContainerState(waiting=CONTAINER_STATE_WAITING),
            ),
            V1ContainerStatus(
                image="benchmarkai/metrics-pusher",
                name="sidecar",
                image_id="",
                ready=True,
                restart_count=0,
                state=V1ContainerState(running=V1ContainerStateRunning()),
            ),
        ],
    )

    pod = V1Pod(metadata=V1ObjectMeta(name="pod-name"), status=status)
    inferrer = SingleNodeStrategyKubernetesStatusInferrer(
        V1JobStatus(active=1), pods=[pod])
    assert inferrer.status(
    ) == BenchmarkJobStatus.PENDING_AT_BENCHMARK_CONTAINER
예제 #4
0
def test_init_containers_running():
    container_state = V1ContainerState(running=V1ContainerStateRunning())
    status = V1PodStatus(
        phase="Pending",
        init_container_statuses=[
            V1ContainerStatus(
                image="benchmarkai/data-puller",
                name="data-puller",
                image_id="",
                ready=True,
                restart_count=0,
                state=container_state,
            )
        ],
    )

    pod = V1Pod(metadata=V1ObjectMeta(name="pod-name"), status=status)
    inferrer = SingleNodeStrategyKubernetesStatusInferrer(
        V1JobStatus(active=1), pods=[pod])
    assert inferrer.status() == BenchmarkJobStatus.RUNNING_AT_INIT_CONTAINERS