Skip to content

Add FinOps xunit tests -- scenario-based recommendation validation (#564)#610

Merged
erikdarlingdata merged 1 commit intodevfrom
feature/finops-xunit-tests
Mar 17, 2026
Merged

Add FinOps xunit tests -- scenario-based recommendation validation (#564)#610
erikdarlingdata merged 1 commit intodevfrom
feature/finops-xunit-tests

Conversation

@erikdarlingdata
Copy link
Owner

@erikdarlingdata erikdarlingdata commented Mar 17, 2026

Summary

  • Add 16 xunit tests for the FinOps recommendation engine and High Impact scorer
  • Fix BigInteger handling bug in maintenance and storage tier FinOps checks (DuckDB SUM() returns HUGEINT -> BigInteger, which Convert.ToInt64/32 cannot handle)
  • Tests cover: over-provisioned enterprise, idle databases, high impact query skew, HighImpactScorer pure function, long-running jobs, clean server, reserved capacity, bursty CPU, VM right-sizing, and low IO latency scenarios

Test plan

  • All 16 FinOps tests pass (dotnet test --filter FinOpsTests)
  • BigInteger bug fix verified: maintenance and storage tier recommendations now fire correctly
  • Clean server scenario confirms no false positives from DuckDB-based checks

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for FinOps recommendations and scoring functionality, validating resource optimization scenarios including CPU/memory right-sizing, idle database detection, query performance impact analysis, and reserved capacity behavior.

… and scoring (#564)

Fix BigInteger handling in maintenance and storage tier FinOps checks:
DuckDB SUM() aggregations return HUGEINT which maps to BigInteger in .NET.
Convert.ToInt64/ToInt32 cannot handle BigInteger, causing these checks to
silently fail. Switched to the existing ToInt64() helper which handles it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bb3f59db-c78b-48b4-934e-37049c7c745b

📥 Commits

Reviewing files that changed from the base of the PR and between 1b3a47f and f1c2cb4.

📒 Files selected for processing (2)
  • Lite.Tests/FinOpsTests.cs
  • Lite/Services/LocalDataService.FinOps.cs

📝 Walkthrough

Walkthrough

Adds a comprehensive end-to-end test suite for FinOps scenarios covering over-provisioned infrastructure, idle databases, high-impact queries, and reserved capacity analysis. Also updates type conversion helpers in LocalDataService.FinOps when reading numeric values from data readers.

Changes

Cohort / File(s) Summary
FinOps Test Suite
Lite.Tests/FinOpsTests.cs
Introduces 16 test methods covering enterprise VM right-sizing, idle database detection, cost-share calculations, dominant query scoring, long-running job recommendations, clean server filtering, CPU reserved capacity analysis, and storage tier recommendations. Tests leverage in-memory DuckDB, TestDataSeeder, and LocalDataService for end-to-end validation.
LocalDataService Type Conversions
Lite/Services/LocalDataService.FinOps.cs
Replaces 8 occurrences of Convert.ToInt64(...) with a ToInt64(...) helper method when reading numeric job metrics (avgDuration, maxDuration, avgHistorical, timesLong) and server IO metrics (totalReads, totalStallRead, totalWrites, totalStallWrite).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • No additional related PRs identified beyond those already referenced in the changeset summary.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/finops-xunit-tests
📝 Coding Plan
  • Generate coding plan for human review comments

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

@erikdarlingdata erikdarlingdata merged commit 5c679e8 into dev Mar 17, 2026
3 of 4 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.

1 participant