Repository navigation
test(pyamber): extend the StartWorkerHandler unit tests - #7061
Conversation
Automated Reviewer SuggestionsBased on the
|
Rewrites test_start_worker_handler.py, added by apache#6988, to cover all three branches and the shared tail. The source branch pins the RUNNING transition, the synthetic port and SOURCE_STARTER channel registration (including their order, since the reverse raises KeyError on a real InputManager), and the ordered pair of enqueued ECMElements: StartChannel with NO_ALIGNMENT then EndChannel with PORT_ALIGNMENT, both carrying the no-reply command id -1. Branch precedence, the empty marker scope, the unwrappable EmptyRequest and the data-sub-queue routing of the markers were not previously asserted. Six tests use real collaborators rather than mocks, for behavior mocks cannot express -- a rejected transition leaves the queue, the state and the InputManager untouched, the markers land in the data sub-queue and so are gated by disable_data, and the response version tracks the real state clock on both the source and the non-source paths. One of them pins observed current behavior rather than correctness, and says so in a comment: a second StartWorker silently appends another marker pair. The two real-state-clock tests on the non-source paths carry over the READY and PAUSED cases from apache#6988; everything else that file asserted is subsumed by a stricter assertion here. Closes apache#7058
b6079c3 to
43ca78c
Compare
|
Rebased this onto main and resolved the conflict — no action needed on your end. #6988 landed this morning and added a The one thing I carried over from #6988 is its two non-source cases against a real Also refreshed the title and description, which still described this as the first test for the handler. 23 cases in the file, handlers package at 69 passing, |
|
| config | throughput | MB/s | latency | max Δ latest / 7d | |
|---|---|---|---|---|---|
| 🔴 | bs=10 sw=10 sl=64 | 550 | 0.336 | 18,781/24,687/24,687 us | 🔴 +13.3% / 🔴 +56.5% |
| 🟢 | bs=100 sw=10 sl=64 | 1,205 | 0.735 | 81,353/100,671/100,671 us | 🟢 -15.4% / 🟢 +20.5% |
| ⚪ | bs=1000 sw=10 sl=64 | 1,425 | 0.87 | 699,851/738,237/738,237 us | ⚪ within ±5% / 🟢 +38.2% |
Baseline details
Latest main 7d5276d from same runner
| config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
|---|---|---|---|---|---|---|
| bs=10 sw=10 sl=64 | throughput | 550 tuples/sec | 572 tuples/sec | 786.12 tuples/sec | -3.8% | -30.0% |
| bs=10 sw=10 sl=64 | MB/s | 0.336 MB/s | 0.349 MB/s | 0.48 MB/s | -3.7% | -30.0% |
| bs=10 sw=10 sl=64 | p50 | 18,781 us | 16,577 us | 12,305 us | +13.3% | +52.6% |
| bs=10 sw=10 sl=64 | p95 | 24,687 us | 25,820 us | 15,774 us | -4.4% | +56.5% |
| bs=10 sw=10 sl=64 | p99 | 24,687 us | 25,820 us | 18,978 us | -4.4% | +30.1% |
| bs=100 sw=10 sl=64 | throughput | 1,205 tuples/sec | 1,178 tuples/sec | 999.71 tuples/sec | +2.3% | +20.5% |
| bs=100 sw=10 sl=64 | MB/s | 0.735 MB/s | 0.719 MB/s | 0.61 MB/s | +2.2% | +20.5% |
| bs=100 sw=10 sl=64 | p50 | 81,353 us | 82,756 us | 100,616 us | -1.7% | -19.1% |
| bs=100 sw=10 sl=64 | p95 | 100,671 us | 119,023 us | 107,356 us | -15.4% | -6.2% |
| bs=100 sw=10 sl=64 | p99 | 100,671 us | 119,023 us | 113,255 us | -15.4% | -11.1% |
| bs=1000 sw=10 sl=64 | throughput | 1,425 tuples/sec | 1,456 tuples/sec | 1,031 tuples/sec | -2.1% | +38.2% |
| bs=1000 sw=10 sl=64 | MB/s | 0.87 MB/s | 0.888 MB/s | 0.63 MB/s | -2.0% | +38.2% |
| bs=1000 sw=10 sl=64 | p50 | 699,851 us | 683,749 us | 980,328 us | +2.4% | -28.6% |
| bs=1000 sw=10 sl=64 | p95 | 738,237 us | 724,071 us | 1,027,528 us | +2.0% | -28.2% |
| bs=1000 sw=10 sl=64 | p99 | 738,237 us | 724,071 us | 1,054,298 us | +2.0% | -30.0% |
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,363.84,200,128000,550,0.336,18781.30,24687.18,24687.18
1,100,10,64,20,1659.97,2000,1280000,1205,0.735,81352.98,100671.36,100671.36
2,1000,10,64,20,14036.00,20000,12800000,1425,0.870,699850.50,738236.91,738236.91
What changes were proposed in this PR?
Rewrites
amber/src/test/python/core/architecture/handlers/control/test_start_worker_handler.py, added by #6988 while this PR was open, to cover all three branches ofStartWorkerHandlerand the shared tail.Four behaviors the previous file did not assert:
is_sourcewins even when materialization reader threads exist, so theelifpredicate must go unqueriedEmptyRequestunwrapped viaget_one_ofAsyncRpcServerunwraps the payload before dispatching; an unset oneof deliversNone, and betterproto's__eq__cannot see the differenceECMElements are data traffic, so a source worker's own start/end markers are gated bydisable_data— pause and backpressure — unlike control messagesIt also pins the ordering of
add_input_portbeforeregister_input(the reverse raisesKeyErroron a realInputManager, sinceregister_inputends withself._ports[port_id].add_channel(...)).Six tests run against real collaborators — a
StateManagerbuilt on the production transition graph and a realInputManagersharing the context'sInternalQueue— rather than mocks, because they pin behavior mocks cannot express: a rejected transition fromUNINITIALIZEDleaves the queue, the state and theInputManageruntouched; the two markers are routed to the data sub-queue; and the response version tracks the real state clock on both the source and the non-source paths. The two non-source cases (READY/0 with reader threads,PAUSED/1 echoed untouched) carry over from #6988; everything else that file asserted is subsumed by a stricter assertion here.test_double_start_enqueues_a_second_pair_of_markersdeliberately pins observed current behavior rather than correctness.StateManager.transit_toreturns early when the target equals the current state, so a secondStartWorkeris a silent no-op on the state and appends another marker pair — including a secondPORT_ALIGNMENTEndChannelon the same port. The test comment says so and asks for a rewrite if an idempotency guard is ever added.Test-only change; no production code is touched.
Any related issues, documentation, discussions?
Closes #7058.
The real-collaborator tests double as a Python-side guard against the stale-state-snapshot family of bugs described in #6010 (
WorkerExecution.scala:56); a mockedget_state_with_versionreturns a constant and cannot catch a hoisted snapshot.How was this PR tested?
New unit tests only; no production behavior changes.
black --checkandruff checkclean.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5)