Skip to content

Commit 3d90512

Browse files
committed
Fix 3.0 compat test for cloudwatch, s3
1 parent ca59bb0 commit 3d90512

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

providers/amazon/tests/unit/amazon/aws/log/test_cloudwatch_task_handler.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from airflow.utils.timezone import datetime
4545

4646
from tests_common.test_utils.config import conf_vars
47-
from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
47+
from tests_common.test_utils.version_compat import AIRFLOW_V_3_0, AIRFLOW_V_3_0_PLUS
4848

4949

5050
def get_time_str(time_in_milliseconds):
@@ -259,13 +259,13 @@ def test_read(self, monkeypatch):
259259
{"timestamp": current_time, "message": "Third"},
260260
],
261261
)
262-
if AIRFLOW_V_3_0_PLUS:
262+
if AIRFLOW_V_3_0_PLUS and not AIRFLOW_V_3_0: # 3.0+
263263
monkeypatch.setattr(
264264
self.cloudwatch_task_handler,
265265
"_read_from_logs_server",
266266
lambda ti, worker_log_rel_path, log_metadata: ([], []),
267267
)
268-
else:
268+
else: # 2.x and 3.0
269269
monkeypatch.setattr(
270270
self.cloudwatch_task_handler,
271271
"_read_from_logs_server",
@@ -299,7 +299,10 @@ def test_read(self, monkeypatch):
299299
"timestamp": pendulum.datetime(2025, 3, 27, 21, 58, 1),
300300
},
301301
]
302-
assert not metadata["first_time_read"]
302+
if AIRFLOW_V_3_0:
303+
assert metadata == {"end_of_log": False, "log_pos": 3}
304+
else:
305+
assert metadata == {"end_of_log": True, "first_time_read": False}
303306
else:
304307
events = "\n".join(
305308
[

providers/amazon/tests/unit/amazon/aws/log/test_s3_task_handler.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from airflow.utils.timezone import datetime
3636

3737
from tests_common.test_utils.config import conf_vars
38-
from tests_common.test_utils.version_compat import AIRFLOW_V_3_0_PLUS
38+
from tests_common.test_utils.version_compat import AIRFLOW_V_3_0, AIRFLOW_V_3_0_PLUS
3939

4040

4141
@pytest.fixture(autouse=True)
@@ -256,7 +256,10 @@ def test_read(self):
256256
assert log[3].event == "Line 2"
257257
assert log[4].event == "Log line 3"
258258
assert log[5].event == "Line 4"
259-
assert metadata == {"end_of_log": True, "first_time_read": False}
259+
if AIRFLOW_V_3_0:
260+
assert metadata == {"end_of_log": True, "log_pos": 4}
261+
else:
262+
assert metadata == {"end_of_log": True, "first_time_read": False}
260263
else:
261264
actual = log[0][0][-1]
262265
assert f"*** Found logs in s3:\n*** * {expected_s3_uri}\n" in actual
@@ -271,7 +274,10 @@ def test_read_when_s3_log_missing(self):
271274
if AIRFLOW_V_3_0_PLUS:
272275
log = list(log)
273276
assert len(log) == 2
274-
assert metadata == {"end_of_log": True, "first_time_read": False}
277+
if AIRFLOW_V_3_0:
278+
assert metadata == {"end_of_log": True, "log_pos": 0}
279+
else:
280+
assert metadata == {"end_of_log": True, "first_time_read": False}
275281
else:
276282
assert len(log) == 1
277283
assert len(log) == len(metadata)

0 commit comments

Comments
 (0)