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.
- Loading branch information
1 parent
9f06921
commit 67e3776
Showing
2 changed files
with
99 additions
and
25 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,98 @@ | ||
Describe 'Cassandra Testing' { | ||
BeforeAll { | ||
$extensionType = "cassandradatacentersoperator" | ||
$extensionName = "cassandra" | ||
|
||
. $PSScriptRoot/../../helper/Constants.ps1 | ||
. $PSScriptRoot/../../helper/Helper.ps1 | ||
} | ||
|
||
It 'Creates the extension and checks that it onboards correctly' { | ||
Invoke-Expression "az $Env:K8sExtensionName create -c $($ENVCONFIG.arcClusterName) -g $($ENVCONFIG.resourceGroup) --cluster-type connectedClusters --extension-type $extensionType -n $extensionName --no-wait" -ErrorVariable badOut | ||
$badOut | Should -BeNullOrEmpty | ||
|
||
$output = Invoke-Expression "az $Env:K8sExtensionName show -c $($ENVCONFIG.arcClusterName) -g $($ENVCONFIG.resourceGroup) --cluster-type connectedClusters -n $extensionName" -ErrorVariable badOut | ||
$badOut | Should -BeNullOrEmpty | ||
|
||
$isAutoUpgradeMinorVersion = ($output | ConvertFrom-Json).autoUpgradeMinorVersion | ||
$isAutoUpgradeMinorVersion.ToString() -eq "True" | Should -BeTrue | ||
|
||
# Check that we get the principal id back for the created identity | ||
$principalId = ($output | ConvertFrom-Json).identity.principalId | ||
$principalId | Should -Not -BeNullOrEmpty | ||
|
||
# Loop and retry until the extension installs | ||
$n = 0 | ||
do | ||
{ | ||
# Only check the extension config, not the pod since this doesn't bring up pods | ||
$output = Invoke-Expression "az $Env:K8sExtensionName show -c $($ENVCONFIG.arcClusterName) -g $($ENVCONFIG.resourceGroup) --cluster-type connectedClusters -n $extensionName" -ErrorVariable badOut | ||
$provisioningState = ($output | ConvertFrom-Json).provisioningState | ||
Write-Host "Got ProvisioningState: $provisioningState for the extension" | ||
if ((Has-ExtensionData $extensionName) -And ($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 extension" { | ||
$output = Invoke-Expression "az $Env:K8sExtensionName show -c $($ENVCONFIG.arcClusterName) -g $($ENVCONFIG.resourceGroup) --cluster-type connectedClusters -n $extensionName" -ErrorVariable badOut | ||
$badOut | Should -BeNullOrEmpty | ||
$output | Should -Not -BeNullOrEmpty | ||
} | ||
|
||
It "Runs an update on the extension on the cluster" { | ||
$output = Invoke-Expression "az $Env:K8sExtensionName update -c $($ENVCONFIG.arcClusterName) -g $($ENVCONFIG.resourceGroup) --cluster-type connectedClusters -n $extensionName --auto-upgrade false --no-wait" -ErrorVariable badOut | ||
$badOut | Should -BeNullOrEmpty | ||
|
||
$output = Invoke-Expression "az $Env:K8sExtensionName show -c $($ENVCONFIG.arcClusterName) -g $($ENVCONFIG.resourceGroup) --cluster-type connectedClusters -n $extensionName" -ErrorVariable badOut | ||
$badOut | Should -BeNullOrEmpty | ||
|
||
$isAutoUpgradeMinorVersion = ($output | ConvertFrom-Json).autoUpgradeMinorVersion | ||
$isAutoUpgradeMinorVersion.ToString() -eq "False" | Should -BeTrue | ||
|
||
# Loop and retry until the extension config updates | ||
$n = 0 | ||
do | ||
{ | ||
$isAutoUpgradeMinorVersion = (Get-ExtensionData $extensionName).spec.autoUpgradeMinorVersion | ||
if (!$isAutoUpgradeMinorVersion) { #autoUpgradeMinorVersion doesn't exist in ExtensionConfig CRD if false | ||
break | ||
} | ||
Start-Sleep -Seconds 10 | ||
$n += 1 | ||
} while ($n -le $MAX_RETRY_ATTEMPTS) | ||
$n | Should -BeLessOrEqual $MAX_RETRY_ATTEMPTS | ||
} | ||
|
||
It "Lists the extensions on the cluster" { | ||
$output = Invoke-Expression "az $Env:K8sExtensionName list -c $($ENVCONFIG.arcClusterName) -g $($ENVCONFIG.resourceGroup) --cluster-type connectedClusters" -ErrorVariable badOut | ||
$badOut | Should -BeNullOrEmpty | ||
|
||
$output | Should -Not -BeNullOrEmpty | ||
$extensionExists = $output | ConvertFrom-Json | Where-Object { $_.extensionType -eq $extensionType } | ||
$extensionExists | Should -Not -BeNullOrEmpty | ||
} | ||
|
||
It "Deletes the extension from the cluster" { | ||
$output = Invoke-Expression "az $Env:K8sExtensionName delete -c $($ENVCONFIG.arcClusterName) -g $($ENVCONFIG.resourceGroup) --cluster-type connectedClusters -n $extensionName --force" -ErrorVariable badOut | ||
$badOut | Should -BeNullOrEmpty | ||
|
||
# Extension should not be found on the cluster | ||
$output = Invoke-Expression "az $Env:K8sExtensionName show -c $($ENVCONFIG.arcClusterName) -g $($ENVCONFIG.resourceGroup) --cluster-type connectedClusters -n $extensionName" -ErrorVariable badOut | ||
$badOut | Should -Not -BeNullOrEmpty | ||
$output | Should -BeNullOrEmpty | ||
} | ||
|
||
It "Performs another list after the delete" { | ||
$output = Invoke-Expression "az $Env:K8sExtensionName list -c $($ENVCONFIG.arcClusterName) -g $($ENVCONFIG.resourceGroup) --cluster-type connectedClusters" -ErrorVariable badOut | ||
$badOut | Should -BeNullOrEmpty | ||
$output | Should -Not -BeNullOrEmpty | ||
|
||
$extensionExists = $output | ConvertFrom-Json | Where-Object { $_.extensionType -eq $extensionName } | ||
$extensionExists | Should -BeNullOrEmpty | ||
} | ||
} |