Skip to content

Commit 3c08eac

Browse files
vineeth-thummaBavneet Singhatchutbarlimcnealm13matthewmcneal
committed
[Azure RBAC] Deprecate 3P mode flags, fix Azure RBAC enablement bug, add E2E coverage and improve logging (#20)
* add pester tests for connectedk8s cli extension * Pass the force delete param to the API call (#4) * forcedelete * format * add code owner * mypy * Parameterize for airgapped clouds (#5) * Add parameterization for the airgapped clouds * Fix azdev style * MCR path function * azdev, ruff, and mypy --------- Co-authored-by: Matthew McNeal (from Dev Box) <[email protected]> * Oras client fix to work with different MCRs (#6) Co-authored-by: mmcneal <[email protected]> * fix CI testcases for nodepool image issues (#8) * update errors for the config and connectivity issues (#11) * update errors * format * style * update python version to 3.13 (#12) * Update cluster diagnostics image to 1.29.3 (#7) * Update cluster diagnostics helm chart to 1.29.3 * Fix lint issues --------- Co-authored-by: bgriddaluru <[email protected]> * RBAC deprecation & fix the issue * typo * fix comments * update tests * add pester tests for connectedk8s cli extension * Pass the force delete param to the API call (#4) * forcedelete * format * add code owner * mypy * fix CI testcases for nodepool image issues (#8) * update errors for the config and connectivity issues (#11) * update errors * format * style * update python version to 3.13 (#12) * rebase * fix tests * fix version * fix mypy, lint * fix test * fix test * fix test * fix test * fix test * rename test * deprecate flags * rebase * rebase * bump version for release --------- Co-authored-by: Bavneet Singh <[email protected]> Co-authored-by: Atchut Kumar Barli <[email protected]> Co-authored-by: mcnealm13 <[email protected]> Co-authored-by: Matthew McNeal (from Dev Box) <[email protected]> Co-authored-by: Bavneet Singh <[email protected]> Co-authored-by: bgriddaluru <[email protected]> Co-authored-by: bgriddaluru <[email protected]> Co-authored-by: vithumma <[email protected]>
1 parent 2121694 commit 3c08eac

File tree

5 files changed

+126
-14
lines changed

5 files changed

+126
-14
lines changed

testing/pipeline/k8s-custom-pipelines.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ stages:
2828
parameters:
2929
jobName: BasicOnboardingTest
3030
path: ./test/configurations/BasicOnboarding.Tests.ps1
31+
- template: ./templates/run-test.yml
32+
parameters:
33+
jobName: EnableDisableFeaturesTest
34+
path: ./test/configurations/EnableDisableFeatures.Tests.ps1
3135
- template: ./templates/run-test.yml
3236
parameters:
3337
jobName: AutoUpdateTest
@@ -177,13 +181,12 @@ stages:
177181
pip install pytest
178182
cd /home/vsts/work/1/s/src/connectedk8s/azext_connectedk8s/tests/unittests
179183
pytest --junitxml=test-results.xml
180-
181184
displayName: 'Run UnitTests test'
182185
- task: PublishTestResults@2
183186
inputs:
184187
testResultsFormat: 'JUnit'
185188
testResultsFiles: '**/test-results.xml'
186-
failTaskOnFailedTests: true
189+
failTaskOnFailedTests: true
187190
- job: SourceTests
188191
displayName: "Integration Tests, Build Tests"
189192
pool:

testing/pipeline/templates/run-test.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
azdev extension build $(EXTENSION_NAME)
4242
workingDirectory: $(CLI_REPO_PATH)
4343
displayName: "Setup and Build Extension with azdev"
44-
44+
4545
- bash: |
4646
K8S_CONFIG_VERSION=$(ls ${EXTENSION_FILE_NAME}* | cut -d "-" -f2)
4747
echo "##vso[task.setvariable variable=K8S_CONFIG_VERSION]$K8S_CONFIG_VERSION"
@@ -60,7 +60,7 @@ jobs:
6060
--arg AKS_CLUSTER_NAME "$AKS_CLUSTER_NAME" \
6161
--arg ARC_CLUSTER_NAME "$ARC_CLUSTER_NAME" \
6262
--arg K8S_CONFIG_VERSION "$K8S_CONFIG_VERSION" \
63-
'{subscriptionId: $SUB_ID, resourceGroup: $RG, aksClusterName: $AKS_CLUSTER_NAME, arcClusterName: $ARC_CLUSTER_NAME, extensionVersion: {"connectedk8s": $K8S_CONFIG_VERSION}}')
63+
'{subscriptionId: $SUB_ID, resourceGroup: $RG, aksClusterName: $AKS_CLUSTER_NAME, arcClusterName: $ARC_CLUSTER_NAME, extensionVersion: {"connectedk8s": $K8S_CONFIG_VERSION}, customLocationsOid: "51dfe1e8-70c6-4de5-a08e-e18aff23d815"}')
6464
echo $JSON_STRING > settings.json
6565
cat settings.json
6666
workingDirectory: $(TEST_PATH)
@@ -74,7 +74,6 @@ jobs:
7474
chmod +x ./kind
7575
./kind create cluster
7676
displayName: "Create and Start the Kind cluster"
77-
7877
- bash: |
7978
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
8079
displayName: "Upgrade az to latest version"
@@ -94,7 +93,6 @@ jobs:
9493
inlineScript: |
9594
.\Bootstrap.ps1 -CI
9695
workingDirectory: $(TEST_PATH)
97-
9896
- task: AzureCLI@2
9997
displayName: Run the Test Suite for ${{ parameters.path }}
10098
inputs:

testing/test/configurations/BasicOnboarding.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Describe 'Basic Onboarding Scenario' {
1010

1111
# Loop and retry until the configuration installs
1212
$n = 0
13-
do
13+
do
1414
{
1515
$output = az connectedk8s show -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup
1616
$jsonOutput = [System.Text.Json.JsonDocument]::Parse($output)
@@ -34,7 +34,7 @@ Describe 'Basic Onboarding Scenario' {
3434

3535
# Loop and retry until the configuration installs
3636
$n = 0
37-
do
37+
do
3838
{
3939
$output = az connectedk8s show -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup
4040
$jsonOutput = [System.Text.Json.JsonDocument]::Parse($output)
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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+
}

testing/test/configurations/Gateway.Tests.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Describe 'Onboarding with Gateway Scenario' {
1212

1313
# Loop and retry until the configuration installs
1414
$n = 0
15-
do
15+
do
1616
{
1717
$output = az connectedk8s show -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup
1818
$jsonOutput = [System.Text.Json.JsonDocument]::Parse($output)
@@ -36,12 +36,12 @@ Describe 'Onboarding with Gateway Scenario' {
3636

3737
# Loop and retry until the configuration installs
3838
$n = 0
39-
do
39+
do
4040
{
4141
$output = az connectedk8s show -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup
4242
$jsonOutput = [System.Text.Json.JsonDocument]::Parse($output)
4343
$provisioningState = ($output | ConvertFrom-Json).provisioningState
44-
$gatewayStatus = $jsonOutput.RootElement.GetProperty("gateway").GetProperty("enabled").GetBoolean()
44+
$gatewayStatus = $jsonOutput.RootElement.GetProperty("gateway").GetProperty("enabled").GetBoolean()
4545
Write-Host "Provisioning State: $provisioningState"
4646
Write-Host "Gateway Status: $gatewayStatus"
4747
if ($provisioningState -eq $SUCCEEDED -and $gatewayStatus -eq $false) {
@@ -60,7 +60,7 @@ Describe 'Onboarding with Gateway Scenario' {
6060

6161
# Loop and retry until the configuration installs
6262
$n = 0
63-
do
63+
do
6464
{
6565
$output = az connectedk8s show -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup
6666
$jsonOutput = [System.Text.Json.JsonDocument]::Parse($output)
@@ -84,12 +84,12 @@ Describe 'Onboarding with Gateway Scenario' {
8484

8585
# Loop and retry until the configuration installs
8686
$n = 0
87-
do
87+
do
8888
{
8989
$output = az connectedk8s show -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup
9090
$jsonOutput = [System.Text.Json.JsonDocument]::Parse($output)
9191
$provisioningState = ($output | ConvertFrom-Json).provisioningState
92-
$gatewayStatus = $jsonOutput.RootElement.GetProperty("gateway").GetProperty("enabled").GetBoolean()
92+
$gatewayStatus = $jsonOutput.RootElement.GetProperty("gateway").GetProperty("enabled").GetBoolean()
9393
Write-Host "Provisioning State: $provisioningState"
9494
Write-Host "Gateway Status: $gatewayStatus"
9595
if ($provisioningState -eq $SUCCEEDED -and $gatewayStatus -eq $false) {

0 commit comments

Comments
 (0)