Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bucket Testing for E2E Testing #96

Merged
merged 2 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions testing/test/configurations/Flux.Bucket.Tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Describe 'Bucket Flux Configuration Testing' {
BeforeAll {
$configurationName = "bucket-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 "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
}
}
75 changes: 75 additions & 0 deletions testing/test/configurations/Flux.CrossKind.Tests.ps1
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
}
}