@@ -40,6 +40,10 @@ def test_read_log_stream_for_action_run_yelp_clog():
40
40
), mock .patch ("tron.config.static_config.build_configuration_watcher" , autospec = True ,), mock .patch (
41
41
"tron.config.static_config.load_yaml_file" ,
42
42
autospec = True ,
43
+ ), mock .patch (
44
+ "tron.utils.scribereader.get_ecosystem" , autospec = True , return_value = "fake"
45
+ ), mock .patch (
46
+ "tron.utils.scribereader.get_superregion" , autospec = True , return_value = "fake"
43
47
), mock .patch (
44
48
"tron.utils.scribereader.S3LogsReader" , autospec = True
45
49
) as mock_s3_reader :
@@ -80,6 +84,47 @@ def test_read_log_stream_for_action_run_yelp_clog():
80
84
assert output == ["line 1" , "line 2" ]
81
85
82
86
87
+ @pytest .mark .parametrize (
88
+ "local_datetime, expected_date" ,
89
+ [
90
+ (
91
+ datetime .datetime (2024 , 2 , 29 , 23 , 59 , 59 , tzinfo = datetime .timezone (datetime .timedelta (hours = + 3 ))),
92
+ datetime .date (2024 , 2 , 29 ),
93
+ ),
94
+ (
95
+ datetime .datetime (2024 , 2 , 29 , 23 , 59 , 59 , tzinfo = datetime .timezone (datetime .timedelta (hours = - 3 ))),
96
+ datetime .date (2024 , 3 , 1 ),
97
+ ),
98
+ ],
99
+ )
100
+ def test_read_log_stream_for_action_run_yelp_clog_tz (local_datetime , expected_date ):
101
+ with mock .patch (
102
+ "staticconf.read" ,
103
+ autospec = True ,
104
+ side_effect = static_conf_patch ({"logging.use_s3_reader" : True , "logging.max_lines_to_display" : 1000 }),
105
+ ), mock .patch ("tron.config.static_config.build_configuration_watcher" , autospec = True ,), mock .patch (
106
+ "tron.config.static_config.load_yaml_file" ,
107
+ autospec = True ,
108
+ ), mock .patch (
109
+ "tron.utils.scribereader.get_ecosystem" , autospec = True , return_value = "fake"
110
+ ), mock .patch (
111
+ "tron.utils.scribereader.get_superregion" , autospec = True , return_value = "fake"
112
+ ), mock .patch (
113
+ "tron.utils.scribereader.S3LogsReader" , autospec = True
114
+ ) as mock_s3_log_reader :
115
+
116
+ read_log_stream_for_action_run (
117
+ "namespace.job.1234.action" ,
118
+ component = "stdout" ,
119
+ min_date = local_datetime ,
120
+ max_date = local_datetime ,
121
+ paasta_cluster = "fake" ,
122
+ )
123
+ mock_s3_log_reader .return_value .get_log_reader .assert_called_once_with (
124
+ log_name = mock .ANY , min_date = expected_date , max_date = expected_date
125
+ )
126
+
127
+
83
128
def test_read_log_stream_for_action_run_min_date_and_max_date_today ():
84
129
# NOTE: these tests don't actually depend on the current time apart from
85
130
# today vs not-today and the args are forwarded to scribereader anyway
0 commit comments