@@ -69,24 +69,15 @@ var (
69
69
70
70
type check [T any ] func (t * testing.T , params T )
71
71
72
- func newParamsAssertNoErr (t * testing.T , taContainerImage string , file string ) v1alpha1.OpenTelemetryCollector {
73
- p , err := newParams (taContainerImage , file )
74
- assert .NoError (t , err )
75
- if len (taContainerImage ) == 0 {
76
- p .Spec .TargetAllocator .Enabled = false
77
- }
78
- return p
79
- }
80
-
81
72
func TestOpenTelemetryCollectorReconciler_Reconcile (t * testing.T ) {
82
- addedMetadataDeployment := paramsWithMode (v1alpha1 .ModeDeployment )
73
+ addedMetadataDeployment := testCollectorWithMode (v1alpha1 .ModeDeployment )
83
74
addedMetadataDeployment .Labels = map [string ]string {
84
75
labelName : labelVal ,
85
76
}
86
77
addedMetadataDeployment .Annotations = map [string ]string {
87
78
annotationName : annotationVal ,
88
79
}
89
- deploymentExtraPorts := paramsWithModeAndReplicas (v1alpha1 .ModeDeployment , 3 )
80
+ deploymentExtraPorts := testCollectorWithModeAndReplicas (v1alpha1 .ModeDeployment , 3 )
90
81
deploymentExtraPorts .Spec .Ports = append (deploymentExtraPorts .Spec .Ports , extraPorts )
91
82
deploymentExtraPorts .Spec .DeploymentUpdateStrategy = appsv1.DeploymentStrategy {
92
83
RollingUpdate : & appsv1.RollingUpdateDeployment {
@@ -100,20 +91,20 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) {
100
91
},
101
92
},
102
93
}
103
- ingressParams := newParamsAssertNoErr (t , "" , testFileIngress )
94
+ ingressParams := testCollectorAssertNoErr (t , "" , testFileIngress )
104
95
ingressParams .Spec .Ingress .Type = "ingress"
105
- updatedIngressParams := newParamsAssertNoErr (t , "" , testFileIngress )
96
+ updatedIngressParams := testCollectorAssertNoErr (t , "" , testFileIngress )
106
97
updatedIngressParams .Spec .Ingress .Type = "ingress"
107
98
updatedIngressParams .Spec .Ingress .Annotations = map [string ]string {"blub" : "blob" }
108
99
updatedIngressParams .Spec .Ingress .Hostname = expectHostname
109
- routeParams := newParamsAssertNoErr (t , "" , testFileIngress )
100
+ routeParams := testCollectorAssertNoErr (t , "" , testFileIngress )
110
101
routeParams .Spec .Ingress .Type = v1alpha1 .IngressTypeRoute
111
102
routeParams .Spec .Ingress .Route .Termination = v1alpha1 .TLSRouteTerminationTypeInsecure
112
- updatedRouteParams := newParamsAssertNoErr (t , "" , testFileIngress )
103
+ updatedRouteParams := testCollectorAssertNoErr (t , "" , testFileIngress )
113
104
updatedRouteParams .Spec .Ingress .Type = v1alpha1 .IngressTypeRoute
114
105
updatedRouteParams .Spec .Ingress .Route .Termination = v1alpha1 .TLSRouteTerminationTypeInsecure
115
106
updatedRouteParams .Spec .Ingress .Hostname = expectHostname
116
- deletedParams := paramsWithMode (v1alpha1 .ModeDeployment )
107
+ deletedParams := testCollectorWithMode (v1alpha1 .ModeDeployment )
117
108
now := metav1 .NewTime (time .Now ())
118
109
deletedParams .DeletionTimestamp = & now
119
110
@@ -199,7 +190,7 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) {
199
190
{
200
191
name : "invalid mode" ,
201
192
args : args {
202
- params : paramsWithMode ("bad" ),
193
+ params : testCollectorWithMode ("bad" ),
203
194
updates : []v1alpha1.OpenTelemetryCollector {},
204
195
},
205
196
want : []want {
@@ -216,7 +207,7 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) {
216
207
{
217
208
name : "invalid prometheus configuration" ,
218
209
args : args {
219
- params : newParamsAssertNoErr (t , baseTaImage , testFileIngress ),
210
+ params : testCollectorAssertNoErr (t , baseTaImage , testFileIngress ),
220
211
updates : []v1alpha1.OpenTelemetryCollector {},
221
212
},
222
213
want : []want {
@@ -307,8 +298,8 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) {
307
298
{
308
299
name : "hpa v2 deployment collector" ,
309
300
args : args {
310
- params : paramsWithHPA (3 , 5 ),
311
- updates : []v1alpha1.OpenTelemetryCollector {paramsWithHPA (1 , 9 )},
301
+ params : testCollectorWithHPA (3 , 5 ),
302
+ updates : []v1alpha1.OpenTelemetryCollector {testCollectorWithHPA (1 , 9 )},
312
303
},
313
304
want : []want {
314
305
{
@@ -350,8 +341,8 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) {
350
341
{
351
342
name : "policy v1 deployment collector" ,
352
343
args : args {
353
- params : paramsWithPolicy (1 , 0 ),
354
- updates : []v1alpha1.OpenTelemetryCollector {paramsWithPolicy (0 , 1 )},
344
+ params : testCollectorWithPDB (1 , 0 ),
345
+ updates : []v1alpha1.OpenTelemetryCollector {testCollectorWithPDB (0 , 1 )},
355
346
},
356
347
want : []want {
357
348
{
@@ -389,7 +380,7 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) {
389
380
{
390
381
name : "daemonset collector" ,
391
382
args : args {
392
- params : paramsWithMode (v1alpha1 .ModeDaemonSet ),
383
+ params : testCollectorWithMode (v1alpha1 .ModeDaemonSet ),
393
384
},
394
385
want : []want {
395
386
{
@@ -409,11 +400,11 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) {
409
400
{
410
401
name : "stateful should update collector with TA" ,
411
402
args : args {
412
- params : paramsWithMode (v1alpha1 .ModeStatefulSet ),
403
+ params : testCollectorWithMode (v1alpha1 .ModeStatefulSet ),
413
404
updates : []v1alpha1.OpenTelemetryCollector {
414
- newParamsAssertNoErr (t , baseTaImage , promFile ),
415
- newParamsAssertNoErr (t , baseTaImage , updatedPromFile ),
416
- newParamsAssertNoErr (t , updatedTaImage , updatedPromFile ),
405
+ testCollectorAssertNoErr (t , baseTaImage , promFile ),
406
+ testCollectorAssertNoErr (t , baseTaImage , updatedPromFile ),
407
+ testCollectorAssertNoErr (t , updatedTaImage , updatedPromFile ),
417
408
},
418
409
},
419
410
want : []want {
@@ -456,7 +447,7 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) {
456
447
exists , err = populateObjectIfExists (t , & v1.ServiceAccount {}, namespacedObjectName (naming .TargetAllocatorServiceAccount (params .Name ), params .Namespace ))
457
448
assert .NoError (t , err )
458
449
assert .True (t , exists )
459
- promConfig , err := ta .ConfigToPromConfig (newParamsAssertNoErr (t , baseTaImage , promFile ).Spec .Config )
450
+ promConfig , err := ta .ConfigToPromConfig (testCollectorAssertNoErr (t , baseTaImage , promFile ).Spec .Config )
460
451
assert .NoError (t , err )
461
452
462
453
taConfig := make (map [interface {}]interface {})
0 commit comments