Skip to content
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

Added debug info for Aks module #20896

Merged
merged 3 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .azure-pipelines/live-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ parameters:
- name: ps_7_2_x
displayName: PowerShell 7.2.x Version
type: string
default: 7.2.9
default: 7.2.8
- name: ps_latest
displayName: PowerShell Latest Version
type: string
Expand Down
56 changes: 46 additions & 10 deletions src/Aks/Aks.Test/LiveTests/TestLiveScenarios.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
$PreDebugPreference = $DebugPreference
$DebugPreference = 'Continue'

Invoke-LiveTestScenario -Name "Test_AKS_CURD" -Description "Test AKS Cluster CRUD and node pool CRU" -ScenarioScript `
{
param ($rg)
Expand All @@ -6,12 +9,12 @@ Invoke-LiveTestScenario -Name "Test_AKS_CURD" -Description "Test AKS Cluster CRU

# Generate random resource name if necessary
$kubeClusterName = New-LiveTestResourceName

# step 1: create a default aks cluster with default node pool

ssh-keygen -t rsa -f id_rsa -q -N '"123456"'
$sshKeyValue = Get-Content id_rsa.pub -Raw

$kvName = "LiveTestKeyVault"
$aksSPIdKey = "AKSSPId"
$aksSPSecretKey = "AKSSPSecret"
Expand All @@ -20,9 +23,14 @@ Invoke-LiveTestScenario -Name "Test_AKS_CURD" -Description "Test AKS Cluster CRU
$servicePrincipalSecureSecret = ConvertTo-SecureString -String $ServicePrincipalSecret -AsPlainText -Force
$servicePrincipalCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $ServicePrincipalId, $servicePrincipalSecureSecret

Write-Host "##[section]Start to create Aks cluster : New-AzAksCluster"
New-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName -SshKeyValue $sshKeyValue -ServicePrincipalIdAndSecret $servicePrincipalCredential

Write-Host "##[section]Finished creating Aks cluster : New-AzAksCluster"

Write-Host "##[section]Start to retrieve Aks cluster : Get-AzAksCluster"
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
Write-Host "##[section]Finished retrieving Aks cluster : Get-AzAksCluster"

Assert-NotNull $cluster.Fqdn
Assert-NotNull $cluster.KubernetesVersion
Assert-NotNull $cluster.DnsPrefix
Expand All @@ -34,8 +42,11 @@ Invoke-LiveTestScenario -Name "Test_AKS_CURD" -Description "Test AKS Cluster CRU
Assert-AreEqual 1 $cluster.AgentPoolProfiles.Length
Assert-AreEqual 3 $cluster.AgentPoolProfiles[0].Count
Assert-NotNull $cluster.AgentPoolProfiles[0].NodeImageVersion


Write-Host "##[section]Start to retrieve Aks node pool : Get-AzAksNodePool"
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
Write-Host "##[section]Finished retrieving Aks node pool : Get-AzAksNodePool"

Assert-NotNull $pools.VmSize
Assert-NotNull $pools.OsDiskSizeGB
Assert-NotNull $pools.OrchestratorVersion
Expand Down Expand Up @@ -76,29 +87,46 @@ Invoke-LiveTestScenario -Name "Test_AKS_CURD" -Description "Test AKS Cluster CRU
Assert-Null $pools.CreationData
Assert-Null $pools.HostGroupID
Assert-False {$pools.EnableFIPS}

# step 2: update the aks cluster
Write-Host "##[section]Start to update Aks cluster : Set-AzAksCluster"
$cluster = $cluster | Set-AzAksCluster -NodeCount 4 -EnableUptimeSLA
Write-Host "##[section]Finished updating Aks cluster : Set-AzAksCluster"

Assert-AreEqual 4 $cluster.AgentPoolProfiles[0].Count
Assert-AreEqual "Basic" $cluster.Sku.Name
Assert-AreEqual "Paid" $cluster.Sku.Tier

# step 3: create the second node pool
$pool1Name = "default"
$pool2Name = "pool2"

Write-Host "##[section]Start to create Aks node pool : New-AzAksNodePool"
New-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName -Name $pool2Name -OsType "Windows" -OsSKU "Windows2022" -Count 1 -VmSetType VirtualMachineScaleSets
Write-Host "##[section]Finished creating Aks node pool : New-AzAksNodePool"

Write-Host "##[section]Start to retrieve Aks node pool : Get-AzAksNodePool"
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
Write-Host "##[section]Finished retrieving Aks node pool : Get-AzAksNodePool"

Assert-AreEqual 2 $pools.Count
Assert-AreEqualArray "Linux" ($pools | where {$_.Name -eq $pool1Name}).OsType
Assert-AreEqualArray "Ubuntu" ($pools | where {$_.Name -eq $pool1Name}).OsSKU
Assert-AreEqualArray "Windows" ($pools | where {$_.Name -eq $pool2Name}).OsType
Assert-AreEqualArray "Windows2022" ($pools | where {$_.Name -eq $pool2Name}).OsSKU

# step4: update the second node pool
$labels = @{"someId" = 127; "tier" = "frontend"; "environment" = "qa" }
$tags = @{"dept"="MM"; "costcenter"=7777; "Admin"="Cindy"}

Write-Host "##[section]Start to update Aks node pool : Update-AzAksNodePool"
Update-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName -Name $pool2Name -NodeLabel $labels -Tag $tags
Write-Host "##[section]Finished updating Aks node pool : Update-AzAksNodePool"

Write-Host "##[section]Start to retrieve Aks cluster : Get-AzAksCluster"
$cluster = Get-AzAksCluster -ResourceGroupName $resourceGroupName -Name $kubeClusterName
Write-Host "##[section]Finished retrieving Aks cluster : Get-AzAksCluster"

Assert-AreEqual 2 $cluster.AgentPoolProfiles.Count
Assert-AreEqual 0 ($cluster.AgentPoolProfiles | where {$_.Name -eq $pool1Name}).NodeLabels.Count
Assert-AreEqual 0 ($cluster.AgentPoolProfiles | where {$_.Name -eq $pool1Name}).Tags.Count
Expand All @@ -108,7 +136,11 @@ Invoke-LiveTestScenario -Name "Test_AKS_CURD" -Description "Test AKS Cluster CRU
Assert-AreEqual MM ($cluster.AgentPoolProfiles | where {$_.Name -eq $pool2Name}).Tags.dept
Assert-AreEqual 7777 ($cluster.AgentPoolProfiles | where {$_.Name -eq $pool2Name}).Tags.costcenter
Assert-AreEqual Cindy ($cluster.AgentPoolProfiles | where {$_.Name -eq $pool2Name}).Tags.Admin

Write-Host "##[section]Start to retrieve Aks node pool : Get-AzAksNodePool"
$pools = Get-AzAksNodePool -ResourceGroupName $resourceGroupName -ClusterName $kubeClusterName
Write-Host "##[section]Finished retrieving Aks node pool : Get-AzAksNodePool"

Assert-AreEqual 2 $pools.Count
Assert-AreEqual 0 ($pools | where {$_.Name -eq $pool1Name}).NodeLabels.Count
Assert-AreEqual 0 ($pools | where {$_.Name -eq $pool1Name}).Tags.Count
Expand All @@ -118,7 +150,11 @@ Invoke-LiveTestScenario -Name "Test_AKS_CURD" -Description "Test AKS Cluster CRU
Assert-AreEqual MM ($pools | where {$_.Name -eq $pool2Name}).Tags.dept
Assert-AreEqual 7777 ($pools | where {$_.Name -eq $pool2Name}).Tags.costcenter
Assert-AreEqual Cindy ($pools | where {$_.Name -eq $pool2Name}).Tags.Admin


Write-Host "##[section]Start to remove Aks cluster : Remove-AzAksCluster"
$cluster | Remove-AzAksCluster -Force
Write-Host "##[section]Finished removing Aks cluster : Remove-AzAksCluster"

}

}
$DebugPreference = $PreDebugPreference