Repository navigation
Conversation
bjesterbot
left a comment
There was a problem hiding this comment.
Patching uuid.getnode, ifcfg.interfaces, and InstanceIDModel._cached_instance before setUp fixes the 8 listed test failures when MORANGO_SYSTEM_ID and MORANGO_NODE_ID are unset, but this PR cannot close #413 as written because three of #413's deliverables remain unmet and several neighboring tests still break or lose coverage.
- 🚨 Key Blockers:
- Merging with
Fixes #413leaves three#413deliverables unmet, including shell environment isolation (MORANGO_SYSTEM_ID=new_sys_idfails 7 of the 8 tests in both original andFakeMacmodes, andMORANGO_NODE_IDstill breakstest_consistent_0_5_instance_id), suite-wide host identity regression safety, and a test recording the intended MAC-less 0.4 lookup behavior (tests/testapp/tests/helpers.py). RecordMaxCounterUpdatesDuringSerialization.test_new_rmc_for_existing_modelhits the same MAC-less fallback (new_id.id == self.current_id.id) and updatesself.old_rmcin place instead of creating a secondRecordMaxCounter, but was omitted fromRecordMaxCounterUpdatesDuringSerializationFakeMacTestCase(tests/testapp/tests/sync/test_controller.py).
- Merging with
- Inline Comments: 2 🚨 Blockers, 1
⚠️ Architecture & Design, 1 🧹 Nit - ✅ Positive Highlight:
use_fake_mac_address(tests/testapp/tests/helpers.py) identifies and resets all three host-identity channels (uuid.getnodefor 0.4 lookups,ifcfg.interfacesfor 0.5 lookups, andInstanceIDModel._cached_instanceacross tests) prior tosetUp.
Verification Status
- Simulated no-MAC (
MORANGO_SYSTEM_IDandMORANGO_NODE_IDunset):201 passed, 8 skippedacross the 4 modified test modules (python -O -m pytest) - Simulated real-MAC (
MORANGO_SYSTEM_IDandMORANGO_NODE_IDunset):201 passed, 8 skippedacross the 4 modified test modules - Shell environment sensitivity check:
7 failedwithMORANGO_SYSTEM_ID=new_sys_id(under both no-MAC and real-MAC plugins) and1 failed(test_consistent_0_5_instance_id) withMORANGO_NODE_IDset - Lint & formatting: Passing (
uv run prek run --all-files) - CI note: Postgres CI failure on Ubuntu 26.04 is an unrelated
M2CryptoSWIG build failure addressed in #423
Generated by Antigravity using model Gemini 4 Carbon
On a host where Morango cannot read a MAC address, the 0.4 and 0.5 node IDs are both empty. The legacy lookup in get_or_create_current_instance then keeps the current instance after MORANGO_SYSTEM_ID changes, and 8 tests that expect a new instance fail. The test helpers now detect this condition once. On such a host, the 8 original tests are skipped, and copies of them run with a fake MAC address that is applied in setUp. On a host with a readable MAC address, the originals run against the real host and the copies are skipped. Fixes learningequality#413 The copies repeated each test body, and on hosts with a MAC address they were skipped, so edits to an original could drift from its copy without any local failure. The with_readable_mac class decorator wraps setUp instead. On a host without a node ID, it patches in the fake MAC address before the setUp of the class runs. On other hosts, it returns the class unchanged, so the tests still run against the real host identity. The decorator applies to every test in the 6 affected classes. This also covers tests that passed on hosts without a MAC address only because they did not check for a new instance, such as the queue tests that use create_dummy_store_data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1ca7e68 to
f98fecf
Compare
On a host without a node ID, the system ID change in this test returned the same instance. The test still passed, because serialization updated the existing RecordMaxCounter in place and the test only compared that counter with the store record. The test now checks that the instance changed and that the facility has a second RecordMaxCounter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bjesterbot
left a comment
There was a problem hiding this comment.
All four findings from the initial review are resolved, and the @with_readable_mac class decorator cleanly satisfies the updated #413 deliverables without duplicating test classes.
- Prior Findings: 4/4
RESOLVED#413scope & deliverables (tests/testapp/tests/helpers.py):RESOLVEDvia updated#413deliverables and@with_readable_mac.test_new_rmc_for_existing_model(tests/testapp/tests/sync/test_controller.py):RESOLVEDinc8b3984by assertingnew_id.id != self.current_id.idandcount() == 2under@with_readable_mac.create_dummy_store_data()fixture collapse & duplicate classes (tests/testapp/tests/sync/test_operations.py):RESOLVEDinf98fecfby decorating the 6TestCaseclasses directly so all 25 queue tests receive distinctgroup1_idandgroup2_idinstances.- Decorator drift in
test_instance_id_caching(tests/testapp/tests/test_uuid_utilities.py):RESOLVEDinf98fecfby removing the duplicate class.
- ✅ Positive Highlight: Wrapping
cls.setUpinwith_readable_mac(tests/testapp/tests/helpers.py) keeps a single copy of each test class, preserves LIFO cleanup ordering with method-level@mock.patchdecorators viaself.addCleanup(patcher.stop), and leaves execution untouched on hosts with a readable MAC address. - 🧹 Commit Message Note (Optional): If merging without squashing, commit
f98fecf's message body still contains the earlier paragraph describing skipped originals and copies alongside the updatedwith_readable_macdescription.
Verification Status
- Simulated no-MAC (
MORANGO_SYSTEM_IDandMORANGO_NODE_IDunset):54 passedacross all 6 decorated test classes (python -O -m pytest -p no_mac) - Simulated real-MAC (
MORANGO_SYSTEM_IDandMORANGO_NODE_IDunset):54 passedacross all 6 decorated test classes (python -O -m pytest -p real_mac) - Lint & formatting: Passing (
uv run prek run --all-files)
Generated by Antigravity using model Gemini 4 Carbon
marcellamaki
left a comment
There was a problem hiding this comment.
I'm not sure my review really adds much here (as I certainly would have not had any comments similar to the pre-me bot review) but I did locally reproduce the steps in the reviewer guidance with some help from claude, and do a code read through and the commit message read through and it all makes sense to me. Since :bot: review says it's okay and I say it's "followable" and it only is changing tests... ![]()
Summary
Eight instance ID tests fail on hosts where Morango cannot read a MAC address. Each test changes
MORANGO_SYSTEM_IDand expects a new instance, butget_or_create_current_instancereturns the existing one. On such a host, the 0.4 and 0.5 node IDs are both empty, so the legacy 0.4 lookup matches the instance thatsetUpcreated. Some CI runners have no readable MAC address, so the tests pass and fail between runs on the same commit.This PR changes only tests:
get_0_5_mac_address()returns a node ID for the host.with_readable_mac, goes on the 6 test classes that contain the failing tests.setUpof the class runs. All tests in the class then run with the fake MAC address.The patches start before
setUp, not on the test method. Otherwise the instance fromsetUpkeeps the real host identity, and a test can pass because the MAC address changed, not becauseMORANGO_SYSTEM_IDchanged.I chose this over a fake MAC address for the whole suite, because the tests then still cover real hosts that have a MAC address. Production code does not change, so the instance ID behavior on hosts without a MAC address stays as it is.
A second commit adds two assertions to
test_new_rmc_for_existing_model. On a host without a node ID, that test passed even though the instance did not change. It now checks that the instance changed and that the facility has a secondRecordMaxCounter.TODO
Reviewer guidance
To reproduce, unset
MORANGO_SYSTEM_IDandMORANGO_NODE_ID, then use theno_macpytest plugin from #413. A second plugin that returns a real MAC address (00:11:22:33:44:55) simulates the other case.Results for the 4 changed test modules:
test_new_rmc_for_existing_modelOther checks:
PermissionErrorin the sync and integrationtest_syncsession.pymodules, caused by the local sandbox. The sync module had the same 31 errors before this change.prekhooks pass.Points to check:
HOST_HAS_READABLE_MACis also true whenMORANGO_NODE_IDis set, becauseget_0_5_mac_address()uses that variable first. In that case the decorator changes nothing and the tests pass against the real host.create_dummy_store_data()now get two separate instances on hosts without a MAC address.test_consistent_0_5_instance_idwhenMORANGO_NODE_IDis set. The tests also do not clearMORANGO_SYSTEM_IDorMORANGO_NODE_IDfrom the shell environment.Issues addressed
Fixes #413
Documentation
N/A
AI usage
I used Claude Code for this change. I rejected two earlier attempts at #413, then directed the design: detect the condition, and use a fake MAC address only on hosts without one. The first version copied the failing tests into separate classes. After review, I asked for a way to avoid the copies, and Claude Code replaced them with the class decorator. Claude Code wrote the helper, reproduced the failures with the plugin from #413, and ran the host checks above. It also confirmed that the tests fail with the decorator turned off. Claude Code also drafted this description.
🤖 Generated with Claude Code