| @@ -110,11 +110,12 @@ func TestCollectionReconcile(t *testing.T) { |
|
|
| 110 |
110 |
Interval: "10s", |
| 111 |
111 |
}, |
| 112 |
112 |
} |
| 113 |
|
- |
|
113 |
+ exampleCollectorConfigMapWithoutScrapeConfig := "global: {}\ngoogle_cloud:\n export: {}\n" |
| 114 |
114 |
testCases := []struct { |
| 115 |
|
-desc string |
| 116 |
|
-input monitoringv1.MonitoringCRD |
| 117 |
|
-expected monitoringv1.MonitoringCRD |
|
115 |
+desc string |
|
116 |
+input monitoringv1.MonitoringCRD |
|
117 |
+expected monitoringv1.MonitoringCRD |
|
118 |
+expectedCollectorConfigMap *string |
| 118 |
119 |
}{ |
| 119 |
120 |
{ |
| 120 |
121 |
desc: "podmonitoring: no update", |
| @@ -413,6 +414,7 @@ func TestCollectionReconcile(t *testing.T) { |
|
|
| 413 |
414 |
}, |
| 414 |
415 |
}, |
| 415 |
416 |
}, |
|
417 |
+expectedCollectorConfigMap: &exampleCollectorConfigMapWithoutScrapeConfig, |
| 416 |
418 |
}, |
| 417 |
419 |
} |
| 418 |
420 |
|
| @@ -466,6 +468,21 @@ func TestCollectionReconcile(t *testing.T) { |
|
|
| 466 |
468 |
t.Fatal(err) |
| 467 |
469 |
} |
| 468 |
470 |
|
|
471 |
+if tc.expectedCollectorConfigMap != nil { |
|
472 |
+collectorConfigMap := &corev1.ConfigMap{ |
|
473 |
+ObjectMeta: metav1.ObjectMeta{ |
|
474 |
+Namespace: opts.OperatorNamespace, |
|
475 |
+Name: NameCollector, |
|
476 |
+ }, |
|
477 |
+ } |
|
478 |
+if err := kubeClient.Get(ctx, client.ObjectKeyFromObject(collectorConfigMap), collectorConfigMap); err != nil { |
|
479 |
+t.Fatal(err) |
|
480 |
+ } |
|
481 |
+if diff := cmp.Diff(*tc.expectedCollectorConfigMap, collectorConfigMap.Data["config.yaml"]); diff != "" { |
|
482 |
+t.Fatalf("unexpected collector configmap (-want, +got): %s", diff) |
|
483 |
+ } |
|
484 |
+ } |
|
485 |
+ |
| 469 |
486 |
if err := kubeClient.Get(ctx, client.ObjectKeyFromObject(tc.input), tc.input); err != nil { |
| 470 |
487 |
t.Fatal(err) |
| 471 |
488 |
} |