Skip to content

Commit b5a60ff

Browse files
authored
Merge pull request #7100 from Abhay349/bucket-interpreter-tests
Add complete interpreter tests covarage for Bucket
2 parents 6a17ea8 + cee61f2 commit b5a60ff

File tree

5 files changed

+519
-0
lines changed

5 files changed

+519
-0
lines changed

pkg/resourceinterpreter/default/thirdparty/resourcecustomizations/source.toolkit.fluxcd.io/v1beta2/Bucket/testdata/aggregatestatus-test.yaml

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# test case for aggregating status of Bucket
22
# case1. Bucket with two status items
3+
# case2. Bucket with no status items
4+
# case3. Bucket with stale member
5+
# case4. Bucket condition merging with different reasons
6+
# case5. Bucket ignores empty url
7+
# case6. Bucket with different artifacts picks last one
38

49
name: "Bucket with two status items"
510
description: "Test aggregating status of Bucket with two status items"
@@ -78,3 +83,203 @@ statusItems:
7883
resourceTemplateGeneration: 1
7984
operation: AggregateStatus
8085
output:
86+
aggregatedStatus:
87+
apiVersion: source.toolkit.fluxcd.io/v1beta2
88+
kind: Bucket
89+
metadata:
90+
name: sample
91+
namespace: test-bucket
92+
generation: 1
93+
spec:
94+
provider: generic
95+
interval: 5m0s
96+
bucketName: podinfo
97+
endpoint: minio.minio.svc.cluster.local:9000
98+
timeout: 60s
99+
insecure: true
100+
secretRef:
101+
name: fake-minio-credentials
102+
status:
103+
conditions:
104+
- type: Reconciling
105+
status: "True"
106+
reason: ProgressingWithRetry
107+
message: "member1=building artifact, member3=building artifact"
108+
observedGeneration: 1
109+
lastTransitionTime: "2023-04-29T14:02:31Z"
110+
- type: Ready
111+
status: "False"
112+
reason: AuthenticationFailed
113+
message: "member1=invalid 'fake-secret' secret data: required fields 'accesskey' and 'secretkey', member3=invalid 'fake-secret' secret data: required fields 'accesskey' and 'secretkey'"
114+
observedGeneration: 1
115+
lastTransitionTime: "2023-04-29T14:02:31Z"
116+
- type: FetchFailed
117+
status: "True"
118+
reason: AuthenticationFailed
119+
message: "member1=invalid 'fake-secret' secret data: required fields 'accesskey' and 'secretkey', member3=invalid 'fake-secret' secret data: required fields 'accesskey' and 'secretkey'"
120+
observedGeneration: 1
121+
lastTransitionTime: "2023-04-29T14:01:44Z"
122+
observedGeneration: 0
123+
url: ""
124+
---
125+
name: "Bucket with no status items"
126+
description: "AggregateStatus initializes empty status when no members exist"
127+
desiredObj:
128+
apiVersion: source.toolkit.fluxcd.io/v1beta2
129+
kind: Bucket
130+
metadata:
131+
name: sample
132+
namespace: test-bucket
133+
generation: 3
134+
operation: AggregateStatus
135+
output:
136+
aggregatedStatus:
137+
apiVersion: source.toolkit.fluxcd.io/v1beta2
138+
kind: Bucket
139+
metadata:
140+
name: sample
141+
namespace: test-bucket
142+
generation: 3
143+
status:
144+
url: ""
145+
observedGeneration: 3
146+
---
147+
name: "Bucket with stale member"
148+
description: "observedGeneration should not advance if any member is stale"
149+
desiredObj:
150+
apiVersion: source.toolkit.fluxcd.io/v1beta2
151+
kind: Bucket
152+
metadata:
153+
name: sample
154+
namespace: test-bucket
155+
generation: 5
156+
status:
157+
observedGeneration: 4
158+
statusItems:
159+
- status:
160+
generation: 5
161+
observedGeneration: 5
162+
resourceTemplateGeneration: 5
163+
- status:
164+
generation: 5
165+
observedGeneration: 4
166+
resourceTemplateGeneration: 5
167+
operation: AggregateStatus
168+
output:
169+
aggregatedStatus:
170+
apiVersion: source.toolkit.fluxcd.io/v1beta2
171+
kind: Bucket
172+
metadata:
173+
name: sample
174+
namespace: test-bucket
175+
generation: 5
176+
status:
177+
observedGeneration: 4
178+
url: ""
179+
---
180+
name: "Bucket condition merging with different reasons"
181+
description: "Conditions with same type but different reasons are not merged"
182+
desiredObj:
183+
apiVersion: source.toolkit.fluxcd.io/v1beta2
184+
kind: Bucket
185+
metadata:
186+
name: sample
187+
namespace: test-bucket
188+
statusItems:
189+
- clusterName: member1
190+
status:
191+
conditions:
192+
- type: Ready
193+
status: "True"
194+
reason: Succeeded
195+
message: ok
196+
- clusterName: member2
197+
status:
198+
conditions:
199+
- type: Ready
200+
status: "False"
201+
reason: Failed
202+
message: error
203+
operation: AggregateStatus
204+
output:
205+
aggregatedStatus:
206+
apiVersion: source.toolkit.fluxcd.io/v1beta2
207+
kind: Bucket
208+
metadata:
209+
name: sample
210+
namespace: test-bucket
211+
generation: 0
212+
status:
213+
conditions:
214+
- type: Ready
215+
status: "True"
216+
reason: Succeeded
217+
message: member1=ok
218+
- type: Ready
219+
status: "False"
220+
reason: Failed
221+
message: member2=error
222+
observedGeneration: 0
223+
url: ""
224+
---
225+
name: "Bucket ignores empty url"
226+
description: "Empty url fields are ignored during aggregation"
227+
desiredObj:
228+
apiVersion: source.toolkit.fluxcd.io/v1beta2
229+
kind: Bucket
230+
metadata:
231+
name: sample
232+
namespace: test-bucket
233+
statusItems:
234+
- status:
235+
url: ""
236+
- status:
237+
url: http://bucket/valid
238+
operation: AggregateStatus
239+
output:
240+
aggregatedStatus:
241+
apiVersion: source.toolkit.fluxcd.io/v1beta2
242+
kind: Bucket
243+
metadata:
244+
name: sample
245+
namespace: test-bucket
246+
generation: 0
247+
status:
248+
observedGeneration: 0
249+
url: http://bucket/valid
250+
---
251+
name: "Bucket with different artifacts picks last one"
252+
description: "AggregateStatus should pick the last artifact when members report different artifacts"
253+
desiredObj:
254+
apiVersion: source.toolkit.fluxcd.io/v1beta2
255+
kind: Bucket
256+
metadata:
257+
name: sample
258+
namespace: test-bucket
259+
generation: 1
260+
statusItems:
261+
- clusterName: member1
262+
status:
263+
artifact:
264+
path: artifact-a.tar.gz
265+
revision: rev-a
266+
- clusterName: member2
267+
status:
268+
artifact:
269+
path: artifact-b.tar.gz
270+
revision: rev-b
271+
operation: AggregateStatus
272+
output:
273+
aggregatedStatus:
274+
apiVersion: source.toolkit.fluxcd.io/v1beta2
275+
kind: Bucket
276+
metadata:
277+
name: sample
278+
namespace: test-bucket
279+
generation: 1
280+
status:
281+
artifact:
282+
path: artifact-b.tar.gz
283+
revision: rev-b
284+
observedGeneration: 0
285+
url: ""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# test case for interpreting dependencies of Bucket
2+
# case1. Bucket with secretRef dependency
3+
# case2. Bucket without secretRef
4+
# case3. Bucket with empty secretRef name
5+
6+
name: "Bucket with secretRef dependency"
7+
description: "InterpretDependency returns Secret reference"
8+
observedObj:
9+
apiVersion: source.toolkit.fluxcd.io/v1beta2
10+
kind: Bucket
11+
metadata:
12+
namespace: default
13+
spec:
14+
secretRef:
15+
name: bucket-secret
16+
operation: InterpretDependency
17+
output:
18+
dependencies:
19+
- apiVersion: v1
20+
kind: Secret
21+
name: bucket-secret
22+
namespace: default
23+
---
24+
name: "Bucket without secretRef"
25+
description: "No dependencies when secretRef missing"
26+
observedObj:
27+
apiVersion: source.toolkit.fluxcd.io/v1beta2
28+
kind: Bucket
29+
spec: {}
30+
operation: InterpretDependency
31+
output:
32+
dependencies: []
33+
---
34+
name: "Bucket with empty secretRef name"
35+
description: "Empty secretRef name should be ignored"
36+
desiredObj:
37+
apiVersion: source.toolkit.fluxcd.io/v1beta2
38+
kind: Bucket
39+
metadata:
40+
name: sample
41+
namespace: test-bucket
42+
spec:
43+
secretRef:
44+
name: ""
45+
operation: InterpretDependency
46+
output:
47+
dependencies: []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# test case for interpreting health of Bucket
2+
# case1. Bucket Ready=True Succeeded should be healthy
3+
# case2. Bucket Ready=True but wrong reason should be unhealthy
4+
# case3. Bucket Ready=False should be unhealthy
5+
# case4. Bucket without Ready condition should be unhealthy
6+
# case5. Bucket with empty conditions should be unhealthy
7+
# case6. Bucket unhealthy when status is nil
8+
# case7. Bucket unhealthy when status.conditions is nil
9+
10+
name: "Bucket healthy when Ready=True and reason=Succeeded"
11+
description: "Health should be true when Ready condition is True and reason is Succeeded"
12+
observedObj:
13+
apiVersion: source.toolkit.fluxcd.io/v1beta2
14+
kind: Bucket
15+
status:
16+
conditions:
17+
- type: Ready
18+
status: "True"
19+
reason: Succeeded
20+
operation: InterpretHealth
21+
output:
22+
healthy: true
23+
---
24+
name: "Bucket unhealthy when Ready=True but wrong reason"
25+
description: "Health should be false when Ready is True but reason is not Succeeded"
26+
observedObj:
27+
apiVersion: source.toolkit.fluxcd.io/v1beta2
28+
kind: Bucket
29+
status:
30+
conditions:
31+
- type: Ready
32+
status: "True"
33+
reason: Progressing
34+
operation: InterpretHealth
35+
output:
36+
healthy: false
37+
---
38+
name: "Bucket unhealthy when Ready=False"
39+
description: "Health should be false when Ready condition is False"
40+
observedObj:
41+
apiVersion: source.toolkit.fluxcd.io/v1beta2
42+
kind: Bucket
43+
status:
44+
conditions:
45+
- type: Ready
46+
status: "False"
47+
reason: Failed
48+
operation: InterpretHealth
49+
output:
50+
healthy: false
51+
---
52+
name: "Bucket unhealthy without Ready condition"
53+
description: "Health should be false when Ready condition is missing"
54+
observedObj:
55+
apiVersion: source.toolkit.fluxcd.io/v1beta2
56+
kind: Bucket
57+
status:
58+
conditions:
59+
- type: Reconciling
60+
status: "True"
61+
operation: InterpretHealth
62+
output:
63+
healthy: false
64+
---
65+
name: "Bucket unhealthy with empty conditions"
66+
description: "Health should be false when status.conditions is empty"
67+
observedObj:
68+
apiVersion: source.toolkit.fluxcd.io/v1beta2
69+
kind: Bucket
70+
status:
71+
conditions: []
72+
operation: InterpretHealth
73+
output:
74+
healthy: false
75+
---
76+
name: "Bucket unhealthy when status is nil"
77+
description: "Health should be false when status is nil"
78+
observedObj:
79+
apiVersion: source.toolkit.fluxcd.io/v1beta2
80+
kind: Bucket
81+
operation: InterpretHealth
82+
output:
83+
healthy: false
84+
---
85+
name: "Bucket unhealthy when status.conditions is nil"
86+
description: "Health should be false when status.conditions is nil"
87+
observedObj:
88+
apiVersion: source.toolkit.fluxcd.io/v1beta2
89+
kind: Bucket
90+
status: {}
91+
operation: InterpretHealth
92+
output:
93+
healthy: false

0 commit comments

Comments
 (0)