Skip to content

test: convert the mechanical tables and finish the silent-test sweep - #4230

Merged
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-4224
Jul 28, 2026
Merged

test: convert the mechanical tables and finish the silent-test sweep#4230
chet merged 1 commit into
NVIDIA:mainfrom
chet:gh-issue-4224

Conversation

@chet

@chet chet commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

carbide-test-support gives us two ways to write a table test -- the explicit Case{}/Check{} array and the scenarios!/value_scenarios! macros -- and the macro form is roughly a third of the lines per row. Where the row's input reads as well as its hand-written label, the explicit form is just ceremony, and three of the label-mapping tables here were exactly that: a FirmwareComponentType or a MethodLabel on one side, its snake_case string on the other.

The narrowness is the point, though. scenarios! builds its label as concat!(group, " / ", stringify!(input)), so a row whose input is a multi-field struct comes back with the whole literal as its label -- worse than the prose it replaced. Of the 1,839 explicit rows in the tree, 658 are that case and another 756 have a label saying something the input never will ("punctuation is normalized" is not derivable from "a,b"). Only about 360 are safe to move, and past the handful converted here they thin out to two or three per file. I left the rest alone rather than churn 70-odd files for the tail.

  • Three label tables collapse: power_operation_label_covers_every_system_power_control (52 lines to 19), firmware_component_label_renders_snake_case (62 to 20), and label_values_render_as_snake_case in bmc-proxy (77 to 27). Same rows, same assertions, same order -- and stringify! gives a better label here than the prose did, since PowerOperation::from(SystemPowerControl::GracefulShutdown) says more than "graceful shutdown".
  • The three dpf/sdk.rs tests left over from Add Missing Assertions To Silent Tests #4190 now assert something. All three drive the branch where an existing, non-terminating resource is deliberately left alone, and all three checked only that no error came back -- so a call that quietly created a duplicate would have passed. They now assert the mock still holds exactly one device, node, or flavor. create_dpu_flavor also returns the existing name, which is the whole idempotent-reuse contract and was being discarded.

Related issues

This supports #4224

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 over preingestion-manager, bmc-proxy and dpf, baselined on the same 06495cda5 this branch sits on:

production functions -- base 30075, after 22848
covered              -- base 1748, after 1748
RESULT: PASS -- no production function lost its coverage

Exactly flat, which is the result you want from a conversion -- the rows and their assertions are unchanged, only how they're written is. The dpf half tightens assertions on paths already being executed, so it doesn't move the function-level number either. All suites green.

Lint gate green (format-nightly, clippy, carbide-lints), no Cargo.lock drift.

Additional Notes

For anyone converting more of these later: label_value() returns opentelemetry::StringValue, and the explicit form was inferring that through check_values. The macro form needs it spelled out on the run = closure, and the import added.

This is the last of the five PRs under #3914. Worth recording that the audit driving that epic was directionally useful and numerically unreliable throughout -- it claimed ~11,000 lines of duplicate tests (3,713 were real), 119 silent tests (44 were real), and ~6,500 lines of collapsible table rows (about 360 rows were genuinely safe). Every PR in the series re-verified its candidates against main before touching them, and the coverage A/B was the gate throughout.

Closes #4224

`carbide-test-support` gives us two ways to write a table test -- the explicit `Case{}`/`Check{}` array and the `scenarios!`/`value_scenarios!` macros -- and the macro form is roughly a third of the lines per row. Where the row's input reads as well as its hand-written label, the explicit form is just ceremony, and three of the label-mapping tables here were exactly that: a `FirmwareComponentType` or a `MethodLabel` on one side, its snake_case string on the other.

The narrowness is the point, though. `scenarios!` builds its label as `concat!(group, " / ", stringify!(input))`, so a row whose input is a multi-field struct comes back with the whole literal as its label -- worse than the prose it replaced. Of the 1,839 explicit rows in the tree, 658 are that case and another 756 have a label saying something the input never will (`"punctuation is normalized"` is not derivable from `"a,b"`). Only about 360 are safe to move, and they thin out to two or three per file after the handful converted here. I left the rest alone.

Primary callouts are:

- Three label tables collapse: `power_operation_label_covers_every_system_power_control` (52 lines to 19), `firmware_component_label_renders_snake_case` (62 to 20), and `label_values_render_as_snake_case` in `bmc-proxy` (77 to 27). Same rows, same assertions, same order -- and `stringify!` gives a *better* label here than the prose did, since `PowerOperation::from(SystemPowerControl::GracefulShutdown)` says more than "graceful shutdown".
- The three `dpf/sdk.rs` tests left over from NVIDIA#4190 now assert something. All three drive the branch where an existing, non-terminating resource is deliberately left alone -- and all three checked only that no error came back, so a call that quietly created a duplicate would have passed. They now assert the mock still holds exactly one device, node, or flavor. `create_dpu_flavor` also returns the existing name, which is the whole idempotent-reuse contract and was being discarded.

Coverage A/B over `preingestion-manager`, `bmc-proxy` and `dpf`, baselined on the same `06495cda5` this branch sits on: **1,748 production functions covered before and after, exactly flat**, with every test still passing. That's the result you want from a conversion -- the rows and their assertions are unchanged, only how they're written is. The `dpf` half tightens assertions on paths that were already being executed, so it doesn't move the function-level number either.

Worth noting for anyone converting more of these: `label_value()` returns `opentelemetry::StringValue`, and the explicit form was inferring that through `check_values`. The macro form needs it spelled out on the `run =` closure.

Tests updated!

This supports NVIDIA#4224

Signed-off-by: Chet Nichols III <chetn@nvidia.com>
@chet
chet requested a review from a team as a code owner July 28, 2026 06:34
@chet

chet commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full_review, thanks!

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

@chet, I’ll perform a complete re-review of #4230, including the table-test conversions and the strengthened dpf/sdk.rs idempotency assertions.

🐇

✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • Bug Fixes

    • Strengthened idempotency behavior by ensuring reuse of existing device, node, and flavor resources does not create duplicates.
  • Tests

    • Improved metric label validation by refactoring label-rendering checks into scenario-driven assertions.
    • Added explicit coverage for snake_case label rendering across authorization, method, status, power, and firmware components.

Walkthrough

The changes modernize metric label tests with value_scenarios! and strengthen DPF SDK tests by asserting existing non-terminating resources are reused without duplicate creation.

Changes

Metric label test modernization

Layer / File(s) Summary
Scenario-based label assertions
crates/bmc-proxy/src/metrics.rs, crates/preingestion-manager/src/metrics.rs
Label tests use value_scenarios! to verify snake_case output across authorization, proxy, power, status, and firmware label variants.

DPF SDK reuse-path assertions

Layer / File(s) Summary
Existing-resource no-op assertions
crates/dpf/src/sdk.rs
Tests verify that existing non-terminating DPU devices, nodes, and flavors are returned or reused without increasing mock store sizes.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the PR’s main theme: converting table tests and tightening test assertions.
Description check ✅ Passed The description is directly related to the changeset and explains the test conversions and idempotency assertions.
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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@crates/dpf/src/sdk.rs`:
- Around line 3374-3378: Update the no-op reuse tests to observe repository
create calls rather than relying only on final collection sizes: at
crates/dpf/src/sdk.rs lines 3374-3378, record and assert zero device-create
calls; at lines 3456-3458, record and assert zero node-create calls; and at
lines 3626-3631, record and assert zero flavor-create calls. Use the existing
mock call-tracking mechanisms and preserve the current no-op assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b433faf0-624c-4a6e-ad0e-b5e545a84bb5

📥 Commits

Reviewing files that changed from the base of the PR and between 06495cd and 71b6d57.

📒 Files selected for processing (3)
  • crates/bmc-proxy/src/metrics.rs
  • crates/dpf/src/sdk.rs
  • crates/preingestion-manager/src/metrics.rs

Comment thread crates/dpf/src/sdk.rs
Comment on lines +3374 to +3378

// This branch is a deliberate no-op: an existing, non-terminating device is left
// alone. `.unwrap()` only said no error came back -- assert no second device was
// created alongside it, which is the whole of what "left alone" means here.
assert_eq!(mock.devices.read().unwrap().len(), 1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Verify reuse by observing repository calls, not only final state.

The mock’s create methods reject existing keys with AlreadyExists, so unchanged store sizes do not prove that the no-op branches avoided duplicate creation.

  • crates/dpf/src/sdk.rs#L3374-L3378: record and assert zero device-create calls.
  • crates/dpf/src/sdk.rs#L3456-L3458: record and assert zero node-create calls.
  • crates/dpf/src/sdk.rs#L3626-L3631: record and assert zero flavor-create calls.
📍 Affects 1 file
  • crates/dpf/src/sdk.rs#L3374-L3378 (this comment)
  • crates/dpf/src/sdk.rs#L3456-L3458
  • crates/dpf/src/sdk.rs#L3626-L3631
🤖 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/dpf/src/sdk.rs` around lines 3374 - 3378, Update the no-op reuse tests
to observe repository create calls rather than relying only on final collection
sizes: at crates/dpf/src/sdk.rs lines 3374-3378, record and assert zero
device-create calls; at lines 3456-3458, record and assert zero node-create
calls; and at lines 3626-3631, record and assert zero flavor-create calls. Use
the existing mock call-tracking mechanisms and preserve the current no-op
assertions.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
crates/dpf/src/sdk.rs (1)

3374-3378: 🎯 Functional Correctness | 🟡 Minor

Verify reuse through repository-call observations.

The three tests should assert zero create calls, because the mock rejects duplicate keys without tracking invocation; unchanged store sizes can therefore hide duplicate-create attempts.

  • crates/dpf/src/sdk.rs#L3374-L3378: record and assert zero device-create calls.
  • crates/dpf/src/sdk.rs#L3456-L3458: record and assert zero node-create calls.
  • crates/dpf/src/sdk.rs#L3626-L3631: record and assert zero flavor-create calls.
🤖 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/dpf/src/sdk.rs` around lines 3374 - 3378, Update the reuse tests in
crates/dpf/src/sdk.rs at lines 3374-3378, 3456-3458, and 3626-3631 to record
repository create-call invocations and assert zero calls for device, node, and
flavor creation respectively, rather than relying only on unchanged store sizes.
Ensure each test verifies the existing resource was reused without attempting a
duplicate create.
🤖 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.

Duplicate comments:
In `@crates/dpf/src/sdk.rs`:
- Around line 3374-3378: Update the reuse tests in crates/dpf/src/sdk.rs at
lines 3374-3378, 3456-3458, and 3626-3631 to record repository create-call
invocations and assert zero calls for device, node, and flavor creation
respectively, rather than relying only on unchanged store sizes. Ensure each
test verifies the existing resource was reused without attempting a duplicate
create.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e2ea7fa2-762d-47d9-9d02-d6cf9f04a8d5

📥 Commits

Reviewing files that changed from the base of the PR and between 06495cd and 71b6d57.

📒 Files selected for processing (3)
  • crates/bmc-proxy/src/metrics.rs
  • crates/dpf/src/sdk.rs
  • crates/preingestion-manager/src/metrics.rs

@chet
chet merged commit a35c307 into NVIDIA:main Jul 28, 2026
155 of 159 checks passed
@chet
chet deleted the gh-issue-4224 branch July 28, 2026 16: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.

Collapse Mechanical Table Rows Into The Scenario Macros

2 participants