@@ -162,22 +162,6 @@ var _ = Describe("Collector", Ordered, func() {
162
162
},
163
163
},
164
164
},
165
- {
166
- Name : "upstream3" ,
167
- ErrorMsg : "there is an error here" ,
168
- Endpoints : []resolver.Endpoint {
169
- {
170
- Address : "endpoint1" ,
171
- Port : 80 ,
172
- }, {
173
- Address : "endpoint2" ,
174
- Port : 80 ,
175
- }, {
176
- Address : "endpoint3" ,
177
- Port : 80 ,
178
- },
179
- },
180
- },
181
165
},
182
166
}
183
167
@@ -242,8 +226,8 @@ var _ = Describe("Collector", Ordered, func() {
242
226
243
227
Describe ("NGF resource count collector" , func () {
244
228
var (
245
- graph1 * graph.Graph
246
- config1 * dataplane.Configuration
229
+ graph1 * graph.Graph
230
+ config1 , invalidUpstreamsConfig * dataplane.Configuration
247
231
)
248
232
249
233
BeforeAll (func () {
@@ -280,6 +264,32 @@ var _ = Describe("Collector", Ordered, func() {
280
264
},
281
265
},
282
266
}
267
+
268
+ invalidUpstreamsConfig = & dataplane.Configuration {
269
+ Upstreams : []dataplane.Upstream {
270
+ {
271
+ Name : "invalidUpstream" ,
272
+ ErrorMsg : "there is an error here" ,
273
+ Endpoints : []resolver.Endpoint {
274
+ {
275
+ Address : "endpoint1" ,
276
+ Port : 80 ,
277
+ }, {
278
+ Address : "endpoint2" ,
279
+ Port : 80 ,
280
+ }, {
281
+ Address : "endpoint3" ,
282
+ Port : 80 ,
283
+ },
284
+ },
285
+ },
286
+ {
287
+ Name : "emptyUpstream" ,
288
+ ErrorMsg : "" ,
289
+ Endpoints : []resolver.Endpoint {},
290
+ },
291
+ },
292
+ }
283
293
})
284
294
285
295
When ("collecting NGF resource counts" , func () {
@@ -314,6 +324,24 @@ var _ = Describe("Collector", Ordered, func() {
314
324
Expect (expData ).To (Equal (data ))
315
325
})
316
326
327
+ It ("ignores invalid and empty upstreams" , func () {
328
+ fakeGraphGetter .GetLatestGraphReturns (& graph.Graph {})
329
+ fakeConfigurationGetter .GetLatestConfigurationReturns (invalidUpstreamsConfig )
330
+ expData .NGFResourceCounts = telemetry.NGFResourceCounts {
331
+ Gateways : 0 ,
332
+ GatewayClasses : 0 ,
333
+ HTTPRoutes : 0 ,
334
+ Secrets : 0 ,
335
+ Services : 0 ,
336
+ Endpoints : 0 ,
337
+ }
338
+
339
+ data , err := dataCollector .Collect (ctx )
340
+
341
+ Expect (err ).To (BeNil ())
342
+ Expect (expData ).To (Equal (data ))
343
+ })
344
+
317
345
When ("it encounters an error while collecting data" , func () {
318
346
BeforeEach (func () {
319
347
fakeGraphGetter .GetLatestGraphReturns (& graph.Graph {})
0 commit comments