Skip to content

test(pyamber): add unit test coverage for AddInputChannelHandler - #7750

Merged
aglinxinyuan merged 1 commit into
apache:mainfrom
eugenegujing:test/add-input-channel-handler-spec
Aug 18, 2026
Merged

test(pyamber): add unit test coverage for AddInputChannelHandler#7750
aglinxinyuan merged 1 commit into
apache:mainfrom
eugenegujing:test/add-input-channel-handler-spec

Conversation

@eugenegujing

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Adds test_add_input_channel_handler.py (12 tests) for core/architecture/handlers/control/add_input_channel_handler.py. The handler's three-line is_control block looks like a no-op but is load-bearing: Message.__hash__ is patched to hash-of-repr, betterproto's repr omits fields left at their default, and proto3 never puts false on the wire — so a data channel's ChannelIdentity arrives ==-equal to its canonical form yet hashing differently, and InputManager keys its channel registry by that hash. test_main_loop.py drives AddInputChannel end to end on the happy path but never pins the materialization, so the workaround could regress silently.

Every request in the spec is built through a bytes round trip so the handler receives the real wire shape — an in-process request would arrive already canonical and prove nothing. The spec pins:

  • the delegation: register_input is the input manager's only call, with the request's channel and port, and the handler returns EmptyReturn;
  • the channel id is canonical by the time register_input receives it, asserted by snapshotting the hash inside a side effect — a key inserted at the pre-materialization hash and then mutated in place strands the dict entry;
  • the consequences on a real InputManager: the registered channel resolves through get_port_id, survives the is_control read that get_all_data_channel_ids() performs on every key, and is interchangeable as a dict key with an independently built canonical id in both directions;
  • control channels arrive already canonical (proto3 does serialize true) and keep their marker, guarding the if not condition against inversion;
  • port 0, the default port, registers correctly even though its identity arrives as a bare PortIdentity() (proto3 omits both id=0 and internal=False). This is complementary to test_input_manager.py::TestPortIdentityDefaults, which feeds a hand-built PortIdentity(id=None, internal=None) — a shape no production caller of register_input produces; the wire shape exercised here is what the two wire-fed callers actually deliver, and it is canonicalized by attribute reads alone, not by the is None branches;
  • a canary pins the wire premise itself, so a betterproto upgrade that starts materializing defaults on parse reports itself instead of quietly making the rest of the file meaningless.

Any related issues, documentation, discussions?

Closes #7748.

How was this PR tested?

12 new tests, all green locally:

cd amber
pytest src/test/python/core/architecture/handlers/control/test_add_input_channel_handler.py -q   # 12 passed
pytest src/test/python/core/architecture/ -q                                                     # 303 passed
pytest src/test/python/core/runnables/test_main_loop.py -q                                       # 34 passed
pytest -m "not integration" -q                                                                   # 1068 passed
ruff check src/main/python src/test/python && ruff format --check src/main/python src/test/python

The only full-suite failures are the pre-existing core/storage/iceberg/test_iceberg_document.py items that need a local catalog stack; they fail identically without this PR.

The tests were also mutation-checked: deleting the handler's is_control block, always assigning False (guard inversion), canonicalizing after register_input instead of before, swapping the delegation arguments, dropping the call entirely, and deleting register_input's id is None guard each turn the expected tests red.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5)

Add test_add_input_channel_handler.py with 12 tests: delegation to register_input, is_control hash canonicalization of wire-parsed channel ids (dict-key interchangeability, real-InputManager lookups, the data-channel scan), control channels keeping their marker, and default-port (port 0) registration.
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • No candidates found from git blame history.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.03%. Comparing base (e80add4) to head (570c8c0).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #7750   +/-   ##
=========================================
  Coverage     91.03%   91.03%           
  Complexity     4459     4459           
=========================================
  Files          1174     1174           
  Lines         47139    47139           
  Branches       5284     5284           
=========================================
  Hits          42915    42915           
  Misses         2549     2549           
  Partials       1675     1675           
Flag Coverage Δ *Carryforward flag
access-control-service 81.00% <ø> (ø) Carriedforward from e80add4
agent-service 98.62% <ø> (ø) Carriedforward from e80add4
amber 87.49% <ø> (ø) Carriedforward from e80add4
computing-unit-managing-service 73.67% <ø> (ø) Carriedforward from e80add4
config-service 86.73% <ø> (ø) Carriedforward from e80add4
file-service 68.90% <ø> (ø) Carriedforward from e80add4
frontend 92.58% <ø> (ø) Carriedforward from e80add4
notebook-migration-service 83.74% <ø> (ø) Carriedforward from e80add4
pyamber 97.57% <ø> (ø)
workflow-compiling-service 77.19% <ø> (ø) Carriedforward from e80add4

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 6 better · 🔴 3 worse · ⚪ 6 noise (<±5%) · 0 without baseline

Compared against main 60300e3 benchmarked on this same runner, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.

Dashboard · Run

config throughput MB/s latency max Δ latest / 7d
🔴 bs=10 sw=10 sl=64 370 0.226 26,338/31,279/31,279 us 🟢 -21.5% / 🔴 +105.5%
🟢 bs=100 sw=10 sl=64 786 0.48 125,039/156,711/156,711 us 🟢 -13.1% / 🔴 +46.1%
bs=1000 sw=10 sl=64 911 0.556 1,094,775/1,152,893/1,152,893 us ⚪ within ±5% / 🔴 -13.1%
Baseline details

Latest main 60300e3 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 370 tuples/sec 395 tuples/sec 779.07 tuples/sec -6.3% -52.5%
bs=10 sw=10 sl=64 MB/s 0.226 MB/s 0.241 MB/s 0.476 MB/s -6.2% -52.5%
bs=10 sw=10 sl=64 p50 26,338 us 22,619 us 12,818 us +16.4% +105.5%
bs=10 sw=10 sl=64 p95 31,279 us 39,841 us 15,986 us -21.5% +95.7%
bs=10 sw=10 sl=64 p99 31,279 us 39,841 us 19,339 us -21.5% +61.7%
bs=100 sw=10 sl=64 throughput 786 tuples/sec 747 tuples/sec 1,011 tuples/sec +5.2% -22.3%
bs=100 sw=10 sl=64 MB/s 0.48 MB/s 0.456 MB/s 0.617 MB/s +5.3% -22.2%
bs=100 sw=10 sl=64 p50 125,039 us 129,591 us 100,965 us -3.5% +23.8%
bs=100 sw=10 sl=64 p95 156,711 us 180,273 us 107,295 us -13.1% +46.1%
bs=100 sw=10 sl=64 p99 156,711 us 180,273 us 115,531 us -13.1% +35.6%
bs=1000 sw=10 sl=64 throughput 911 tuples/sec 888 tuples/sec 1,049 tuples/sec +2.6% -13.1%
bs=1000 sw=10 sl=64 MB/s 0.556 MB/s 0.542 MB/s 0.64 MB/s +2.6% -13.1%
bs=1000 sw=10 sl=64 p50 1,094,775 us 1,124,352 us 978,248 us -2.6% +11.9%
bs=1000 sw=10 sl=64 p95 1,152,893 us 1,182,880 us 1,021,881 us -2.5% +12.8%
bs=1000 sw=10 sl=64 p99 1,152,893 us 1,182,880 us 1,050,075 us -2.5% +9.8%
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,540.04,200,128000,370,0.226,26337.50,31279.48,31279.48
1,100,10,64,20,2544.13,2000,1280000,786,0.480,125039.27,156711.22,156711.22
2,1000,10,64,20,21958.15,20000,12800000,911,0.556,1094774.76,1152892.93,1152892.93

@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Aug 18, 2026
Merged via the queue into apache:main with commit fb9f4e2 Aug 18, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add unit test coverage for the Python AddInputChannelHandler

3 participants