fix(platform-fulfillment): 释放空闲连接并合并选号请求
This commit is contained in:
@@ -1042,6 +1042,22 @@ class TestSnapshotSync(_Base):
|
||||
|
||||
|
||||
class TestAccountSelection(_Base):
|
||||
def test_manual_allocation_request_only_marks_task_due(self):
|
||||
task = self.task()
|
||||
old_retry_at = task.next_allocate_at
|
||||
|
||||
detail = service.prepare_manual_allocation(
|
||||
self.session,
|
||||
task_id=task.id,
|
||||
current=self.admin,
|
||||
)
|
||||
|
||||
self.session.refresh(task)
|
||||
assert detail["task"]["account"] is None
|
||||
assert task.next_allocate_at is not None
|
||||
assert old_retry_at is None or task.next_allocate_at >= old_retry_at
|
||||
self.refresh_mock.assert_not_called()
|
||||
|
||||
def test_capability_match_checks_only_selected_candidate(self, monkeypatch):
|
||||
account = self.account("capability-fast")
|
||||
task = self.task()
|
||||
|
||||
@@ -13,6 +13,26 @@ from web.backend.models import (
|
||||
from web.backend.services.platform_fulfillment import auto_allocator
|
||||
|
||||
|
||||
def test_queue_task_allocation_deduplicates_pending_and_running_tasks():
|
||||
with auto_allocator._pending_lock:
|
||||
auto_allocator._pending_task_ids.clear()
|
||||
auto_allocator._running_task_ids.clear()
|
||||
try:
|
||||
assert auto_allocator.queue_task_allocation(3565) is True
|
||||
assert auto_allocator.queue_task_allocation(3565) is False
|
||||
|
||||
with auto_allocator._pending_lock:
|
||||
auto_allocator._pending_task_ids.discard(3565)
|
||||
auto_allocator._running_task_ids.add(3565)
|
||||
|
||||
assert auto_allocator.queue_task_allocation(3565) is False
|
||||
finally:
|
||||
with auto_allocator._pending_lock:
|
||||
auto_allocator._pending_task_ids.clear()
|
||||
auto_allocator._running_task_ids.clear()
|
||||
auto_allocator._wake_event.clear()
|
||||
|
||||
|
||||
def test_auto_allocator_only_scans_ready_unassigned_tasks(db):
|
||||
actor = User(username="auto-alloc-actor", password_hash="h", role="super_admin")
|
||||
db.add(
|
||||
@@ -81,6 +101,7 @@ def test_auto_allocator_only_scans_ready_unassigned_tasks(db):
|
||||
|
||||
assert calls == [ready.id]
|
||||
assert result == {"checked": 1, "allocated": 1, "failed": 0}
|
||||
assert not auto_allocator._running_task_ids
|
||||
|
||||
|
||||
def test_auto_allocator_schedules_retry_only_after_failed_allocation(db):
|
||||
|
||||
Reference in New Issue
Block a user