Skip to content

test(pyamber): add unit test coverage for AssignPortHandler - #7374

Merged
aglinxinyuan merged 1 commit into
apache:mainfrom
eugenegujing:test/assign-port-handler-spec
Aug 7, 2026
Merged

aglinxinyuan merged 1 commit into
apache:mainfrom
eugenegujing:test/assign-port-handler-spec

Conversation

@eugenegujing

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Adds amber/src/test/python/core/architecture/handlers/control/test_assign_port_handler.py (14 test functions, 16 collected), the first dedicated tests for the Python worker's AssignPort RPC handler. Sibling handlers in the same package already have test files; this handler's only driver was test_main_loop.py, whose AssignPortRequest fixtures pass no storage_uris/partitionings, so the per-URI channel registration loop never executed and the output branch ran only as setup.

Covered behavior:

  • Input branch: add_input_port receives the port id, the wrapped Schema, and the storage_uris/partitionings lists verbatim; one data channel is registered per URI, in URI order, with the reader identity derived by get_from_actor_id_for_input_port_storage, this worker as the target, and is_control false; with no URIs nothing is registered. Unlike the output branch there is no truthiness guard, so an empty-string URI still registers a channel — the Scala worker behaves the same, pinned as a cross-language symmetry.
  • Output branch: no URIs and an empty-string URI both yield storage_uri_base=None (the production coordinator really sends [""] for a storage-less output port — RegionExecutionManager falls back to .getOrElse("")), a single URI is passed through, and every URI after the first is dropped (pinned as current behavior).
  • Both branches return EmptyReturn, wrap req.schema into a value-equal Schema, and leave the other manager untouched; an AssignPortRequest built without the storage_uris field iterates as an empty repeated field.

The harness follows test_start_worker_handler.py: asyncio.run per test, SimpleNamespace context with MagicMock managers, no production code changes.

Any related issues, documentation, discussions?

Closes #7371.

How was this PR tested?

85 passed (69 baseline + 16 new). An independent review applied 14 targeted mutations to the handler (branch swap, dropped registration loop, swapped channel endpoints, is_control flip, reordered/emptied lists, wrong URI index, dropped or added truthiness guards on either branch, None base, None return, empty schema in each branch, wrong port id, fully stubbed body) — every mutation is killed by at least one test. black --check and ruff check are clean.

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

Co-authored by: Claude Code (Fable 5)

Add test_assign_port_handler.py covering the AssignPort RPC handler: the input branch's port registration with storage URIs and partitionings passed through verbatim plus one data channel registered per URI (derived reader identity, this worker as target, is_control false), and the output branch's storage-base selection (no URIs and the empty-string URI both mean no storage, only the first URI is used). Both branches' EmptyReturn and raw-schema wrapping are pinned, and an unset storage_uris field is exercised as an empty repeated field.
@github-actions

github-actions Bot commented Aug 7, 2026

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 83.73%. Comparing base (cc83087) to head (581f306).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7374      +/-   ##
============================================
+ Coverage     83.72%   83.73%   +0.01%     
  Complexity     4137     4137              
============================================
  Files          1169     1169              
  Lines         46520    46520              
  Branches       5179     5179              
============================================
+ Hits          38947    38952       +5     
+ Misses         5860     5855       -5     
  Partials       1713     1713              
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from cc83087
agent-service 83.65% <ø> (ø) Carriedforward from cc83087
amber 80.66% <ø> (ø) Carriedforward from cc83087
computing-unit-managing-service 50.72% <ø> (ø) Carriedforward from cc83087
config-service 65.97% <ø> (ø) Carriedforward from cc83087
file-service 69.05% <ø> (ø) Carriedforward from cc83087
frontend 84.71% <ø> (ø) Carriedforward from cc83087
notebook-migration-service 78.89% <ø> (ø) Carriedforward from cc83087
pyamber 97.47% <ø> (+0.11%) ⬆️
workflow-compiling-service 26.31% <ø> (ø) Carriedforward from cc83087

*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

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 2 better · 🔴 4 worse · ⚪ 9 noise (<±5%) · 0 without baseline

Compared against main 18a277c 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 443 0.27 22,062/27,831/27,831 us 🟢 -11.4% / 🔴 +73.2%
🔴 bs=100 sw=10 sl=64 940 0.574 102,331/159,216/159,216 us 🔴 +16.7% / 🔴 +43.8%
⚪ bs=1000 sw=10 sl=64 1,089 0.665 911,692/956,089/956,089 us ⚪ within ±5% / 🟢 -12.1%
Baseline details

Latest main 18a277c from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 443 tuples/sec 471 tuples/sec 757.88 tuples/sec -5.9% -41.5%
bs=10 sw=10 sl=64 MB/s 0.27 MB/s 0.287 MB/s 0.463 MB/s -5.9% -41.6%
bs=10 sw=10 sl=64 p50 22,062 us 21,451 us 12,904 us +2.8% +71.0%
bs=10 sw=10 sl=64 p95 27,831 us 31,426 us 16,065 us -11.4% +73.2%
bs=10 sw=10 sl=64 p99 27,831 us 31,426 us 19,384 us -11.4% +43.6%
bs=100 sw=10 sl=64 throughput 940 tuples/sec 972 tuples/sec 957.87 tuples/sec -3.3% -1.9%
bs=100 sw=10 sl=64 MB/s 0.574 MB/s 0.593 MB/s 0.585 MB/s -3.2% -1.8%
bs=100 sw=10 sl=64 p50 102,331 us 100,466 us 104,502 us +1.9% -2.1%
bs=100 sw=10 sl=64 p95 159,216 us 136,470 us 110,735 us +16.7% +43.8%
bs=100 sw=10 sl=64 p99 159,216 us 136,470 us 120,386 us +16.7% +32.3%
bs=1000 sw=10 sl=64 throughput 1,089 tuples/sec 1,125 tuples/sec 988.88 tuples/sec -3.2% +10.1%
bs=1000 sw=10 sl=64 MB/s 0.665 MB/s 0.687 MB/s 0.604 MB/s -3.2% +10.2%
bs=1000 sw=10 sl=64 p50 911,692 us 889,371 us 1,018,589 us +2.5% -10.5%
bs=1000 sw=10 sl=64 p95 956,089 us 950,991 us 1,056,001 us +0.5% -9.5%
bs=1000 sw=10 sl=64 p99 956,089 us 950,991 us 1,087,982 us +0.5% -12.1%
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,451.62,200,128000,443,0.270,22061.90,27830.73,27830.73
1,100,10,64,20,2128.50,2000,1280000,940,0.574,102331.27,159215.68,159215.68
2,1000,10,64,20,18357.69,20000,12800000,1089,0.665,911691.99,956089.14,956089.14

@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Aug 7, 2026
Merged via the queue into apache:main with commit 23ea0fa Aug 7, 2026
26 checks passed
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Nov 25, 2026
…9686)

### What changes were proposed in this PR?

Remove code that nothing uses, and constructs that repeat a default or
an alias, from the Python tests, the agent service, three frontend
specs, the AsterixDB source and the RustFS test container, and make an
unreachable error check in the single-node example loader reachable
(**+84/−137 lines**). Only the loader's behavior changes: a workflow
file that `jq` cannot parse is now reported and skipped instead of
aborting the loader.

- **Python tests (14 files):** `test_console_message.py` drops the
unused `internal_queue` and `timed_buffer` fixtures and their imports.
Two tests drop fixture parameters they never read (`executor`,
`a_timestamp`), and `test_proxy_client.py` names an unused loop value
`_`. The others write `dict(...)` calls as literals, return from
fixtures that yield without teardown, drop empty `@pytest.fixture()`
parentheses, merge nested `with` blocks, return a value directly instead
of through a local, take the first element with `next(iter(...))`, and
spell `datetime.timezone.utc`, `socket.timeout` and `bytes()` as
`datetime.UTC`, `TimeoutError` and `b""` (Ruff targets Python 3.11).
- **Agent service:** `src/agent/index.ts` and `src/api/index.ts` only
re-export modules that callers import directly. No file imports either
barrel, and the package entry is `src/index.ts`.
`workflow-system-metadata.ts` drops the unused `OperatorSchema` and
`ValidationError` type imports.
- **Frontend specs:** the dataset and model creator specs drop
`FormsModule` and `HttpClientTestingModule`, which
`createFormlyModalFixture` already provides, and the admin Gmail spec
drops three modules that the standalone component and its stubbed
service do not need.
- **`load-examples.sh`:** tests the `content=$(jq -c .
"$workflow_file")` assignment in the `if` instead of checking `$?` after
it. The script runs under `set -euo pipefail` and `main` calls
`load_workflows` directly, so the old check could never fire: a workflow
file that `jq` could not parse aborted the loader and skipped the files
after it, although the comment above `FAILURES` calls each failure
deliberately non-fatal. Now `print_error` counts the file, the loop
moves on, and `main` still exits non-zero at the end.
`test_load_examples_sh.sh` adds a case with an unparseable workflow
sorted ahead of a good one.
- **AsterixDB source:** `AsterixDBConnUtil` and `AsterixDBSourceOpExec`
assign the version response and the parsed row once as `val`s instead of
overwriting `null` and `None` placeholders.
- **`RustFSContainer`:** drops the Scaladoc lines saying the console is
left disabled. RustFS 1.0.0 enables the console by default, and the
fixture does not override it.

| Event | PR / Commit |
| --- | --- |
| Introduced by | Python tests: apache#1259 (2021-07-23), apache#1498 (2022-04-15),
apache#1452 (2022-05-13), apache#2067 (2023-07-27), apache#1748 (2023-11-09), apache#2815
(2024-09-05), apache#4520 (2026-04-27), apache#4704, apache#4719 and apache#4795 (2026-05-03),
apache#4893 (2026-05-04), apache#6643 (2026-07-20), apache#6988 (2026-07-29), apache#7374
(2026-08-07), apache#7579 (2026-08-13), apache#8067 (2026-08-29), apache#8542
(2026-09-15), apache#9279 (2026-11-04), apache#8704 (2026-11-05), apache#9623
(2026-11-23); agent service: apache#4020 (2025-11-25), apache#4495 and apache#4540
(2026-04-28); frontend specs: apache#6513 (2026-07-18), apache#6576 (2026-07-20),
apache#8068 (2026-08-28); `load-examples.sh`: apache#4247 (2026-03-02); AsterixDB
source: apache#1044 (2021-02-25); `RustFSContainer`: apache#8542 (2026-09-15) |
| Usage removed by | Creator spec modules: apache#9522 (2026-11-22,
`refactor(frontend): share dataset and model resource UI`) moved both
specs to `createFormlyModalFixture`. Everything else: unused,
unreachable or redundant since introduction. |

As of 2026-11-24:
- The AsterixDB placeholders have been overwritten before any read for
over 5 years.
- The console-message fixtures have been unused for over 2 years.
- The `load-examples.sh` check has been unreachable for almost 9 months.
- The agent-service barrels have had no importer for the 7 months the
service has existed.
- The creator spec modules have been redundant for 2 days.

### Any related issues, documentation, discussions?

Closes apache#9685.

### How was this PR tested?

Ran on this branch and on `main` at `424b2a757a` (Windows 11; Python
3.12 with CI's pinned `ruff` 0.14.7; Node 24 with Yarn 4.14.1; Bun
1.3.13; JDK 17; the loader test in an Alpine container with Bash 5.2.21
and jq 1.7.1):

```bash
cd amber
ruff check src/main/python src/test/python
ruff format --check src/main/python src/test/python
pytest $(git diff --name-only --relative origin/main -- src/test/python)
cd ../agent-service
bun test
bun run typecheck
cd ../frontend
npx ng test --watch=false --include='**/user-dataset-creator.component.spec.ts' --include='**/user-model-creator.component.spec.ts' --include='**/admin-gmail.component.spec.ts'
npx tsc --noEmit -p src/tsconfig.spec.json
yarn prettier-eslint --list-different $(git diff --name-only --relative origin/main -- src)
yarn eslint $(git diff --name-only --relative origin/main -- src)
cd ..
sbt "WorkflowOperator/testOnly org.apache.texera.amber.operator.source.sql.*" WorkflowCore/Test/compile WorkflowOperator/scalafmtCheckAll WorkflowCore/scalafmtCheckAll "WorkflowOperator/scalafixAll --check" "WorkflowCore/scalafixAll --check"
bash bin/single-node/tests/test_load_examples_sh.sh
```

- **Python:**
  - Ruff passes on all 218 files.
- The 14 changed test files run 288 tests with the same outcome per test
on both sides: 218 pass, 67 are skipped and 3 fail.
- The three failures are timestamp cases in
`test_ui_parameter_contract.py` that expect UTC and come out 8 hours off
in this machine's time zone. They fail the same way on `main`.
- **Agent service:** all 361 tests in 20 files and the typecheck pass on
both sides.
- **Frontend:** the three specs run 37 tests, all passing on both sides.
The spec typecheck, prettier-eslint and ESLint pass.
- **Scala:** the 11 `source.sql` suites, including the three AsterixDB
specs, run 204 tests that all pass on both sides. WorkflowCore's tests
compile, and scalafmt and scalafix pass on both modules.
- **`load-examples.sh`:** `test_load_examples_sh.sh` passes all 11
checks. Against `main`'s loader, the 9 existing checks pass and the 2
new ones fail: `jq` exits 5 at the malformed file, and the loader stops
there without creating the other workflow.

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

Generated-by: Claude Code (Claude Opus 5.5)
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 AssignPortHandler

3 participants