xchwan commented on code in PR #56578:
URL: https://github.com/apache/airflow/pull/56578#discussion_r2433188700
##########
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/hooks/test_kubernetes.py:
##########
@@ -760,9 +760,11 @@ def test_check_kueue_deployment_running(self,
mock_get_deployment_status, mock_l
@mock.patch(HOOK_MODULE + ".KubernetesHook.log")
@mock.patch(HOOK_MODULE + ".KubernetesHook.get_deployment_status")
def test_check_kueue_deployment_raise_exception(self,
mock_get_deployment_status, mock_log):
- mock_get_deployment_status.side_effect = ValueError
+ mock_get_deployment_status.side_effect = ValueError(
+ "Exception occurred while checking for Deployment status."
+ )
- with pytest.raises(ValueError):
+ with pytest.raises(ValueError, match="Exception occurred while
checking for Deployment status."):
Review Comment:
This is the function which this case test
```python
def check_kueue_deployment_running(
self, name: str, namespace: str, timeout: float = 300.0,
polling_period_seconds: float = 2.0
) -> None:
_timeout = timeout
while _timeout > 0:
try:
deployment = self.get_deployment_status(name=name,
namespace=namespace)
except Exception as e:
self.log.exception("Exception occurred while checking for
Deployment status.")
raise e
deployment_status = V1Deployment.to_dict(deployment)["status"]
replicas = deployment_status["replicas"]
ready_replicas = deployment_status["ready_replicas"]
unavailable_replicas = deployment_status["unavailable_replicas"]
if (
replicas is not None
and ready_replicas is not None
and unavailable_replicas is None
and replicas == ready_replicas
):
return
self.log.info("Waiting until Deployment will be ready...")
sleep(polling_period_seconds)
_timeout -= polling_period_seconds
raise AirflowException("Deployment timed out")
```
As we can see in
```python
while _timeout > 0:
try:
deployment = self.get_deployment_status(name=name,
namespace=namespace)
except Exception as e:
self.log.exception("Exception occurred while checking for
Deployment status.")
raise e
```
It calling get_deployment_status, and re-raise it as is when fail. I think
in real scenario get deployment status will raise error message, which is
kubernetes provided. In this test, it mock the case kubernetes raise valueError
without error message. So, it get empty match before this PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]