Skip to content

test: delete tests a stronger sibling already covers - #4185

Merged
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-4180
Jul 27, 2026
Merged

test: delete tests a stronger sibling already covers#4185
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-4180

Conversation

@chet

@chet chet commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

The audit behind #3914 flagged something like 11,000 lines of duplicated tests. I went to delete them and found the audit was mostly wrong -- it had counted tests that look alike as tests that cover alike. So this is the ~3,700 lines I could actually prove, each one checked against the specific surviving test that still covers it.

The clearest example of why the gap is so wide: libmlx has six tests/ files that mirror inline #[cfg(test)] modules, and the audit wanted all six gone. They aren't duplicates -- value.rs says so in its own comments ("the array variants are already covered by the sibling tests/ file", "the spec branches not in the sibling file"). The two halves were split deliberately. Deleting them would have taken out the only test of Display for LockStatus, the only tests of is_array_type and get_set_indices (both live in production in runner.rs), and the only coverage of IntoMlxValue for Vec<String>, which is how we parse mlxconfig --json arrays. Not one of those files went away whole.

What did go:

  • dpf/duplicate_events.rs, entirely. Its setup is byte-identical to waiting_for_ready.rs, and the survivor is stronger -- it asserts ForceOff == 1, runs five more iterations, then asserts == 0. Its module doc was also false: it claims to test watcher event dedup and never touches DpuWatcher or the ON CONFLICT DO NOTHING that actually dedupes.
  • Three narrow NMX tests in the rack handler, subsumed by the e2e below them, which runs the same assertions under a harder two-switch fixture.
  • nvue_startup_with_bridge.yaml.expected and its test. diff against nvue_startup.yaml.expected is empty and both tests pass identical arguments, so a bridge regression needed both goldens updated before anything failed.
  • Two "set the state with raw SQL, read it back" tests that run no controller and no handler, and pay for a template database to round-trip serde.
  • Six of seven mqttea trait tests that dispatch to a handler defined in the test file itself and assert on its own atomics.

Three changes in here aren't deletions. test_expected_no_definition_stays_parked was handing the handler a known rack profile, so it waited for the wrong reason and left the unresolved-profile branch uncovered -- it passes None now, and matches on the wait reason rather than just the variant, since the device-count branch also returns Wait. test_spec.rs had a bare matches!(spec, MlxVariableSpec::Boolean); with the result thrown away, the same class #4173 swept out. And the surviving nvue test now says that it is the bridge case, so nobody re-adds one that isn't.

Related issues

This supports #4180

Type of Change

  • Add - New feature or capability
  • Change - Changes in existing functionality
  • Fix - Bug fixes
  • Remove - Removed features or deprecated functionality
  • Internal - Internal changes (refactoring, tests, docs, etc.)

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

Function-level coverage A/B against main over the eight touched crates. Line coverage is the wrong instrument for a deletion -- removing test lines makes the percentage rise on its own, and --ignore-filename-regex can't reach inside an inline #[cfg(test)] module. So the question asked here is narrower: did any production function go from executed to never-executed?

production functions -- base 31324, after 27843
covered              -- base 15428, after 15414
RESULT: PASS -- no production function lost its coverage
  • 1,444 api-core tests green (down from 1,454 -- exactly the ten removed), 0 failures across all eight crates.
  • Covered drops by exactly 14, matching the 14 reported as gone from the build. All 14 are generic instantiations that existed only for deleted tests -- register_raw_message::<DogMessage>, check_values::<...>. The generics themselves stay covered through other instantiations: check_values 251/252, Check::check 253/254.
  • The repurposed rack test was mutation-checked: hand it a known profile and it fails with left: "waiting for devices: compute=0/2, ..." against right: "no or unknown rack_profile_id". The old bare Wait { .. } assertion passed in that state.

Additional Notes

Reviewer guidance -- the two places I'd look hardest:

  • libmlx trims. Six files, none deleted whole. Everything kept is kept for a stated reason: YAML on-disk schema contracts (grep serde_yaml src/variables/{registry,spec}.rs returns nothing, so only the mirrors pin the registry file format), log_json_output = true, LockdownManager::with_dry_run, the non-dry-run error path, and three cases where the mirror pinned an exact error variant while the inline twin asserted a bare is_err().
  • handler.rs. 362 lines of NMX tests removed on the claim that one e2e covers all three, plus one of the three near-identical Created tests. I kept test_expected_incomplete_device_counts_stays as the honest counts-shortfall case and repurposed the other.

One I deliberately left in: libmlx's test_malformed_json. It's subsumed at equal strength, which is the weakest justification for removal there is, so it stays.

crates/rpc/src/model/hardware_info.rs is untouched here on purpose. Removing its projection layer is a rewrite that makes the tests stronger rather than a deletion, so it belongs with the table-test work rather than in this PR.

Closes #4180

The audit behind NVIDIA#3914 flagged something like 11,000 lines of duplicated tests. I went to delete them and found the audit was mostly wrong -- it had counted tests that *look* alike as tests that *cover* alike. So this is the ~3,700 lines I could actually prove, each one checked against the specific surviving test that still covers it.

The clearest example of why the gap is so wide: `libmlx` has six `tests/` files that mirror inline `#[cfg(test)]` modules, and the audit wanted all six gone. They aren't duplicates -- `value.rs` says so in its own comments (*"the array variants are already covered by the sibling tests/ file"*, *"the spec branches **not** in the sibling file"*). The two halves were split deliberately. Deleting them would have taken out the only test of `Display for LockStatus`, the only tests of `is_array_type` and `get_set_indices` (both live in production in `runner.rs`), and the only coverage of `IntoMlxValue for Vec<String>`, which is how we parse mlxconfig `--json` arrays. Those files lost about half of what was claimed, and not one of them went away whole.

Primary callouts are:

- `dpf/duplicate_events.rs` goes entirely. Its setup is byte-identical to `waiting_for_ready.rs`, and the survivor is stronger -- it asserts `ForceOff == 1`, runs five more iterations, then asserts `== 0`, which bounds the over-run the deleted file was reaching for. The file's own module doc was also false: it claims to test watcher event dedup and never touches `DpuWatcher` or the `ON CONFLICT DO NOTHING` that actually does the deduping.
- Three narrow NMX tests in the rack handler, subsumed by the e2e below them, which runs the same assertions under a harder two-switch fixture and additionally cross-checks that the cert step's in-memory primary agrees with the configure step's persisted one.
- `nvue_startup_with_bridge.yaml.expected` and the test that read it. `diff` against `nvue_startup.yaml.expected` is empty and both tests pass identical arguments -- so a bridge regression needed *both* goldens updated before anything failed. The surviving test is the bridge case; there's a note on it now saying so.
- Two "set the state with raw SQL, read it back" tests that run no controller and no handler, and pay for a template database to round-trip serde.
- Six of seven `mqttea` trait tests that dispatch to a handler defined in the test file itself and assert on its own atomics.

Three things in here aren't deletions. `test_expected_no_definition_stays_parked` was handing the handler a *known* rack profile, so it waited for the wrong reason and left the unresolved-profile branch uncovered -- it passes `None` now and matches on the wait reason, not just the variant, since the device-count branch also returns `Wait`. `test_spec.rs` had a bare `matches!(spec, MlxVariableSpec::Boolean);` with the result thrown away, which is the same class NVIDIA#4173 just swept out. And the surviving nvue test now explains that it *is* the bridge case, so nobody re-adds one that isn't.

Proven with a function-level coverage A/B over the eight touched crates: 1,444 `api-core` tests green, and **no production function lost its coverage**. Fourteen entries drop out of the build, all of them generic instantiations that existed only for deleted tests (`register_raw_message::<DogMessage>`, `check_values::<...>`); the generics themselves stay covered 251/252 and 253/254 through other instantiations.

Tests updated!

This supports NVIDIA#4180

Signed-off-by: Chet Nichols III <chetn@nvidia.com>
@chet
chet requested a review from a team as a code owner July 27, 2026 02:40
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6f1f6942-cf17-4014-8b31-54588957ebc8

📥 Commits

Reviewing files that changed from the base of the PR and between b9c43b2 and ee52988.

📒 Files selected for processing (20)
  • crates/agent/src/ethernet_virtualization.rs
  • crates/agent/templates/tests/nvue_startup_with_bridge.yaml.expected
  • crates/api-core/src/tests/dpf/duplicate_events.rs
  • crates/api-core/src/tests/dpf/mod.rs
  • crates/api-core/src/tests/power_shelf_state_controller/mod.rs
  • crates/api-core/src/tests/rack_state_controller/handler.rs
  • crates/api-core/src/tests/switch_state_controller/mod.rs
  • crates/api-db/src/resource_pool.rs
  • crates/api-model/src/machine_validation.rs
  • crates/bmc-proxy/src/bmc_proxy.rs
  • crates/ipxe-renderer/src/lib.rs
  • crates/libmlx/tests/lockdown/test_lockdown.rs
  • crates/libmlx/tests/profile/test_serialization.rs
  • crates/libmlx/tests/runner/common/mod.rs
  • crates/libmlx/tests/runner/json_parser_tests.rs
  • crates/libmlx/tests/runner/result_types_tests.rs
  • crates/libmlx/tests/variables/test_registry.rs
  • crates/libmlx/tests/variables/test_spec.rs
  • crates/mqttea/tests/stats.rs
  • crates/mqttea/tests/traits.rs
💤 Files with no reviewable changes (13)
  • crates/api-core/src/tests/dpf/mod.rs
  • crates/agent/templates/tests/nvue_startup_with_bridge.yaml.expected
  • crates/api-core/src/tests/dpf/duplicate_events.rs
  • crates/libmlx/tests/lockdown/test_lockdown.rs
  • crates/ipxe-renderer/src/lib.rs
  • crates/libmlx/tests/runner/common/mod.rs
  • crates/bmc-proxy/src/bmc_proxy.rs
  • crates/api-model/src/machine_validation.rs
  • crates/mqttea/tests/traits.rs
  • crates/api-db/src/resource_pool.rs
  • crates/libmlx/tests/profile/test_serialization.rs
  • crates/libmlx/tests/runner/json_parser_tests.rs
  • crates/mqttea/tests/stats.rs

Summary by CodeRabbit

  • Tests
    • Improved and refocused metrics coverage for queue, publish, connection-state, and client instrumentation registration.
    • Strengthened validation of rack “Created” wait behavior when rack profile resolution is unavailable.
    • Consolidated forwarded-header parsing checks into clearer parameterized scenarios.
    • Simplified NVUE bridge vs non-bridge expectations so a single scenario validates shared outcomes.
    • Removed redundant or outdated test cases across networking, device/power/rack/switch state controllers, and parsing/serialization suites.
  • Documentation
    • Added explanatory guidance in NVUE test expectations to clarify shared configuration behavior.

Walkthrough

The change audits test coverage across agent, API, libmlx, and mqttea modules. Redundant tests and fixtures are removed, equivalent cases are consolidated, rack wait assertions are strengthened, and metrics-registration coverage is added.

Changes

Test suite audit

Layer / File(s) Summary
Controller and virtualization test updates
crates/agent/src/..., crates/api-core/src/tests/...
Bridge coverage is documented through shared golden expectations; redundant controller-state tests are removed; rack tests assert the specific wait reason.
Focused unit-test consolidation
crates/api-db/..., crates/api-model/..., crates/bmc-proxy/..., crates/ipxe-renderer/...
Redundant IPv6, validation, and rendering tests are removed, while forwarded-header cases are consolidated into a table-driven test.
libmlx test coverage reshaping
crates/libmlx/tests/profile/..., crates/libmlx/tests/runner/..., crates/libmlx/tests/variables/...
Profile, runner, registry, and variable-spec coverage is narrowed toward retained serialization and YAML scenarios; the boolean YAML check now asserts its result.
mqttea metrics and handler tests
crates/mqttea/tests/...
Metrics-registration tests are added for trackers and clients, while dog-message fixtures and related scenarios are removed.

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

Possibly related issues

  • NVIDIA/infra-controller#4180 — The changes implement the test-audit objective by removing redundant coverage and consolidating retained tests.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: removing tests already covered by stronger surviving tests.
Description check ✅ Passed The description is directly related to the test-removal and test-update changes in the pull request.
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

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

@chet

chet commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

@chet, I’ve triggered a full re-review of the PR, including the test-deletion rationale and coverage-preservation claims.

🐇🔍

✅ Action performed

Full review finished.

@chet
chet enabled auto-merge (squash) July 27, 2026 04:15
@chet
chet merged commit a764ca3 into NVIDIA:main Jul 27, 2026
61 checks passed
@chet
chet deleted the gh-issue-4180 branch July 27, 2026 04:39
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.

Remove Tests Subsumed By Stronger Siblings

2 participants