Skip to content

test: replace always-true assert with issubclass check in test_installer_class_available#1979

Open
hognek wants to merge 3 commits into
jaylfc:devfrom
hognek:fix/lxc-port-allocator-695
Open

test: replace always-true assert with issubclass check in test_installer_class_available#1979
hognek wants to merge 3 commits into
jaylfc:devfrom
hognek:fix/lxc-port-allocator-695

Conversation

@hognek

@hognek hognek commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Kilo suggestion on merged PR #1964: assert LXCInstaller is not None is always true at module scope and cannot detect the import-error regression the docstring claims.

Fix: Replace with assert issubclass(LXCInstaller, AppInstaller) — a meaningful class-hierarchy regression check.

  • Added AppInstaller import from tinyagentos.installers.base
  • Changed assertion from identity check to subclass check
  • Updated docstring

Tests: 16/16 pass in test_port_allocator.py


Summary by Gitar

  • Test Suite Refactoring:
    • Added TestLxcUsesCentralizedAllocator to enforce that LXCInstaller uses the centralized port allocator.
    • Verified lxc_installer module no longer exposes _find_free_port or RESERVED_PORTS.

This will update automatically on new commits.

Summary by CodeRabbit

  • Bug Fixes

    • Improved LXC installation port allocation and retry handling when ports are unavailable.
    • Prevented repeated attempts to use ports that previously failed.
  • Documentation

    • Clarified how container and host ports are mapped during installation.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@hognek, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 34 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d6a83287-d11e-42ee-a66a-cf9015641ca5

📥 Commits

Reviewing files that changed from the base of the PR and between 3ca6aa9 and dc1c8ae.

📒 Files selected for processing (1)
  • tests/installers/test_port_allocator.py
📝 Walkthrough

Walkthrough

LXCInstaller now uses the shared allocate_host_port helper, tracks failed ports across retries, and removes its local port finder. Tests patch the shared allocator, while _docker_published_port documentation is corrected.

Changes

LXC port allocation

Layer / File(s) Summary
Centralized allocator and retry handling
tinyagentos/installers/lxc_installer.py, tinyagentos/routes/store_install.py
LXCInstaller delegates host-port selection to allocate_host_port, excludes ports that fail with address-in-use errors, and documents Docker container-port mapping accurately.
Allocator integration tests
tests/installers/test_port_allocator.py, tests/test_lxc_installer.py
Regression tests verify the centralized allocator structure and update normal and restore-mode mocks to target allocate_host_port.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related issues

Possibly related PRs

  • jaylfc/taOS#1964 — Covers corresponding LXCInstaller allocator integration and test updates.
  • jaylfc/taOS#696 — Also changes host-port allocation constraints in lxc_installer.py.

Suggested reviewers: jaylfc

Sequence Diagram(s)

sequenceDiagram
  participant LXCInstaller
  participant allocate_host_port
  participant LXCProxyDevice
  LXCInstaller->>allocate_host_port: Request an available host port
  allocate_host_port-->>LXCInstaller: Return host port
  LXCInstaller->>LXCProxyDevice: Create proxy device
  LXCProxyDevice-->>LXCInstaller: Report address-in-use failure
  LXCInstaller->>allocate_host_port: Retry while excluding failed ports
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is specific and correctly describes a real test change in the PR, though it covers only one part of the broader update.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hognek
hognek marked this pull request as ready for review July 18, 2026 08:09
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@gitar-bot

gitar-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

Gitar is working

Gitar

@kilo-code-bot

kilo-code-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Verified current HEAD (dc1c8ae) of PR #1979. The change replaces the always-true assert LXCInstaller is not None with assert issubclass(LXCInstaller, AppInstaller) and adds the AppInstaller import from tinyagentos.installers.base. This correctly implements the prior Kilo suggestion — a meaningful class-hierarchy regression check. Import placement is correct, and issubclass receives a class (import would have already failed via ImportError otherwise).

Files Reviewed (1 file)
  • tests/installers/test_port_allocator.py - 0 issues

Reviewed by hy3:free · Input: 37.9K · Output: 2.9K · Cached: 167K

@jaylfc

jaylfc commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Good catch folding the post-merge Kilo nit on #1964. The branch is CONFLICTING against dev though - please rebase onto origin/dev and I'll merge once green.

hognek added 3 commits July 20, 2026 03:09
Replace the standalone _find_free_port() in lxc_installer.py with
allocate_host_port(app_id) from port_allocator.py so the centralized
allocator is the single source of truth for all app host-port
assignments.

- Remove _find_free_port(), socket, and closing imports from lxc_installer
- Import allocate_host_port instead of RESERVED_PORTS
- Accumulate failed ports in exclude set across TOCTOU retry loop
- Fix stale _docker_published_port docstring (DockerInstaller now
  maps {allocated_host_port}:{container_port}, not {p}:{p})
- Add test class verifying _find_free_port is gone and
  allocate_host_port is the only import

Refs: jaylfc#695
Add assert not hasattr(mod, 'RESERVED_PORTS') to verify the old import
is truly removed, not just that allocate_host_port is present.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants