jscheffl commented on code in PR #65232:
URL: https://github.com/apache/airflow/pull/65232#discussion_r3081754322
##########
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/operators/test_pod.py:
##########
@@ -2842,6 +2842,31 @@ def test_write_logs_gives_up_after_max_retries(
post_complete_action.assert_called_once()
assert "Reading of logs interrupted with error" in caplog.text
+ @patch(KUB_OP_PATH.format("client"))
+ def test_write_logs_with_valid_since_time(self, mocked_client):
+ """Test that since_seconds is calculated correctly when since_time is
a valid datetime."""
+ pod = k8s.V1Pod(metadata=k8s.V1ObjectMeta(name=TEST_NAME,
namespace=TEST_NAMESPACE))
+ since_time = datetime.datetime.now(tz=datetime.timezone.utc) -
datetime.timedelta(seconds=30)
+ k = KubernetesPodOperator(task_id="task", get_logs=True)
+
+ k._write_logs(pod, since_time=since_time)
+
+ _, call_kwargs = mocked_client.read_namespaced_pod_log.call_args
+ assert call_kwargs["since_seconds"] is not None
+ assert call_kwargs["since_seconds"] >= 30
+
+ @patch(KUB_OP_PATH.format("client"))
+ def test_write_logs_with_invalid_since_time_falls_back_to_none(self,
mocked_client, caplog):
Review Comment:
Since some time be banned caplog for testing - in many cases this generated
negative side effects if some tests adjusting log level or tests were executed
in parallel. Please use other means of grabbing the log or ignore content from
logs and just have logical checks
--
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]