@@ -858,6 +858,9 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) {
858
858
Namespace : metav1 .NamespaceDefault ,
859
859
},
860
860
Spec : v1beta1.OpenTelemetryCollectorSpec {
861
+ OpenTelemetryCommonFields : v1beta1.OpenTelemetryCommonFields {
862
+ PodDisruptionBudget : & v1beta1.PodDisruptionBudgetSpec {},
863
+ },
861
864
ConfigVersions : 1 ,
862
865
TargetAllocator : v1beta1.TargetAllocatorEmbedded {
863
866
Enabled : true ,
@@ -937,6 +940,8 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) {
937
940
}, time .Second * 5 , time .Millisecond )
938
941
939
942
// modify the ConfigMap, it should be kept
943
+ // wait a second first, as K8s creation timestamps only have second precision
944
+ time .Sleep (time .Second )
940
945
err = k8sClient .Get (clientCtx , nsn , collector )
941
946
require .NoError (t , err )
942
947
collector .Spec .Config .Exporters .Object ["debug" ] = map [string ]interface {}{}
@@ -961,6 +966,8 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) {
961
966
}, time .Second * 5 , time .Millisecond )
962
967
963
968
// modify the ConfigMap again, the oldest one is still kept, but is dropped after next reconciliation
969
+ // wait a second first, as K8s creation timestamps only have second precision
970
+ time .Sleep (time .Second )
964
971
err = k8sClient .Get (clientCtx , nsn , collector )
965
972
require .NoError (t , err )
966
973
collector .Spec .Config .Exporters .Object ["debug/2" ] = map [string ]interface {}{}
@@ -978,8 +985,7 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) {
978
985
979
986
assert .EventuallyWithT (t , func (collect * assert.CollectT ) {
980
987
configMaps := & v1.ConfigMapList {}
981
- // use the reconciler client here to ensure it sees the new ConfigMap, before running the next reconciliation
982
- listErr := reconciler .Client .List (clientCtx , configMaps , opts ... )
988
+ listErr := k8sClient .List (clientCtx , configMaps , opts ... )
983
989
assert .NoError (collect , listErr )
984
990
assert .NotEmpty (collect , configMaps )
985
991
assert .Len (collect , configMaps .Items , 4 )
@@ -993,12 +999,8 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) {
993
999
listErr := k8sClient .List (clientCtx , configMaps , opts ... )
994
1000
assert .NoError (collect , listErr )
995
1001
assert .NotEmpty (collect , configMaps )
996
- // actual deletion can happen with a delay in a K8s cluster, check the timestamp instead to speed things up
997
- items := slices .DeleteFunc (configMaps .Items , func (item v1.ConfigMap ) bool {
998
- return item .DeletionTimestamp != nil
999
- })
1000
- assert .Len (collect , items , 3 )
1001
- }, time .Second * 30 , time .Second ) // not sure why this can take so long to bubble up
1002
+ assert .Len (collect , configMaps .Items , 3 )
1003
+ }, time .Second * 5 , time .Second )
1002
1004
}
1003
1005
1004
1006
func TestOpAMPBridgeReconciler_Reconcile (t * testing.T ) {
0 commit comments