You've already forked FrameTour-RenderWorker
test(handlers): 添加基础处理器并行传输相关单元测试
- 实现 download_files_parallel 方法的并发下载功能测试 - 验证上传文件并行处理收集URL功能的正确性 - 测试下载文件时设置锁等待时间跨度属性 - 验证无缓存下载时锁等待时间为零的场景 - 测试上传文件时设置详细的跨度属性功能 - 添加渲染视频效果相关的参数解析测试 - 实现存储服务上传指标
This commit is contained in:
51
tests/unit/test_tracing.py
Normal file
51
tests/unit/test_tracing.py
Normal file
@@ -0,0 +1,51 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import importlib
|
||||
from types import SimpleNamespace
|
||||
|
||||
import util.tracing as tracing_module
|
||||
|
||||
|
||||
def _create_task_stub():
|
||||
task_type = SimpleNamespace(value="RENDER_SEGMENT_VIDEO")
|
||||
return SimpleNamespace(
|
||||
task_id="task-1001",
|
||||
task_type=task_type,
|
||||
get_job_id=lambda: "job-2002",
|
||||
get_segment_id=lambda: "seg-3003",
|
||||
)
|
||||
|
||||
|
||||
def test_task_trace_scope_sets_and_resets_context(monkeypatch):
|
||||
monkeypatch.setenv("OTEL_ENABLED", "false")
|
||||
tracing = importlib.reload(tracing_module)
|
||||
|
||||
assert tracing.initialize_tracing("worker-1", "2.0.0") is False
|
||||
assert tracing.get_current_task_context() is None
|
||||
|
||||
with tracing.task_trace_scope(_create_task_stub()) as span:
|
||||
assert span is None
|
||||
context = tracing.get_current_task_context()
|
||||
assert context is not None
|
||||
assert context.task_id == "task-1001"
|
||||
assert context.task_type == "RENDER_SEGMENT_VIDEO"
|
||||
assert context.job_id == "job-2002"
|
||||
assert context.segment_id == "seg-3003"
|
||||
|
||||
with tracing.start_span("render.task.sample.step") as child_span:
|
||||
assert child_span is None
|
||||
|
||||
assert tracing.get_current_task_context() is None
|
||||
|
||||
|
||||
def test_bind_trace_context_restores_previous_context(monkeypatch):
|
||||
monkeypatch.setenv("OTEL_ENABLED", "false")
|
||||
tracing = importlib.reload(tracing_module)
|
||||
|
||||
tracing.initialize_tracing("worker-1", "2.0.0")
|
||||
context = tracing.TaskTraceContext(task_id="task-1", task_type="FINALIZE_MP4")
|
||||
|
||||
assert tracing.get_current_task_context() is None
|
||||
with tracing.bind_trace_context(None, context):
|
||||
assert tracing.get_current_task_context() == context
|
||||
assert tracing.get_current_task_context() is None
|
||||
Reference in New Issue
Block a user