Repository navigation
Description
Task Summary
amber/src/main/scala/org/apache/texera/amber/engine/architecture/worker/DPThread.scala is at 74.7% by Codecov's metric — 3 missed and 19 partial of 87 lines, with 26 of 76 branch arms uncovered. DPThreadSpec has 8 tests and none of them exercise the thread's lifecycle edges: stopping before start, parking when idle, or a pause arriving mid-batch.
The tests are cheap — the existing fixtures need no DB, Iceberg, Python or actor system — but the measurement is full of traps, and most of the apparent gap is not real:
- The entire payload-dispatch block (lines 204-223) is not counted at all.
logManager.withFaultTolerant { msgOpt match { … } }compiles into$anonfun$runDPThreadMainLogic$2, andjavap -vshowsACC_SYNTHETIC, so JaCoCo'sSyntheticFilterdrops it — the tracked line list jumps straight from 203 to 224. Any test aimed at ECM/DCM dispatch here moves Codecov by exactly zero. Same for line 201's filter lambda. - Four lines are permanently partial because of scala-logging. Lines 84, 102, 110 and 112 each expand to
if (logger.underlying.isXEnabled) …, so at any fixed log level exactly one arm is dead. CI pinsTEXERA_SERVICE_LOG_LEVEL=WARN. Closing them would mean mutating logback levels from a test, which is a pure count-raising trick. - Line 88 can never be fully covered.
if (dp.stateManager.getCurrentState == UNINITIALIZED)disassembles toifnonnull/ifnull/ifeq= 6 arms with 4 missed, and since the state object is never null the null-equals-null leg is unreachable dead code. Even covering the reachable arm leaves 3 arms missed, so the line stays "missed" forever. - Other structurally dead arms: the lazy-val double-checked-lock arm,
$outer == nullguards, theisDefinedAtelse-arm (dead because the partial function's last case iscase err: Throwable, hence total), theMatchErrorarm of a sealed trait with three final case classes, and theMatchErrorarms of exhaustiveOptionmatches. - Line 91's false arm is only reachable by assigning the public
var dpThreadfrom outside, sincestop()nulls neither field. That is an artificial test of an unreachable state. - A stop-during-busy-spin test is a race. It depends on the interrupt landing while the thread is in a non-interruptible spin, so the loop exits via the stop flag rather than via
InterruptedExceptionfrominternalQueue.take. Give it a large margin and do not shrink the tuple count. Conversely, tests that prove data is not flowing are one-sided — a slow runner makes them more reliable, not less. - Watch for unsynchronized reads of plain
vars written by the DP thread as test gates; they work by luck. And do not locate the thread by name — several tests never stop theirs, so multiple live threads share the name.
85.1% is the realistic ceiling here.
Task Type
- Refactor / Cleanup
- DevOps / Deployment / CI
- Testing / QA
- Documentation
- Performance
- Other
Metadata
Metadata
Assignees
Labels
No labels
Activity
test(amber): cover the DP thread's lifecycle edges (apache#7870)