1+ suite : Test Hub Cluster Detection Logic
2+ templates :
3+ - templates/imperative/unsealjob.yaml
4+ release :
5+ name : release-test
6+ tests :
7+ # Test 1: isHubCluster takes precedence over domain logic (explicit true)
8+ - it : should use isHubCluster true even when domains do not match
9+ set :
10+ global :
11+ repoURL : https://github.com/validatedpatterns/multicloud-gitops
12+ multiSourceRepoUrl : https://charts.validatedpatterns.io
13+ hubClusterDomain : " apps.hub.example.com"
14+ localClusterDomain : " apps.spoke.example.com"
15+ clusterGroup :
16+ isHubCluster : true # This takes precedence over domain logic
17+ applications :
18+ test :
19+ name : test
20+ namespace : test
21+ project : test
22+ chart : test-chart
23+ asserts :
24+ - isKind :
25+ of : CronJob
26+ - hasDocuments :
27+ count : 1
28+
29+ # Test 2: isHubCluster takes precedence over domain logic (explicit false)
30+ - it : should use isHubCluster false even when domains match
31+ set :
32+ global :
33+ repoURL : https://github.com/validatedpatterns/multicloud-gitops
34+ multiSourceRepoUrl : https://charts.validatedpatterns.io
35+ hubClusterDomain : " apps.hub.example.com"
36+ localClusterDomain : " apps.hub.example.com"
37+ secretStore :
38+ backend : " vault"
39+ clusterGroup :
40+ isHubCluster : false # This takes precedence over domain logic
41+ applications :
42+ test :
43+ name : test
44+ namespace : test
45+ project : test
46+ chart : test-chart
47+ asserts :
48+ - hasDocuments :
49+ count : 0
50+
51+ # Test 3: Domain logic fallback - hub cluster when domains match (isHubCluster not set)
52+ - it : should detect hub cluster via domain logic when isHubCluster is not set and domains match
53+ set :
54+ global :
55+ repoURL : https://github.com/validatedpatterns/multicloud-gitops
56+ multiSourceRepoUrl : https://charts.validatedpatterns.io
57+ hubClusterDomain : " apps.hub.example.com"
58+ localClusterDomain : " apps.hub.example.com"
59+ clusterGroup :
60+ isHubCluster : null # Explicitly null to trigger domain logic fallback
61+ applications :
62+ test :
63+ name : test
64+ namespace : test
65+ project : test
66+ chart : test-chart
67+ asserts :
68+ - isKind :
69+ of : CronJob
70+ - hasDocuments :
71+ count : 1
72+
73+ # Test 4: Domain logic fallback - managed cluster when domains differ (isHubCluster not set)
74+ - it : should detect managed cluster via domain logic when isHubCluster is not set and domains differ
75+ set :
76+ global :
77+ repoURL : https://github.com/validatedpatterns/multicloud-gitops
78+ multiSourceRepoUrl : https://charts.validatedpatterns.io
79+ hubClusterDomain : " apps.hub.example.com"
80+ localClusterDomain : " apps.spoke.example.com"
81+ secretStore :
82+ backend : " vault"
83+ clusterGroup :
84+ isHubCluster : null # Explicitly null to trigger domain logic fallback
85+ applications :
86+ test :
87+ name : test
88+ namespace : test
89+ project : test
90+ chart : test-chart
91+ asserts :
92+ - hasDocuments :
93+ count : 0
94+
95+ # Test 5: Domain logic fallback - hub cluster when localClusterDomain is unset
96+ - it : should detect hub cluster when isHubCluster not set and localClusterDomain defaults to hubClusterDomain
97+ set :
98+ global :
99+ repoURL : https://github.com/validatedpatterns/multicloud-gitops
100+ multiSourceRepoUrl : https://charts.validatedpatterns.io
101+ hubClusterDomain : " apps.hub.example.com"
102+ # localClusterDomain is intentionally not set - defaults to hubClusterDomain
103+ clusterGroup :
104+ isHubCluster : null # Explicitly null to trigger domain logic fallback
105+ applications :
106+ test :
107+ name : test
108+ namespace : test
109+ project : test
110+ chart : test-chart
111+ asserts :
112+ - isKind :
113+ of : CronJob
114+ - hasDocuments :
115+ count : 1
116+
117+ # Test 6: Fallback to false when no isHubCluster and no domain configuration
118+ - it : should default to false when no isHubCluster and no domain configuration
119+ set :
120+ global :
121+ repoURL : https://github.com/validatedpatterns/multicloud-gitops
122+ multiSourceRepoUrl : https://charts.validatedpatterns.io
123+ secretStore :
124+ backend : " vault"
125+ # No domain configuration provided
126+ clusterGroup :
127+ isHubCluster : null # Explicitly null to trigger fallback logic
128+ applications :
129+ test :
130+ name : test
131+ namespace : test
132+ project : test
133+ chart : test-chart
134+ asserts :
135+ - hasDocuments :
136+ count : 0
137+
138+ # Test 7: Should still create unsealjob when hashicorp-vault app exists regardless of hub status
139+ - it : should create unsealjob when hashicorp-vault app exists even on managed cluster
140+ set :
141+ global :
142+ repoURL : https://github.com/validatedpatterns/multicloud-gitops
143+ multiSourceRepoUrl : https://charts.validatedpatterns.io
144+ hubClusterDomain : " apps.hub.example.com"
145+ localClusterDomain : " apps.spoke.example.com"
146+ clusterGroup :
147+ isHubCluster : false # This confirms it's a managed cluster
148+ applications :
149+ vault :
150+ name : vault
151+ namespace : vault
152+ project : hub
153+ chart : hashicorp-vault
154+ chartVersion : 0.1.*
155+ asserts :
156+ - isKind :
157+ of : CronJob
158+ - hasDocuments :
159+ count : 1
160+
161+ # Test 8: isHubCluster true with no domain configuration
162+ - it : should use isHubCluster true when no domain configuration is provided
163+ set :
164+ global :
165+ repoURL : https://github.com/validatedpatterns/multicloud-gitops
166+ multiSourceRepoUrl : https://charts.validatedpatterns.io
167+ # No domain configuration provided
168+ clusterGroup :
169+ isHubCluster : true
170+ applications :
171+ test :
172+ name : test
173+ namespace : test
174+ project : test
175+ chart : test-chart
176+ asserts :
177+ - isKind :
178+ of : CronJob
179+ - hasDocuments :
180+ count : 1
181+
182+ # Test 9: isHubCluster false with no domain configuration
183+ - it : should use isHubCluster false when no domain configuration is provided
184+ set :
185+ global :
186+ repoURL : https://github.com/validatedpatterns/multicloud-gitops
187+ multiSourceRepoUrl : https://charts.validatedpatterns.io
188+ secretStore :
189+ backend : " vault"
190+ # No domain configuration provided
191+ clusterGroup :
192+ isHubCluster : false
193+ applications :
194+ test :
195+ name : test
196+ namespace : test
197+ project : test
198+ chart : test-chart
199+ asserts :
200+ - hasDocuments :
201+ count : 0
0 commit comments