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