Skip to content

test(core-api): Site explorer tests refactoring#2230

Merged
poroh merged 4 commits into
NVIDIA:mainfrom
poroh:site-explorer-tests-refactoring
Jun 5, 2026
Merged

test(core-api): Site explorer tests refactoring#2230
poroh merged 4 commits into
NVIDIA:mainfrom
poroh:site-explorer-tests-refactoring

Conversation

@poroh
Copy link
Copy Markdown
Contributor

@poroh poroh commented Jun 5, 2026

Description

This PR contains series of commits that clean up site explorer code.
More clean code will be easier to move to site explorer crate. That I'll do in next PR.

Each individual commit is the PR contains uniform changes.

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

Related Issues (Optional)

#2001

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

Additional Notes

poroh added 3 commits June 4, 2026 17:10
Use direct imports for `sqlx_test` and `PgPool`, and cache the
underlay segment in tests to avoid repeated unwraps.

Signed-off-by: Dmitry Porokh <dporokh@nvidia.com>
Introduce a test-env construction trait for creating SiteExplorer
instances and reuse the env-provided test meter instead of allocating
per-test meters.

Signed-off-by: Dmitry Porokh <dporokh@nvidia.com>
Refactor fake machine and power shelf test helpers to use default
relay addresses and credentials, reducing repetitive setup across site
explorer tests.

Signed-off-by: Dmitry Porokh <dporokh@nvidia.com>
@poroh poroh requested a review from a team as a code owner June 5, 2026 01:22
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 5, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b255bda1-a1a6-4ca4-9b57-60b26550a32a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@poroh poroh enabled auto-merge (squash) June 5, 2026 01:26
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
crates/api-core/src/tests/site_explorer.rs (1)

3282-3292: ⚡ Quick win

Simplify unreachable relay-selection branch in switch DHCP setup.

segment is assigned from underlay_segment, so the match fallback arm is unreachable. Please collapse this to a single explicit relay value to keep the test intent clear and avoid stale branching logic.

Suggested simplification
-    let segment = underlay_segment;
-
     let response = env
         .api
         .discover_dhcp(
             DhcpDiscovery::builder(
                 bmc_mac.to_string(),
-                match segment {
-                    s if s == underlay_segment => "192.0.1.1".to_string(),
-                    _ => "192.0.2.1".to_string(),
-                },
+                UNDERLAY_RELAY.to_string(),
             )
             .tonic_request(),
         )

As per coding guidelines, "Prefer simple, explicit code over clever or heavily abstracted code."

🤖 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/api-core/src/tests/site_explorer.rs` around lines 3282 - 3292, The
match expression selecting the relay IP inside the DhcpDiscovery::builder call
is redundant because `segment` is set to `underlay_segment`, making the fallback
arm unreachable; replace the match with a single explicit relay string (e.g.,
"192.0.1.1".to_string()) when calling
env.api.discover_dhcp/DhcpDiscovery::builder (the variables to locate are
`segment`, `underlay_segment`, `bmc_mac`, and the call site
`env.api.discover_dhcp(...)`) to simplify the test and remove the stale
branching logic.
🤖 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/api-core/src/tests/site_explorer.rs`:
- Around line 3282-3292: The match expression selecting the relay IP inside the
DhcpDiscovery::builder call is redundant because `segment` is set to
`underlay_segment`, making the fallback arm unreachable; replace the match with
a single explicit relay string (e.g., "192.0.1.1".to_string()) when calling
env.api.discover_dhcp/DhcpDiscovery::builder (the variables to locate are
`segment`, `underlay_segment`, `bmc_mac`, and the call site
`env.api.discover_dhcp(...)`) to simplify the test and remove the stale
branching logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: fb341e52-b0c7-4ffd-8541-b6d69140f7e4

📥 Commits

Reviewing files that changed from the base of the PR and between 17a22d2 and d602ce1.

📒 Files selected for processing (1)
  • crates/api-core/src/tests/site_explorer.rs

Signed-off-by: Dmitry Porokh <dporokh@nvidia.com>
@poroh poroh merged commit 0a28f12 into NVIDIA:main Jun 5, 2026
54 checks passed
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.

2 participants