tests: fix grpc topotest xdist collection mismatch in CI - #22048
Conversation
Greptile SummaryThis PR fixes intermittent pytest-xdist CI failures where workers collected
Confidence Score: 5/5Safe to merge β both changes are narrowly scoped to CI test infrastructure and do not touch any FRR daemon or production code. The subprocess-to-filesystem swap removes the sole source of non-determinism that caused xdist mismatches; file existence is evaluated identically on every worker. The analyze.py regex guard is correct and only skips entries that were previously causing downstream name-processing errors. No functional test logic was altered. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[pytest-xdist worker: collection phase] --> B{grpc / grpc_tools\nPython imports OK?}
B -- No --> C[pytest.skip: gRPC modules not installed\nallow_module_level=True]
B -- Yes --> D{_frr_grpc_module_available?\nglob grpc.so in system paths\n+ FRR_BUILD_DIR}
D -- No --> E[pytest.skip: FRR gRPC northbound\nmodule not installed\nallow_module_level=True]
D -- Yes --> F[Collect & run grpc_basic tests]
style C fill:#f88,stroke:#c00
style E fill:#f88,stroke:#c00
style F fill:#8f8,stroke:#080
Reviews (3): Last reviewed commit: "tests: skip grpc_basic when FRR gRPC mod..." | Re-trigger Greptile |
The runtime-vs-skip tradeoff is acceptable: CI Docker always builds with --enable-grpc, and a proto/protoc problem there should fail as a normal test error, not a per-worker collection skip that aborts the whole xdist run. For local runs without --enable-grpc: if grpcio/grpcio-tools arenβt installed, the module still skips via the import guard (unchanged since ea85c7c). The removed --check never verified the FRR build anyway β only Python proto generation. A deterministic skip based on GRPC_TRUE / grpc.so would be a nice follow-up for devs who have pip grpc but donβt enable gRPC in the build. If you have better ideas or code suggestions, let me know. |
|
The rationale is sound. The key insight is that Your analysis of the tradeoffs is correct:
The one gap you identified β a dev with pip-installed grpc but a non-grpc FRR build β is real but narrow. A clean follow-up would be to check for # tests/topotests/conftest.py
def pytest_ignore_collect(collection_path, config):
if "grpc_basic" in str(collection_path) and not _frr_built_with_grpc():
return Truewhere But that's genuinely a follow-up. The current fix correctly removes the per-worker non-determinism, and the tradeoff is well-reasoned. |
Follow-up to ea85c7c ("fix grpc_basic xdist collection mismatch"): that commit made missing grpc imports skip consistently, but the per-worker grpc-query --check subprocess could still fail on some xdist workers while others collected grpc_basic tests, aborting CI with "Different tests were collected". Rely on the import guard only; proto generation still runs when tests execute grpc-query. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
When parallel collection fails, xdist records errors named gw0, gw5, etc. analyze.py turned those into nonexistent gw5.py rerun targets. Skip worker ids so CI serial reruns only real topotest modules. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
|
@greptile review |
After dropping the collection-time grpc-query --check guard, CI always collected grpc_basic when Python grpc was installed, but grpc.s (frr-grpc) might not be installed. Zebra then failed to start with -M grpc and surfaced as a misleading mgmtd connection timeout. Skip the module when the northbound gRPC module is absent. Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
|
@greptile review |
|
@Mergifyio backport stable/10.6 |
β Backports have been createdDetails
Cherry-pick of 54429f5 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
tests: fix grpc topotest xdist collection mismatch in CI (backport #22048)
Fix intermittent CI topotest failures where pytest-xdist aborts with Different tests were collected between gw0 and gw5 because grpc_basic was collected on some workers but module-skipped on others.
Example CI failure here