test(api-model,rpc,uuid): collapse per-variant clusters and drop redundant tests#2713
Conversation
…ndant tests `api-model`'s `is_power_shelf` gains one `value_scenarios!` table in place of five per-input functions, and `build_version`'s standalone `partial_cmp` check folds into the ordering table -- which now asserts `partial_cmp == Some(cmp)` on every row, a touch stronger than the old three-case spot-check. Three tests that only exercised a derive or the stdlib go: the `Display`-equals-`Debug` check (it can't fail, since `Display` is defined as `Debug::fmt`), the `AssignStaticResult` `PartialEq`-derive table, and two `IpAddr` formatting tests. `rpc` drops two `identity_config_try_from_proto` tests that duplicated exact rows of the existing error-case table. `uuid` merges `RackId` and `RackProfileId`'s parallel parse and serde tests behind a small generic helper and removes two tautological transparent-newtype conversion tests (`as_str` == `to_string` == `as_ref`). Around 340 fewer test lines, no production change. Verified per crate (api-model 320, rpc 10, uuid `rack` 2) and clippy-clean. Signed-off-by: Chet Nichols III <chetn@nvidia.com>
|
@coderabbitai PTAL, thanks! |
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Summary by CodeRabbit
WalkthroughThis PR cleans up test suites across ChangesTest Suite Cleanup and Consolidation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
gh pr view 2713 --repo NVIDIA/infra-controller --json title,body,files,additions,deletions,commits
echo "--- DIFF ---"
gh pr diff 2713 --repo NVIDIA/infra-controllerLength of output: 29896
Strengths
Minor observation (non-blocking)
Verdict No correctness or coverage concerns. The production logic is untouched, and the stated test counts ( |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/uuid/src/rack/mod.rs (1)
354-368: 💤 Low valueConsider inline markers for consecutive scenario blocks.
The two
scenarios!blocks (RackId at line 331, RackProfileId at line 356) are separated only by blank lines. A one-line comment marker (e.g.,// RackProfileId) would immediately clarify which block exercises which type without requiring readers to inspect type parameters.This is a minor readability suggestion and entirely optional.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/uuid/src/rack/mod.rs` around lines 354 - 368, The consecutive scenarios! blocks for RackId and RackProfileId lack clear inline markers that indicate which block tests which type. Add a single-line comment marker (e.g., `// RackProfileId`) immediately before the scenarios! macro invocation that tests parse_as::<RackProfileId> to improve code readability and make it immediately clear which type each scenario block exercises without requiring readers to inspect the type parameters.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/uuid/src/rack/mod.rs`:
- Around line 354-368: The consecutive scenarios! blocks for RackId and
RackProfileId lack clear inline markers that indicate which block tests which
type. Add a single-line comment marker (e.g., `// RackProfileId`) immediately
before the scenarios! macro invocation that tests parse_as::<RackProfileId> to
improve code readability and make it immediately clear which type each scenario
block exercises without requiring readers to inspect the type parameters.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 923189c3-ea25-4d86-a505-28927614e7bd
📒 Files selected for processing (7)
crates/api-model/src/allocation_type.rscrates/api-model/src/controller_outcome.rscrates/api-model/src/machine/network.rscrates/api-model/src/machine/upgrade_policy.rscrates/api-model/src/site_explorer/mod.rscrates/rpc/src/model/tenant.rscrates/uuid/src/rack/mod.rs
💤 Files with no reviewable changes (3)
- crates/api-model/src/controller_outcome.rs
- crates/rpc/src/model/tenant.rs
- crates/api-model/src/machine/network.rs
🔍 Container Scan Summary
Per-CVE detail lives in the per-service |
Wave 1 of the carbide-test-support integration (#2692).
api-model:is_power_shelf's five per-input tests → onevalue_scenarios!table;build_version'spartial_cmpcheck folds into the ordering table (now assertspartial_cmp == Some(cmp)per row); drops theDisplay-equals-Debugcheck (can't fail), theAssignStaticResultPartialEq-derive table, and twoIpAddrstdlib-formatting tests.rpc: drops twoidentity_config_try_from_prototests that duplicated exact rows of the existing error-case table.uuid: mergesRackId/RackProfileIdparse + serde tests behind a generic helper; drops two tautological transparent-newtype conversion tests.~340 fewer test lines, no production change. Verified per crate (
cargo test: api-model 320, rpc 10, uuidrack2), clippy-clean.Two items from #2692's plan intentionally left as-is, on review:
MachineCapability*conversion tests separate rather than collapsing them into one table -- they are distinct type-pairFromconversions (not duplicates), and a single table would require type erasure that erases the per-field "which field mismapped" failure diagnostic.test_db_column_name-- it guards each type'sDB_COLUMN_NAME, which feeds production DB queries viadb_primary_uuid_name()(api-db), so it is not a pure tautology.Addresses #2695.