Skip to content

Commit aa034b9

Browse files
bragi92Bavneet Singh
authored andcommitted
fix: simplify logic and enable correct recording rule groups for managed prom extension (#7)
1 parent 2d8d5e2 commit aa034b9

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/k8s-extension/HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Release History
1414
1.6.5
1515
++++++++++++++++++
1616
* microsoft.dataprotection.kubernetes: Add support for 'DisableInformerCache' configuration.
17+
* microsoft.azuremonitor.containers.metrics: Simplify logic and enable correct recording rule groups for managed prom extension
1718

1819
1.6.4
1920
++++++++++++++++++

testing/test/extensions/public/AzureMonitorMetrics.Tests.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Describe 'Azure Monitor Metrics Testing' {
55
$extensionName = "azuremonitor-metrics"
66
$extensionAgentName = "ama-metrics"
77
$extensionAgentNamespace = "kube-system"
8+
$workspaceResourceGroup = $null # Initialize here for shared scope
89

910
. $PSScriptRoot/../../helper/Constants.ps1
1011
. $PSScriptRoot/../../helper/Helper.ps1
@@ -47,6 +48,23 @@ Describe 'Azure Monitor Metrics Testing' {
4748
$extensionExists | Should -Not -BeNullOrEmpty
4849
}
4950

51+
It 'Verifies rule groups were created' {
52+
$clusterName = $ENVCONFIG.arcClusterName
53+
$expectedRuleGroupNames = @(
54+
"KubernetesRecordingRulesRuleGroup-$clusterName",
55+
"NodeRecordingRulesRuleGroup-$clusterName"
56+
)
57+
58+
$ruleGroups = az resource list --resource-group $($ENVCONFIG.resourceGroup) --resource-type "Microsoft.AlertsManagement/prometheusRuleGroups" --query "[].{name:name, location:location, id:id}" | ConvertFrom-Json
59+
$ruleGroups | Should -Not -BeNullOrEmpty -Because "Rule groups may take time to be created after extension onboarding"
60+
61+
foreach ($expectedName in $expectedRuleGroupNames) {
62+
$matchingGroup = $ruleGroups | Where-Object { $_.name -eq $expectedName }
63+
$matchingGroup | Should -Not -BeNullOrEmpty -Because "Rule group '$expectedName' should have been created by create.py"
64+
}
65+
}
66+
67+
5068
It "Deletes the extension from the cluster" {
5169
$output = az $Env:K8sExtensionName delete -c $($ENVCONFIG.arcClusterName) -g $($ENVCONFIG.resourceGroup) --cluster-type connectedClusters -n $extensionName --force
5270
$? | Should -BeTrue

0 commit comments

Comments
 (0)