Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit e6f28f7

Browse files
Bucket Testing for E2E Testing (#96)
* Bucket testing * Add switching kind test to update CLI
1 parent 8aedb4e commit e6f28f7

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
Describe 'Bucket Flux Configuration Testing' {
2+
BeforeAll {
3+
$configurationName = "bucket-config"
4+
. $PSScriptRoot/Constants.ps1
5+
. $PSScriptRoot/Helper.ps1
6+
}
7+
8+
It 'Creates a configuration and checks that it onboards correctly' {
9+
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
10+
$? | Should -BeTrue
11+
12+
# Loop and retry until the configuration installs
13+
$n = 0
14+
do {
15+
$output = az k8s-configuration flux show -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters -n $configurationName
16+
$provisioningState = ($output | ConvertFrom-Json).provisioningState
17+
Write-Host "Provisioning State: $provisioningState"
18+
if ($provisioningState -eq $SUCCEEDED) {
19+
break
20+
}
21+
Start-Sleep -Seconds 10
22+
$n += 1
23+
} while ($n -le $MAX_RETRY_ATTEMPTS)
24+
$n | Should -BeLessOrEqual $MAX_RETRY_ATTEMPTS
25+
}
26+
27+
It "Performs a show on the configuration" {
28+
$output = az k8s-configuration flux show -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type "connectedClusters" -n $configurationName
29+
$? | Should -BeTrue
30+
$output | Should -Not -BeNullOrEmpty
31+
}
32+
33+
It "Lists the configurations on the cluster" {
34+
$output = az k8s-configuration flux list -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters
35+
$? | Should -BeTrue
36+
37+
$configExists = $output | ConvertFrom-Json | Where-Object { $_.id -Match $configurationName }
38+
$configExists | Should -Not -BeNullOrEmpty
39+
}
40+
41+
It "Deletes the configuration from the cluster" {
42+
az k8s-configuration flux delete -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters -n $configurationName --force
43+
$? | Should -BeTrue
44+
45+
# Configuration should be removed from the resource model
46+
az k8s-configuration show -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters -n $configurationName
47+
$? | Should -BeFalse
48+
}
49+
50+
It "Performs another list after the delete" {
51+
$output = az k8s-configuration flux list -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters
52+
$configExists = $output | ConvertFrom-Json | Where-Object { $_.id -Match $configurationName }
53+
$configExists | Should -BeNullOrEmpty
54+
}
55+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
Describe 'Bucket Flux Configuration Testing' {
2+
BeforeAll {
3+
$configurationName = "cross-kind-config"
4+
. $PSScriptRoot/Constants.ps1
5+
. $PSScriptRoot/Helper.ps1
6+
}
7+
8+
It 'Creates a configuration and checks that it onboards correctly' {
9+
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
10+
$? | Should -BeTrue
11+
12+
# Loop and retry until the configuration installs
13+
$n = 0
14+
do {
15+
$output = az k8s-configuration flux show -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters -n $configurationName
16+
$provisioningState = ($output | ConvertFrom-Json).provisioningState
17+
Write-Host "Provisioning State: $provisioningState"
18+
if ($provisioningState -eq $SUCCEEDED) {
19+
break
20+
}
21+
Start-Sleep -Seconds 10
22+
$n += 1
23+
} while ($n -le $MAX_RETRY_ATTEMPTS)
24+
$n | Should -BeLessOrEqual $MAX_RETRY_ATTEMPTS
25+
}
26+
27+
It "Performs a show on the configuration" {
28+
$output = az k8s-configuration flux show -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type "connectedClusters" -n $configurationName
29+
$? | Should -BeTrue
30+
$output | Should -Not -BeNullOrEmpty
31+
}
32+
33+
It "Performs an update on the configuration changing the kind from Bucket to Git" {
34+
$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
35+
$? | Should -BeTrue
36+
37+
# Loop and retry until the configuration installs
38+
$n = 0
39+
do {
40+
$output = az k8s-configuration flux show -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters -n $configurationName
41+
$provisioningState = ($output | ConvertFrom-Json).provisioningState
42+
Write-Host "Provisioning State: $provisioningState"
43+
if ($provisioningState -eq $SUCCEEDED) {
44+
break
45+
}
46+
Start-Sleep -Seconds 10
47+
$n += 1
48+
} while ($n -le $MAX_RETRY_ATTEMPTS)
49+
$n | Should -BeLessOrEqual $MAX_RETRY_ATTEMPTS
50+
$output | Should -Not -BeNullOrEmpty
51+
}
52+
53+
It "Lists the configurations on the cluster" {
54+
$output = az k8s-configuration flux list -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters
55+
$? | Should -BeTrue
56+
57+
$configExists = $output | ConvertFrom-Json | Where-Object { $_.id -Match $configurationName }
58+
$configExists | Should -Not -BeNullOrEmpty
59+
}
60+
61+
It "Deletes the configuration from the cluster" {
62+
az k8s-configuration flux delete -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters -n $configurationName --force
63+
$? | Should -BeTrue
64+
65+
# Configuration should be removed from the resource model
66+
az k8s-configuration show -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters -n $configurationName
67+
$? | Should -BeFalse
68+
}
69+
70+
It "Performs another list after the delete" {
71+
$output = az k8s-configuration flux list -c $ENVCONFIG.arcClusterName -g $ENVCONFIG.resourceGroup --cluster-type connectedClusters
72+
$configExists = $output | ConvertFrom-Json | Where-Object { $_.id -Match $configurationName }
73+
$configExists | Should -BeNullOrEmpty
74+
}
75+
}

0 commit comments

Comments
 (0)