forked from Azure/azure-cli-extensions
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add switching kind test to update CLI
- Loading branch information
1 parent
1839390
commit 485cb6f
Showing
2 changed files
with
75 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
Describe 'Bucket Flux Configuration Testing' { | ||
BeforeAll { | ||
$configurationName = "cross-kind-config" | ||
. $PSScriptRoot/Constants.ps1 | ||
. $PSScriptRoot/Helper.ps1 | ||
} | ||
|
||
It 'Creates a configuration and checks that it onboards correctly' { | ||
az k8s-configuration flux create -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type "connectedClusters" --kind bucket -u "http://52.190.35.89" --bucket-name flux -n $configurationName --scope cluster --namespace $configurationName --access-key test --secret-key test --no-wait | ||
$? | Should -BeTrue | ||
|
||
# Loop and retry until the configuration installs | ||
$n = 0 | ||
do { | ||
$output = az k8s-configuration flux show -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters -n $configurationName | ||
$provisioningState = ($output | ConvertFrom-Json).provisioningState | ||
Write-Host "Provisioning State: $provisioningState" | ||
if ($provisioningState -eq $SUCCEEDED) { | ||
break | ||
} | ||
Start-Sleep -Seconds 10 | ||
$n += 1 | ||
} while ($n -le $MAX_RETRY_ATTEMPTS) | ||
$n | Should -BeLessOrEqual $MAX_RETRY_ATTEMPTS | ||
} | ||
|
||
It "Performs a show on the configuration" { | ||
$output = az k8s-configuration flux show -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type "connectedClusters" -n $configurationName | ||
$? | Should -BeTrue | ||
$output | Should -Not -BeNullOrEmpty | ||
} | ||
|
||
It "Performs an update on the configuration changing the kind from Bucket to Git" { | ||
$output = az k8s-configuration flux update -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type "connectedClusters" -n $configurationName --kind git -u "https://github.com/Azure/arc-k8s-demo" --branch main --no-wait | ||
$? | Should -BeTrue | ||
|
||
# Loop and retry until the configuration installs | ||
$n = 0 | ||
do { | ||
$output = az k8s-configuration flux show -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters -n $configurationName | ||
$provisioningState = ($output | ConvertFrom-Json).provisioningState | ||
Write-Host "Provisioning State: $provisioningState" | ||
if ($provisioningState -eq $SUCCEEDED) { | ||
break | ||
} | ||
Start-Sleep -Seconds 10 | ||
$n += 1 | ||
} while ($n -le $MAX_RETRY_ATTEMPTS) | ||
$n | Should -BeLessOrEqual $MAX_RETRY_ATTEMPTS | ||
$output | Should -Not -BeNullOrEmpty | ||
} | ||
|
||
It "Lists the configurations on the cluster" { | ||
$output = az k8s-configuration flux list -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters | ||
$? | Should -BeTrue | ||
|
||
$configExists = $output | ConvertFrom-Json | Where-Object { $_.id -Match $configurationName } | ||
$configExists | Should -Not -BeNullOrEmpty | ||
} | ||
|
||
It "Deletes the configuration from the cluster" { | ||
az k8s-configuration flux delete -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters -n $configurationName --force | ||
$? | Should -BeTrue | ||
|
||
# Configuration should be removed from the resource model | ||
az k8s-configuration show -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters -n $configurationName | ||
$? | Should -BeFalse | ||
} | ||
|
||
It "Performs another list after the delete" { | ||
$output = az k8s-configuration flux list -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters | ||
$configExists = $output | ConvertFrom-Json | Where-Object { $_.id -Match $configurationName } | ||
$configExists | Should -BeNullOrEmpty | ||
} | ||
} |