From 485cb6fa3bf25bf2e34c7aa27a639034c5346025 Mon Sep 17 00:00:00 2001 From: Jonathan Innis Date: Fri, 10 Dec 2021 10:17:00 -0800 Subject: [PATCH] Add switching kind test to update CLI --- .../test/configurations/Flux.Bucket.Tests.ps1 | 5 -- .../configurations/Flux.CrossKind.Tests.ps1 | 75 +++++++++++++++++++ 2 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 testing/test/configurations/Flux.CrossKind.Tests.ps1 diff --git a/testing/test/configurations/Flux.Bucket.Tests.ps1 b/testing/test/configurations/Flux.Bucket.Tests.ps1 index b35ab315a80..a6d39172f55 100644 --- a/testing/test/configurations/Flux.Bucket.Tests.ps1 +++ b/testing/test/configurations/Flux.Bucket.Tests.ps1 @@ -30,11 +30,6 @@ Describe 'Bucket Flux Configuration Testing' { $output | Should -Not -BeNullOrEmpty } - It "Performs a re-PUT of the configuration on the cluster, with HTTPS in caps" { - az k8s-configuration flux create -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type "connectedClusters" -u "HTTPS://github.com/Azure/arc-k8s-demo" -n $configurationName --scope cluster --namespace $configurationName --branch main --no-wait - $? | Should -BeTrue - } - It "Lists the configurations on the cluster" { $output = az k8s-configuration flux list -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters $? | Should -BeTrue diff --git a/testing/test/configurations/Flux.CrossKind.Tests.ps1 b/testing/test/configurations/Flux.CrossKind.Tests.ps1 new file mode 100644 index 00000000000..4452ecff7d7 --- /dev/null +++ b/testing/test/configurations/Flux.CrossKind.Tests.ps1 @@ -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 + } +} \ No newline at end of file