1+ Describe ' ConnectedK8s Enable Disable Features Scenario' {
2+ BeforeAll {
3+ . $PSScriptRoot / ../ helper/ Constants.ps1
4+
5+ function Invoke-AzCommand {
6+ param (
7+ [string ]$Command
8+ )
9+ Write-Host " Executing: $Command " - ForegroundColor Yellow
10+ $result = Invoke-Expression $Command
11+ return $result
12+ }
13+
14+ function Wait-ForProvisioning {
15+ param (
16+ [string ]$expectedProvisioningState ,
17+ [string ]$expectedAutoUpdate
18+ )
19+ $n = 0
20+ do {
21+ $output = Invoke-AzCommand " az connectedk8s show -n $ ( $ENVCONFIG.arcClusterName ) -g $ ( $ENVCONFIG.resourceGroup ) "
22+ $jsonOutput = [System.Text.Json.JsonDocument ]::Parse($output )
23+ $provisioningState = ($output | ConvertFrom-Json ).provisioningState
24+ $autoUpdate = $jsonOutput.RootElement.GetProperty (" arcAgentProfile" ).GetProperty(" agentAutoUpgrade" ).GetString()
25+ Write-Host " Provisioning State: $provisioningState "
26+ Write-Host " Auto Update: $autoUpdate "
27+ if ($provisioningState -eq $expectedProvisioningState -and $autoUpdate -eq $expectedAutoUpdate ) {
28+ break
29+ }
30+ Start-Sleep - Seconds 10
31+ $n += 1
32+ } while ($n -le $MAX_RETRY_ATTEMPTS )
33+ $n | Should - BeLessOrEqual $MAX_RETRY_ATTEMPTS
34+ }
35+ }
36+
37+ It ' Onboard Connected cluster with no features enabled' {
38+ Invoke-AzCommand " az connectedk8s connect -n $ ( $ENVCONFIG.arcClusterName ) -g $ ( $ENVCONFIG.resourceGroup ) -l $ARC_LOCATION --no-wait"
39+ $? | Should - BeTrue
40+ Start-Sleep - Seconds 10
41+ Wait-ForProvisioning - expectedProvisioningState $SUCCEEDED - expectedAutoUpdate " Enabled"
42+ }
43+
44+ It ' Enable azure-rbac feature' {
45+ Invoke-AzCommand " az connectedk8s enable-features -n $ ( $ENVCONFIG.arcClusterName ) -g $ ( $ENVCONFIG.resourceGroup ) --features azure-rbac"
46+ $? | Should - BeTrue
47+ Start-Sleep - Seconds 10
48+ Wait-ForProvisioning - expectedProvisioningState $SUCCEEDED - expectedAutoUpdate " Enabled"
49+ }
50+
51+ It ' Disable azure-rbac feature' {
52+ Invoke-AzCommand " az connectedk8s disable-features -n $ ( $ENVCONFIG.arcClusterName ) -g $ ( $ENVCONFIG.resourceGroup ) --features azure-rbac --yes"
53+ $? | Should - BeTrue
54+ Start-Sleep - Seconds 10
55+ Wait-ForProvisioning - expectedProvisioningState $SUCCEEDED - expectedAutoUpdate " Enabled"
56+ }
57+
58+ It ' Enable cluster-connect feature' {
59+ Invoke-AzCommand " az connectedk8s enable-features -n $ ( $ENVCONFIG.arcClusterName ) -g $ ( $ENVCONFIG.resourceGroup ) --features cluster-connect"
60+ $? | Should - BeTrue
61+ Start-Sleep - Seconds 10
62+ Wait-ForProvisioning - expectedProvisioningState $SUCCEEDED - expectedAutoUpdate " Enabled"
63+ }
64+
65+ It ' Disable cluster-connect feature' {
66+ Invoke-AzCommand " az connectedk8s disable-features -n $ ( $ENVCONFIG.arcClusterName ) -g $ ( $ENVCONFIG.resourceGroup ) --features cluster-connect --yes"
67+ $? | Should - BeTrue
68+ Start-Sleep - Seconds 10
69+ Wait-ForProvisioning - expectedProvisioningState $SUCCEEDED - expectedAutoUpdate " Enabled"
70+ }
71+
72+ It ' Enable custom-locations feature' {
73+ Invoke-AzCommand " az connectedk8s enable-features -n $ ( $ENVCONFIG.arcClusterName ) -g $ ( $ENVCONFIG.resourceGroup ) --features custom-locations --custom-locations-oid $ ( $ENVCONFIG.customLocationsOid ) "
74+ $? | Should - BeTrue
75+ Start-Sleep - Seconds 10
76+ Wait-ForProvisioning - expectedProvisioningState $SUCCEEDED - expectedAutoUpdate " Enabled"
77+ }
78+
79+ It ' Disable custom-locations feature' {
80+ Invoke-AzCommand " az connectedk8s disable-features -n $ ( $ENVCONFIG.arcClusterName ) -g $ ( $ENVCONFIG.resourceGroup ) --features custom-locations --yes"
81+ $? | Should - BeTrue
82+ Start-Sleep - Seconds 10
83+ Wait-ForProvisioning - expectedProvisioningState $SUCCEEDED - expectedAutoUpdate " Enabled"
84+ }
85+
86+ It ' Enable all features (cluster-connect, custom-locations, azure-rbac) together' {
87+ Invoke-AzCommand " az connectedk8s enable-features -n $ ( $ENVCONFIG.arcClusterName ) -g $ ( $ENVCONFIG.resourceGroup ) --features cluster-connect custom-locations azure-rbac --custom-locations-oid $ ( $ENVCONFIG.customLocationsOid ) "
88+ $? | Should - BeTrue
89+ Start-Sleep - Seconds 10
90+ Wait-ForProvisioning - expectedProvisioningState $SUCCEEDED - expectedAutoUpdate " Enabled"
91+ }
92+
93+ It ' Disable all features (cluster-connect, custom-locations, azure-rbac) together' {
94+ Invoke-AzCommand " az connectedk8s disable-features -n $ ( $ENVCONFIG.arcClusterName ) -g $ ( $ENVCONFIG.resourceGroup ) --features cluster-connect custom-locations azure-rbac --yes"
95+ $? | Should - BeTrue
96+ Start-Sleep - Seconds 10
97+ Wait-ForProvisioning - expectedProvisioningState $SUCCEEDED - expectedAutoUpdate " Enabled"
98+ }
99+
100+ It " Delete the connected instance" {
101+ Invoke-AzCommand " az connectedk8s delete -n $ ( $ENVCONFIG.arcClusterName ) -g $ ( $ENVCONFIG.resourceGroup ) -y"
102+ $? | Should - BeTrue
103+
104+ # Wait for deletion to propagate through the resource model
105+ Start-Sleep - Seconds 30
106+
107+ # Configuration should be removed from the resource model - expect ResourceNotFound error
108+ $output = Invoke-AzCommand " az connectedk8s show -n $ ( $ENVCONFIG.arcClusterName ) -g $ ( $ENVCONFIG.resourceGroup ) " 2>&1
109+ $output | Should -Match " ResourceNotFound"
110+ }
111+ }
0 commit comments