Skip to content

Package Storage Metrics as a module (Phase 5) - #41

Open
tjsullivan1 wants to merge 4 commits into
masterfrom
tjsullivan1-storage-metrics-phase-5
Open

tjsullivan1 wants to merge 4 commits into
masterfrom
tjsullivan1-storage-metrics-phase-5

Conversation

@tjsullivan1

Copy link
Copy Markdown
Owner

Summary

  • Add a StorageMetrics module exporting only Get-AzStorageTransactionMetric and Get-AzStorageRedundancyCost; keep both existing .ps1 files as dot-source-compatible import shims.
  • Move helpers into Private with explicit account, time-window, context, retry and policy inputs. Move classification/product tables into versioned policy data with source URLs and retrieval dates, loaded once per import.
  • Add StorageMetrics.<RecordType> display metadata and compact table views for all 21 record types without changing ordered CSV/JSON properties.
  • Update the quickstart and add the complete record/status aggregation reference.

This is Phase 5 only. Phase 4 (#40) merged into master before this PR was opened. The branch adds one distinct Phase 5 commit after dcec962; no Phase 4 commits were changed and this PR is not stacked.

Verification

  • Pester 3.4.0: 190/190 offline tests passed (179 existing tests plus 11 new module/type/schema/null/policy regressions).
  • PSScriptAnalyzer 1.25.0: 0 findings; module manifest and git diff checks passed.
  • Private-helper variable audit found no implicit caller inputs.
  • Existing null/status, fail-closed reconciliation, per-account buffering, saved-context, exact-decimal, invariant-parsing and flat-export behavior remains covered. No live Azure collection was needed.

Standards review

No documented-standard violations. The reviewer noted the existing category switches in retail meter selection as a possible repeated-switch smell. Those switches are unchanged behavior moved into Public and are outside Phase 5's requested policy tables, so they remain unchanged.

Spec review

No significant issues or missing Phase 5 requirements found. No Phase 6 work included.

Extract private helpers with explicit inputs, preserve dot-source entry points and flat exports, and add typed table views plus record/status references.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 2fe9508c-dba1-4dd4-a425-ac46a9581943
Move fixture setup to BeforeAll, retain module-scoped offline mocks, and route UTC reads through an internal clock. Preserve all 190 original tests and add retry-date and polling-deadline coverage. Pin Pester 5.7.1 in CI and verification docs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: bab1d34b-d8d8-4bd1-8a3a-5e44f606ee9d

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Mixed-record output bypasses the separate compact table views and falls back to full-property lists.

1 open issue
What changed in this PR

Packages the existing Azure Storage collectors and cost estimator as a reusable module, preserving dot-source entry points and flat export schemas.

Changes:

  • Separates public commands, private helpers and versioned classification policy.
  • Adds display metadata and table views for 21 record types.
  • Updates documentation and module-scoped regression tests.
File Description
PowerShell/​StorageMetrics/​tests/​StorageMetrics.Module.Tests.ps1 Tests exports, shims and view registration.
PowerShell/​StorageMetrics/​tests/​Get-AzStorageWorkloadBaseline.Tests.ps1 Adds module mocks and export checks.
PowerShell/​StorageMetrics/​tests/​Get-AzStorageTransactionMetric.Tests.ps1 Tests schemas, metadata and policy reuse.
PowerShell/​StorageMetrics/​tests/​Get-AzStorageRedundancyCost.Tests.ps1 Tests typed estimate exports.
PowerShell/​StorageMetrics/​tests/​Get-AzStorageCostComparison.Tests.ps1 Moves mocks into module scope.
PowerShell/​StorageMetrics/​tests/​Get-AzStorageCapacity.Tests.ps1 Updates mocks and error-type checks.
PowerShell/​StorageMetrics/​StorageTransactionMetrics.md Documents module layout and aggregation rules.
PowerShell/​StorageMetrics/​StorageTransactionCostComparison.ps1 Removes the former companion implementation.
PowerShell/​StorageMetrics/​StorageMetrics.psm1 Loads policy, helpers and public commands.
PowerShell/​StorageMetrics/​StorageMetrics.psd1 Defines exports and formatting registration.
PowerShell/​StorageMetrics/​StorageMetrics.format.ps1xml Adds record-specific table views.
PowerShell/​StorageMetrics/​Quickstart.md Documents module import and packaging.
PowerShell/​StorageMetrics/​Public/​Get-AzStorageTransactionMetric.ps1 Integrates explicit helper inputs and record types.
PowerShell/​StorageMetrics/​Public/​Get-AzStorageRedundancyCost.ps1 Integrates policy-backed products and typed output.
PowerShell/​StorageMetrics/​PSScriptAnalyzerSettings.psd1 Removes blanket unused-parameter suppression.
PowerShell/​StorageMetrics/​Private/​Set-StorageRecordType.ps1 Attaches display-only type metadata.
PowerShell/​StorageMetrics/​Private/​Set-RetailCost.ps1 Extracts pricing with explicit observation time.
PowerShell/​StorageMetrics/​Private/​New-TransactionRecord.ps1 Constructs records from explicit metadata.
PowerShell/​StorageMetrics/​Private/​New-EstimateRecord.ps1 Constructs records from explicit assumptions.
PowerShell/​StorageMetrics/​Private/​New-CostMeter.ps1 Applies billing classification policy.
PowerShell/​StorageMetrics/​Private/​Invoke-StorageMetricRequest.ps1 Extracts response parsing and retry inputs.
PowerShell/​StorageMetrics/​Private/​Invoke-StorageArmGet.ps1 Adds comment-based help.
PowerShell/​StorageMetrics/​Private/​Import-CostRows.ps1 Extracts billing CSV import.
PowerShell/​StorageMetrics/​Private/​Get-TransactionSeries.ps1 Extracts transaction response validation.
PowerShell/​StorageMetrics/​Private/​Get-TransactionChunkRecords.ps1 Makes collection dependencies explicit.
PowerShell/​StorageMetrics/​Private/​Get-StorageWorkloadBaseline.ps1 Moves workload normalization into Private.
PowerShell/​StorageMetrics/​Private/​Get-StorageTransactionCostComparison.ps1 Coordinates private billing helpers.
PowerShell/​StorageMetrics/​Private/​Get-StorageCapacityRecord.ps1 Delegates to extracted capacity helpers.
PowerShell/​StorageMetrics/​Private/​Get-SeriesCount.ps1 Extracts request-count validation.
PowerShell/​StorageMetrics/​Private/​Get-RetailCatalog.ps1 Builds catalog queries from policy.
PowerShell/​StorageMetrics/​Private/​Get-ReportHeader.ps1 Extracts report-header access.
PowerShell/​StorageMetrics/​Private/​Get-LiveCostRows.ps1 Extracts report polling and downloads.
PowerShell/​StorageMetrics/​Private/​Get-CostLookupKey.ps1 Extracts normalized billing keys.
PowerShell/​StorageMetrics/​Private/​Get-CostField.ps1 Extracts billing field resolution.
PowerShell/​StorageMetrics/​Private/​Get-CostDecimal.ps1 Extracts invariant decimal parsing.
PowerShell/​StorageMetrics/​Private/​Get-CapacityWindow.ps1 Extracts hourly capacity reconciliation.
PowerShell/​StorageMetrics/​Private/​Get-CapacitySeries.ps1 Makes context and retries explicit.
PowerShell/​StorageMetrics/​Private/​Get-CapacityPoints.ps1 Extracts capacity sample validation.
PowerShell/​StorageMetrics/​Private/​ConvertTo-MonthlyRecord.ps1 Makes aggregation boundaries explicit.
PowerShell/​StorageMetrics/​Private/​ConvertTo-CostMeterRecord.ps1 Extracts flat billing-record conversion.
PowerShell/​StorageMetrics/​Get-AzStorageTransactionMetric.ps1 Becomes a compatibility import shim.
PowerShell/​StorageMetrics/​Get-AzStorageRedundancyCost.ps1 Becomes a compatibility import shim.
PowerShell/​StorageMetrics/​Data/​StoragePricingPolicy.psd1 Centralizes versioned mappings and sources.

Review effort: Balanced

</View>
<View>
<Name>StorageMetrics.Summary</Name>
<ViewSelectedBy><TypeName>StorageMetrics.Summary</TypeName></ViewSelectedBy>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Added a shared mixed-record table view and Out-String coverage. Commit: 38456e8.

…hase-6

Storage Metrics phase 6: migrate to Pester 5
Co-authored-by: tjsullivan1 <191369+tjsullivan1@users.noreply.github.com>
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.

3 participants