@@ -157,6 +157,71 @@ def test_run_report_periodic(
157157 assert "taskEvents" in checkin_bag [1 ]
158158
159159
160+ def test_run_report_periodic_reset_startup (
161+ connection_config : ConnectionConfig ,
162+ application_config : TestConfig ,
163+ requests_mock : requests_mock .Mocker ,
164+ mock_checkin_request : Callable [[requests_mock .Mocker ], None ],
165+ mock_startup_request : Callable [[requests_mock .Mocker ], None ],
166+ faker : faker .Faker ,
167+ checkin_bag : list ,
168+ ) -> None :
169+ requests_mock .real_http = True
170+ mock_startup_request (requests_mock )
171+ mock_checkin_request (requests_mock )
172+ cognite_client = connection_config .get_cognite_client ("test_checkin" )
173+ cancellation_token = CancellationToken ()
174+ worker = CheckinWorker (
175+ cognite_client ,
176+ connection_config .integration .external_id ,
177+ logging .getLogger (__name__ ),
178+ )
179+
180+ test_extractor = TestExtractor (
181+ FullConfig (
182+ connection_config = connection_config , application_config = application_config , current_config_revision = 1
183+ ),
184+ worker ,
185+ )
186+ test_extractor ._start_time = datetime .fromtimestamp (int (now () / 1000 ), tz = timezone .utc )
187+ message_queue : Queue = Queue ()
188+ mp_cancel_event = Event ()
189+ test_extractor ._attach_runtime_controls (cancel_event = mp_cancel_event , message_queue = message_queue )
190+
191+ worker .report_task_end ("task1" , faker .sentence ())
192+ worker .report_task_start ("task1" , faker .sentence ())
193+ worker .report_error (
194+ Error (
195+ level = ErrorLevel .error ,
196+ description = faker .sentence (),
197+ task_name = "task1" ,
198+ extractor = test_extractor ,
199+ details = None ,
200+ )
201+ )
202+
203+ process = Thread (
204+ target = worker .run_periodic_checkin ,
205+ args = (cancellation_token , test_extractor ._get_startup_request (), 2.0 ),
206+ )
207+ process .start ()
208+ worker .reset_startup ()
209+ process .join (timeout = 3 )
210+ cancellation_token .cancel ()
211+
212+ cancellation_token = CancellationToken ()
213+ process = Thread (
214+ target = worker .run_periodic_checkin ,
215+ args = (cancellation_token , test_extractor ._get_startup_request (), 2.0 ),
216+ )
217+ process .start ()
218+ worker .reset_startup ()
219+ process .join (timeout = 3 )
220+ cancellation_token .cancel ()
221+
222+ assert len (checkin_bag ) >= 3
223+
224+
160225def test_run_report_periodic_ensure_reorder (
161226 connection_config : ConnectionConfig ,
162227 application_config : TestConfig ,
0 commit comments