fix self heal
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import unittest
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
@@ -50,6 +51,27 @@ class TestSelfHeal(unittest.TestCase):
|
||||
|
||||
self.assertIsNone(ts)
|
||||
|
||||
def test_active_recent_progress_prevents_db_idle_restart(self) -> None:
|
||||
redis_client = MagicMock()
|
||||
redis_client.scan_iter.return_value = ["iaai:state:task_progress:hourly"]
|
||||
redis_client.get.return_value = json.dumps(
|
||||
{
|
||||
"task_id": "hourly",
|
||||
"stage": "fast_listing_collected",
|
||||
"ts": 1000,
|
||||
"last_db_progress_ts": 1,
|
||||
"skipped_existing": 2417,
|
||||
}
|
||||
)
|
||||
|
||||
active = self_heal._has_active_recent_progress(
|
||||
redis_client,
|
||||
now_ts=1010,
|
||||
stall_seconds=900,
|
||||
)
|
||||
|
||||
self.assertTrue(active)
|
||||
|
||||
@patch("iaai_scraper.worker.self_heal.time.sleep", return_value=None)
|
||||
@patch("iaai_scraper.worker.self_heal.os.kill")
|
||||
@patch("builtins.open")
|
||||
|
||||
@@ -19,6 +19,8 @@ class TestWorkerTaskLockHelpers(unittest.TestCase):
|
||||
|
||||
settings = Settings(runtime_config_file=runtime_config_file)
|
||||
settings.listing.listing_segments_json = "runtime"
|
||||
settings.scraping_profile.http_first = False
|
||||
settings.listing.fast_segment_year_splits = True
|
||||
|
||||
segs = tasks._build_listing_segments(settings)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user