Skip to content

Commit b3112a8

Browse files
committed
[connectedk8s] Add ci test script to test the bundle feature flag in the connectedk8s extension and resolve the ruff check failure
1 parent efa12d2 commit b3112a8

File tree

3 files changed

+165
-0
lines changed

3 files changed

+165
-0
lines changed

testing/pipeline/k8s-custom-pipelines.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ stages:
5656
parameters:
5757
jobName: ForcedDeleteTest
5858
path: ./test/configurations/ForcedDelete.Tests.ps1
59+
- template: ./templates/run-test.yml
60+
parameters:
61+
jobName: BundleFeatureFlagTest
62+
path: ./test/configurations/BundleFeatureFlag.Tests.ps1
5963
- job: BuildPublishExtension
6064
pool:
6165
vmImage: 'ubuntu-latest'
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
Describe 'Setting Bundle Feature Flag Scenario' {
2+
BeforeAll {
3+
. $PSScriptRoot/../helper/Constants.ps1
4+
}
5+
6+
It 'Enable the bundle feature flag when connecting the cluster to Arc' {
7+
$output = & {
8+
az connectedk8s connect -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup -l $BUNDLE_FEATURE_TEST_ARC_LOCATION `
9+
--disable-auto-upgrade --config extensionSets.versionManagedExtensions='off' 2>&1 | Out-String
10+
}
11+
$output | Should -Match "Not supported value for the feature flag"
12+
13+
$output = & {
14+
az connectedk8s connect -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup -l $BUNDLE_FEATURE_TEST_ARC_LOCATION `
15+
--disable-auto-upgrade --config extensionSets.versionManagedExtensions='disabled' 2>&1 | Out-String
16+
}
17+
$output | Should -Match "'disabled' mode can only be set using 'az connectedk8s update'"
18+
19+
az connectedk8s connect -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup -l $BUNDLE_FEATURE_TEST_ARC_LOCATION `
20+
--disable-auto-upgrade --config extensionSets.versionManagedExtensions='preview' --no-wait --yes
21+
$? | Should -BeTrue
22+
Start-Sleep -Seconds 10
23+
24+
# Loop and retry until the configuration installs
25+
$n = 0
26+
do
27+
{
28+
$output = az connectedk8s show -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup
29+
$jsonOutput = [System.Text.Json.JsonDocument]::Parse($output)
30+
$provisioningState = ($output | ConvertFrom-Json).provisioningState
31+
$bundleFeatureFlag = $jsonOutput.RootElement.GetProperty("arcAgentryConfigurations")[0].GetProperty("settings").GetProperty("versionManagedExtensions").GetString()
32+
Write-Host "Provisioning State: $provisioningState"
33+
Write-Host "Bundle Feature Flag: $bundleFeatureFlag"
34+
if ($provisioningState -eq $SUCCEEDED -and $bundleFeatureFlag -eq "preview")
35+
{
36+
break
37+
}
38+
Start-Sleep -Seconds 10
39+
$n += 1
40+
} while ($n -le $MAX_RETRY_ATTEMPTS)
41+
$n | Should -BeLessOrEqual $MAX_RETRY_ATTEMPTS
42+
43+
$output = & {
44+
az connectedk8s update -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --auto-upgrade false `
45+
--config extensionSets.versionManagedExtensions='enabled' 2>&1 | Out-String
46+
}
47+
$output | Should -Match "The cluster is in versionManagedExtensions 'preview' mode, updating the value is not allowed."
48+
49+
az connectedk8s delete -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --force -y
50+
$? | Should -BeTrue
51+
Start-Sleep -Seconds 10
52+
53+
az connectedk8s connect -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup -l $BUNDLE_FEATURE_TEST_ARC_LOCATION `
54+
--disable-auto-upgrade --config extensionSets.versionManagedExtensions='enabled' --no-wait
55+
$? | Should -BeTrue
56+
Start-Sleep -Seconds 10
57+
58+
# Loop and retry until the configuration installs
59+
$n = 0
60+
do
61+
{
62+
$output = az connectedk8s show -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup
63+
$jsonOutput = [System.Text.Json.JsonDocument]::Parse($output)
64+
$provisioningState = ($output | ConvertFrom-Json).provisioningState
65+
$bundleFeatureFlag = $jsonOutput.RootElement.GetProperty("arcAgentryConfigurations")[0].GetProperty("settings").GetProperty("versionManagedExtensions").GetString()
66+
Write-Host "Provisioning State: $provisioningState"
67+
Write-Host "Bundle Feature Flag: $bundleFeatureFlag"
68+
if ($provisioningState -eq $SUCCEEDED -and $bundleFeatureFlag -eq "enabled")
69+
{
70+
break
71+
}
72+
Start-Sleep -Seconds 10
73+
$n += 1
74+
} while ($n -le $MAX_RETRY_ATTEMPTS)
75+
$n | Should -BeLessOrEqual $MAX_RETRY_ATTEMPTS
76+
}
77+
78+
It 'Enable the bundle feature flag using update cmd' {
79+
$output = & {
80+
az connectedk8s update -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --auto-upgrade false `
81+
--config extensionSets.versionManagedExtensions='on' 2>&1 | Out-String
82+
}
83+
$output | Should -Match "Not supported value for the feature flag"
84+
85+
$output = & {
86+
az connectedk8s update -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --auto-upgrade false `
87+
--config extensionSets.versionManagedExtensions='preview' 2>&1 | Out-String
88+
}
89+
$output | Should -Match "Updating the preview mode config with 'az connectedk8s update' is not allowed"
90+
91+
$output = & {
92+
az connectedk8s update -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --auto-upgrade false `
93+
--config extensionSets.versionManagedExtensions='' 2>&1 | Out-String
94+
}
95+
$output | Should -Match "Could not set extensionSets.versionManagedExtensions from 'enabled' to ''"
96+
97+
az k8s-extension create --cluster-name $ENVCONFIG.arcClusterName --resource-group $ENVCONFIG.resourceGroup `
98+
--cluster-type connectedClusters --extension-type microsoft.iotoperations.platform `
99+
--name azure-iot-operations-platform --release-train preview --auto-upgrade-minor-version False `
100+
--config installTrustManager=true --config installCertManager=true --version 0.7.6 `
101+
--release-namespace cert-manager --scope cluster
102+
$? | Should -BeTrue
103+
Start-Sleep -Seconds 10
104+
105+
az k8s-extension create --cluster-name $ENVCONFIG.arcClusterName --resource-group $ENVCONFIG.resourceGroup `
106+
--cluster-type connectedClusters --extension-type microsoft.azure.secretstore `
107+
--name azure-secret-store --auto-upgrade-minor-version False `
108+
--config rotationPollIntervalInSeconds=120 --config validatingAdmissionPolicies.applyPolicies=false `
109+
--scope cluster
110+
$? | Should -BeTrue
111+
Start-Sleep -Seconds 10
112+
113+
$output = & {
114+
az connectedk8s update -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --auto-upgrade false `
115+
--config extensionSets.versionManagedExtensions='disabled' 2>&1 | Out-String
116+
}
117+
$output | Should -Match "detected the following extension types on the cluster"
118+
119+
az k8s-extension delete --cluster-name $ENVCONFIG.arcClusterName --resource-group $ENVCONFIG.resourceGroup `
120+
--cluster-type connectedClusters --name azure-secret-store --yes
121+
$? | Should -BeTrue
122+
123+
az k8s-extension delete --cluster-name $ENVCONFIG.arcClusterName --resource-group $ENVCONFIG.resourceGroup `
124+
--cluster-type connectedClusters --name azure-iot-operations-platform --yes
125+
$? | Should -BeTrue
126+
127+
az connectedk8s update -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --auto-upgrade false `
128+
--config extensionSets.versionManagedExtensions='disabled'
129+
$? | Should -BeTrue
130+
Start-Sleep -Seconds 10
131+
132+
# Loop and retry until the configuration installs
133+
$n = 0
134+
do
135+
{
136+
$output = az connectedk8s show -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup
137+
$jsonOutput = [System.Text.Json.JsonDocument]::Parse($output)
138+
$provisioningState = ($output | ConvertFrom-Json).provisioningState
139+
$bundleFeatureFlag = $jsonOutput.RootElement.GetProperty("arcAgentryConfigurations")[0].GetProperty("settings").GetProperty("versionManagedExtensions").GetString()
140+
Write-Host "Provisioning State: $provisioningState"
141+
Write-Host "Bundle Feature Flag: $bundleFeatureFlag"
142+
if ($provisioningState -eq $SUCCEEDED -and $bundleFeatureFlag -eq "disabled")
143+
{
144+
break
145+
}
146+
Start-Sleep -Seconds 10
147+
$n += 1
148+
} while ($n -le $MAX_RETRY_ATTEMPTS)
149+
$n | Should -BeLessOrEqual $MAX_RETRY_ATTEMPTS
150+
}
151+
152+
It "Delete the connected instance" {
153+
az connectedk8s delete -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --force -y
154+
$? | Should -BeTrue
155+
156+
# Configuration should be removed from the resource model
157+
az connectedk8s show -n $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup
158+
$? | Should -BeFalse
159+
}
160+
}

testing/test/helper/Constants.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ $ENVCONFIG = Get-Content -Path $PSScriptRoot/../../settings.json | ConvertFrom-J
22

33
$MAX_RETRY_ATTEMPTS = 30
44
$ARC_LOCATION = "uksouth"
5+
$BUNDLE_FEATURE_TEST_ARC_LOCATION = "eastus2euap"
56
$SUCCEEDED = "Succeeded"

0 commit comments

Comments
 (0)