test: bound thousand-step queue work independently of machine timing
This commit is contained in:
1 parent
0151552f55
commit
4b78ca0f27
1 file changed
+15
-1
@@ -355,6 +355,7 @@ def test_batch_clears_worker_current_state_after_saved_completion(tmp_path):
|
||||
|
||||
def test_thousand_item_multisheet_mixed_queue_has_bounded_runtime_and_memory(tmp_path, monkeypatch):
|
||||
import dx_productivity.trial_task_center.batch as batch_module
|
||||
import dx_productivity.trial_task_center.quick_run as quick_run_module
|
||||
|
||||
project_count = 20
|
||||
sheet_count = 5
|
||||
@@ -396,6 +397,15 @@ def test_thousand_item_multisheet_mixed_queue_has_bounded_runtime_and_memory(tmp
|
||||
|
||||
initial = service.quick_run_progress(task.task_id)
|
||||
expected = (str(initial.next_project_path), 'OLD-00', 'NEW-00', 'preserve')
|
||||
reads = {'_read_commands': 0, '_read_status_details': 0}
|
||||
def observe(name):
|
||||
original = getattr(quick_run_module, name)
|
||||
def counted(*args, **kwargs):
|
||||
reads[name] += 1
|
||||
return original(*args, **kwargs)
|
||||
monkeypatch.setattr(quick_run_module, name, counted)
|
||||
for name in reads:
|
||||
observe(name)
|
||||
tracemalloc.start()
|
||||
started = time.perf_counter()
|
||||
result = service.execute_quick_run_queue(task.task_id, expected_item=expected, stop_event=Event())
|
||||
@@ -410,13 +420,17 @@ def test_thousand_item_multisheet_mixed_queue_has_bounded_runtime_and_memory(tmp
|
||||
'sheets_per_project': sheet_count, 'rules_per_sheet': rule_count,
|
||||
'steps': total, 'saved_steps': saved, 'elapsed_seconds': elapsed,
|
||||
'peak_bytes': peak, 'steps_per_second': total / elapsed,
|
||||
'full_queue_parses': reads,
|
||||
}, indent=2), encoding='utf-8')
|
||||
assert result.progress.queue_complete
|
||||
assert result.progress.total_items == total
|
||||
assert result.progress.saved_items == saved
|
||||
assert result.progress.no_match_items == total - saved
|
||||
assert len(calls) == total and len(set(calls)) == total
|
||||
assert elapsed < 30
|
||||
# Wall-clock budgets depend on the machine and tracemalloc overhead. Guard
|
||||
# the repeated full-file work directly; keep timings as benchmark evidence.
|
||||
assert reads['_read_commands'] <= 2
|
||||
assert reads['_read_status_details'] <= 2
|
||||
assert peak < 128 * 1024 * 1024
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user