Repository navigation
fix(hubs): stop price transform row fan-out and fix eligibility scoping #2246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Michael Flanakin (flanakin)
wants to merge
9
commits into
dev
Choose a base branch
from
flanakin/1736-1625-prices-transform
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+190
−20
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b9b712c
fix(hubs): stop price transform row fan-out and fix eligibility scoping
flanakin e9f4277
fix(hubs): normalize meter ID casing in eligibility lookup, harden CS…
flanakin d67d563
chore: Update ms.date in docs-mslearn files
github-actions[bot] 9483937
Merge remote-tracking branch 'origin/dev' into flanakin/1736-1625-pri…
flanakin 9a26744
Address PR #2246 feedback: local hub open data, Gov/China fallback, s…
flanakin 37f94ab
chore: Update ms.date in docs-mslearn files
github-actions[bot] 3318e51
Merge origin/dev into flanakin/1736-1625-prices-transform
flanakin beb9c1d
fix(hubs): restore savings plan prefilter and add price transform reg…
flanakin 57cc2db
chore: Update ms.date in docs-mslearn files
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/powershell/Tests/Unit/HubsPriceTransformLookups.Tests.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Copyright (c) Microsoft Corporation. | ||
| # Licensed under the MIT License. | ||
|
|
||
| <# | ||
| Regression coverage for #1736 (Prices_transform row fan-out) and #1625 (commitment discount eligibility | ||
| computed from a per-invocation partial view of Prices_raw). | ||
| Text-pattern checks, like HubsReservationPriceBackfill.Tests.ps1. | ||
| #> | ||
|
|
||
| Describe 'HubsPriceTransformLookups' { | ||
|
|
||
| BeforeDiscovery { | ||
| $repoRoot = (Resolve-Path "$PSScriptRoot/../../../..").Path | ||
| $scriptsPath = Join-Path $repoRoot 'src/templates/finops-hub/modules/Microsoft.FinOpsHubs/Analytics/scripts' | ||
| $ingestionFiles = @('IngestionSetup_v1_0.kql', 'IngestionSetup_v1_2.kql') | ForEach-Object { | ||
| @{ Name = $_; FullName = (Join-Path $scriptsPath $_) } | ||
| } | ||
| } | ||
|
|
||
| BeforeAll { | ||
| $repoRoot = (Resolve-Path "$PSScriptRoot/../../../..").Path | ||
| $analyticsPath = Join-Path $repoRoot 'src/templates/finops-hub/modules/Microsoft.FinOpsHubs/Analytics' | ||
| } | ||
|
|
||
| Context 'Savings plan price lookup (#1736)' { | ||
|
|
||
| It 'Should dedupe the Consumption side with take_any, not distinct: <Name>' -ForEach $ingestionFiles { | ||
| $content = Get-Content -Path $FullName -Raw | ||
| $content | Should -Match "lookup kind=leftouter \(prices \| where x_SkuPriceType == 'Consumption'[^\n]*summarize take_any\(ListUnitPrice\), take_any\(ContractedUnitPrice\), take_any\(x_BaseUnitPrice\) by tmp_SavingsPlanKey\)" -Because 'distinct over price columns leaves several rows per key and fans out SavingsPlan rows' | ||
| $content | Should -Not -Match '\| distinct tmp_SavingsPlanKey' -Because 'distinct over price columns is the #1736 fan-out bug' | ||
| } | ||
|
|
||
| It 'Should keep the savings plan meter prefilter on the dimension side: <Name>' -ForEach $ingestionFiles { | ||
| $content = Get-Content -Path $FullName -Raw | ||
| $content | Should -Match "'Consumption' \| where x_SkuMeterId in \(spMeters\) \| summarize take_any" -Because 'limits the aggregation to savings plan meters on the ingestion hot path' | ||
| } | ||
|
|
||
| It 'Should include billing profile and currency in the savings plan key: <Name>' -ForEach $ingestionFiles { | ||
| $content = Get-Content -Path $FullName -Raw | ||
| $content | Should -Match 'tmp_SavingsPlanKey = strcat\([^\n]*x_BillingProfileId[^\n]*Currency' -Because 'one billing profile or currency must not pick up another one''s price' | ||
| } | ||
| } | ||
|
|
||
| Context 'Commitment discount eligibility (#1625)' { | ||
|
|
||
| It 'Should source eligibility from the CommitmentDiscountEligibility table: <Name>' -ForEach $ingestionFiles { | ||
| $content = Get-Content -Path $FullName -Raw | ||
| $content | Should -Match 'let commitmentEligibility = CommitmentDiscountEligibility' -Because 'deriving eligibility only from the invocation''s partial Prices_raw gives wrong results for multi-file exports' | ||
| $content | Should -Match 'lookup kind=leftouter \(commitmentEligibility\) on tmp_MeterId' | ||
| } | ||
|
|
||
| It 'Should fall back to pricesheet-derived eligibility when the meter is missing: <Name>' -ForEach $ingestionFiles { | ||
| $content = Get-Content -Path $FullName -Raw | ||
| $content | Should -Match "iff\(x_SkuMeterId in \(spMeters\), 'Eligible', 'Not Eligible'\)" -Because 'Azure Government/China and new meters are not in the open data' | ||
| $content | Should -Match "iff\(x_SkuMeterId in \(riMeters\) and x_SkuPriceType != 'ReservedInstance', 'Eligible', 'Not Eligible'\)" | ||
| } | ||
|
|
||
| It 'Should create and populate the table for ADF, Fabric, and local hubs' { | ||
| Get-Content -Path (Join-Path $analyticsPath 'scripts/IngestionSetup_HubInfra.kql') -Raw | Should -Match '\.create-merge table CommitmentDiscountEligibility' | ||
| Get-Content -Path (Join-Path $analyticsPath 'scripts/IngestionSetup_OpenDataExternal.kql') -Raw | Should -Match '\.set-or-replace CommitmentDiscountEligibility' | ||
| Get-Content -Path (Join-Path $analyticsPath 'app.bicep') -Raw | Should -Match '\.set-or-replace CommitmentDiscountEligibility' | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.