def test_pod_conditions_pod_without_node(self) -> None: last_transition_time = datetime.datetime(2021, 10, 29, 9, 5, 52, tzinfo=tzutc()) pod_condition_list = [ client.V1PodCondition( last_probe_time=None, last_transition_time=last_transition_time, message="0/1 nodes are available: 1 Too many pods.", reason="Unschedulable", status="False", type="PodScheduled", ) ] self.assertEqual( pod_conditions(pod_condition_list), [ api.PodCondition( status=False, type=api.ConditionType.PODSCHEDULED, custom_type=None, reason="Unschedulable", detail="0/1 nodes are available: 1 Too many pods.", last_transition_time=convert_to_timestamp( last_transition_time)) ], )
def test_pod_conditions_start_up_missing_fields(self) -> None: """ In this specific instance all of the fields except for the scheduled field are missing. """ pod = Pod( uid=Mock(), status=api.PodStatus( start_time=int( convert_to_timestamp( datetime.datetime( 2021, 11, 22, 16, 11, 38, 710257, tzinfo=datetime.timezone.utc ) ) ), conditions=[ api.PodCondition( status=True, type=api.ConditionType.PODSCHEDULED, custom_type=None, reason=None, detail=None, ) ], phase=api.Phase.PENDING, qos_class="burstable", ), metadata=Mock(), spec=Mock(), containers=Mock(), init_containers=Mock(), ) self.assertEqual( pod.conditions(), section.PodConditions( initialized=None, scheduled=section.PodCondition(status=True, reason=None, detail=None), containersready=None, ready=None, ), )
def test_pod_conditions_start_up(self) -> None: """ It is possible that during startup of pods, also more complete information arises. """ pod_status = api.PodStatus( start_time=int( convert_to_timestamp( datetime.datetime(2021, 11, 22, 16, 11, 38, 710257))), conditions=[ api.PodCondition( status=True, type=api.ConditionType.INITIALIZED, custom_type=None, reason=None, detail=None, ), api.PodCondition( status=False, type=api.ConditionType.READY, custom_type=None, reason="ContainersNotReady", detail= "containers with unready status: [unready_container]", ), api.PodCondition( status=False, type=api.ConditionType.CONTAINERSREADY, custom_type=None, reason="ContainersNotReady", detail= "containers with unready status: [unready_container]", ), api.PodCondition( status=True, type=api.ConditionType.PODSCHEDULED, custom_type=None, reason=None, detail=None, ), ], phase=api.Phase.PENDING, ) pod = Pod( uid=Mock(), status=pod_status, metadata=Mock(), spec=Mock(), resources=Mock(), containers=Mock(), ) self.assertEqual( pod.conditions(), section.PodConditions( initialized=section.PodCondition(status=True, reason=None, detail=None), scheduled=section.PodCondition(status=True, reason=None, detail=None), containersready=section.PodCondition( status=False, reason="ContainersNotReady", detail= "containers with unready status: [unready_container]", ), ready=section.PodCondition( status=False, reason="ContainersNotReady", detail= "containers with unready status: [unready_container]", ), ), )