feat: stabilize multi-region runtime sync and worker orchestration
This commit is contained in:
@@ -5,6 +5,9 @@ from domainCheck.detect import aizhan, baidu, c360, chinaz
|
||||
|
||||
|
||||
class StepTimeoutBudgetTests(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
c360._PROXY_SESSIONS.clear()
|
||||
|
||||
def test_baidu_timeout_respects_remaining_budget(self):
|
||||
with patch.dict("os.environ", {}, clear=False):
|
||||
timeout = baidu._resolve_baidu_timeout({"http": "http://127.0.0.1:8080"}, budget_seconds=1.1)
|
||||
@@ -17,6 +20,33 @@ class StepTimeoutBudgetTests(unittest.TestCase):
|
||||
self.assertLessEqual(timeout, 0.9)
|
||||
self.assertGreaterEqual(timeout, 0.6)
|
||||
|
||||
def test_360_direct_session_disables_env_proxy_and_is_reused(self):
|
||||
first = c360._get_session()
|
||||
second = c360._get_session()
|
||||
self.assertIs(first, second)
|
||||
self.assertFalse(first.trust_env)
|
||||
|
||||
def test_360_proxy_session_is_reused_per_proxy_url(self):
|
||||
first = c360._get_session({"http": "http://127.0.0.1:8080"})
|
||||
second = c360._get_session({"https": "http://127.0.0.1:8080"})
|
||||
third = c360._get_session({"http": "http://127.0.0.1:8081"})
|
||||
self.assertIs(first, second)
|
||||
self.assertIsNot(first, third)
|
||||
self.assertFalse(first.trust_env)
|
||||
|
||||
def test_360_proxy_session_cache_evicts_oldest_entry(self):
|
||||
with patch.dict("os.environ", {"DOMAINCHECK_360_PROXY_SESSION_CACHE_SIZE": "2"}, clear=False):
|
||||
first = c360._get_session({"http": "http://127.0.0.1:8080"})
|
||||
second = c360._get_session({"http": "http://127.0.0.1:8081"})
|
||||
third = c360._get_session({"http": "http://127.0.0.1:8082"})
|
||||
|
||||
self.assertEqual(2, len(c360._PROXY_SESSIONS))
|
||||
self.assertIsNotNone(second)
|
||||
self.assertIsNotNone(third)
|
||||
|
||||
recreated_first = c360._get_session({"http": "http://127.0.0.1:8080"})
|
||||
self.assertIsNot(first, recreated_first)
|
||||
|
||||
def test_chinaz_timeout_respects_remaining_budget(self):
|
||||
timeout = chinaz._resolve_chinaz_timeout({"http": "http://127.0.0.1:8080"}, budget_seconds=1.3)
|
||||
self.assertLessEqual(timeout, 1.3)
|
||||
|
||||
Reference in New Issue
Block a user