Repository navigation
fix: decouple PerformanceMonitor UT from debug/info logging - #766
Conversation
1. UT tasks task-1b84a8cf and task-7d4e671d failed the 4 PerformanceMonitorTest cases: runner exports QT_LOGGING_RULES="*.debug=false;*.info=false", short-circuiting qCDebug/qCInfo(appLog); the prior setFilterRules workaround (d9eeae0) proved ineffective on the cluster 2. Tests now assert state instead of log text: snapshot() exposes the last recorded timestamps, formatXxx() pure functions build the GRABPOINT messages, and timeCalls counts clock reads -- all deterministic under any logging configuration 3. Product hardening: each monitor method now reads the clock exactly once (debug streams reuse the captured timestamp), so behavior no longer depends on whether logging is enabled Log: No user-facing changes Influence: 1. Run tests/test-prj-running.sh on the AT/UT cluster with the log cap in place and verify the four PerformanceMonitorTest cases pass 2. Verify GRABPOINT output format is unchanged (POINT-01/02/04) when launching with debug logging enabled manually 3. Confirm the UT log volume still stays under the 256MB platform cap fix: PerformanceMonitor 单元测试与 debug/info 日志解耦 1. UT 任务 task-1b84a8cf、task-7d4e671d 中 PerformanceMonitorTest 4 个用例失败:运行脚本导出 QT_LOGGING_RULES="*.debug=false; *.info=false" 使 qCDebug/qCInfo(appLog) 整体短路;此前 setFilterRules 的修复(d9eeae03)在集群上证明无效 2. 用例改为状态断言:snapshot() 暴露最近一次各打点时间戳, formatXxx() 纯函数构造 GRABPOINT 消息,timeCalls 计数时钟 读取次数——任何日志配置下结果均确定 3. 产品加固:各打点方法只读一次时钟(调试流复用已捕获的 时间戳),行为不再随日志开关变化 Log: 无用户可见变化 Influence: 1. 在 AT/UT 集群带日志限流跑 tests/test-prj-running.sh,验证 PerformanceMonitorTest 四个用例全部通过 2. 手动以 debug 日志启动应用,确认 GRABPOINT 输出格式 (POINT-01/02/04)与改动前一致 3. 确认 UT 日志总量仍低于平台 256MB 上限 PMS: TASK-398635
Reviewer's GuideData structuresAdd a read-only snapshot structure for the monitor’s most recently recorded timestamps, which the tests use to assert state independently of logging.
APIExpose snapshot and pure message-formatting functions so callers and tests can inspect timestamps and verify GRABPOINT formats without capturing logs.
ImplementationReuse one captured timestamp per monitoring operation and implement the snapshot and formatting functions, decoupling recorded state and message construction from logging rules.
TestsReplace log-capture and logging-rule manipulation with deterministic timestamp, clock-read-count, and formatted-message assertions.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Problem
UT 任务 task-1b84a8cf 与 task-7d4e671d 中 PerformanceMonitorTest 4 个用例持续失败(logsContain 断言全 false、timeCalls 少计):
QT_LOGGING_RULES="*.debug=false;*.info=false"(避免打满平台 256MB 日志上限),qCDebug/qCInfo(appLog) 整体短路,消息到不了测试的捕获 handler;Solution
按"用例不依赖 debug/info 输出"重构:
PerformanceMonitor::snapshot()返回最近一次各打点时间戳;formatInitDuration/formatCloseDuration/formatOpenFileInfo纯函数构造 GRABPOINT 消息,直接断言格式;timeCalls计数时钟读取——任何日志配置下结果均确定;UT 验证任务:http://10.8.12.70:18780/task?task_id=task-52ae814e72634aa899fe72123a837aa0
PMS: TASK-398635
Summary by Sourcery
Make PerformanceMonitor unit tests deterministic regardless of runtime logging configuration.
Enhancements:
Tests: