@@ -858,6 +858,9 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) {
858858 Namespace : metav1 .NamespaceDefault ,
859859 },
860860 Spec : v1beta1.OpenTelemetryCollectorSpec {
861+ OpenTelemetryCommonFields : v1beta1.OpenTelemetryCommonFields {
862+ PodDisruptionBudget : & v1beta1.PodDisruptionBudgetSpec {},
863+ },
861864 ConfigVersions : 1 ,
862865 TargetAllocator : v1beta1.TargetAllocatorEmbedded {
863866 Enabled : true ,
@@ -937,6 +940,8 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) {
937940 }, time .Second * 5 , time .Millisecond )
938941
939942 // 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 )
940945 err = k8sClient .Get (clientCtx , nsn , collector )
941946 require .NoError (t , err )
942947 collector .Spec .Config .Exporters .Object ["debug" ] = map [string ]interface {}{}
@@ -961,6 +966,8 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) {
961966 }, time .Second * 5 , time .Millisecond )
962967
963968 // 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 )
964971 err = k8sClient .Get (clientCtx , nsn , collector )
965972 require .NoError (t , err )
966973 collector .Spec .Config .Exporters .Object ["debug/2" ] = map [string ]interface {}{}
@@ -978,8 +985,7 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) {
978985
979986 assert .EventuallyWithT (t , func (collect * assert.CollectT ) {
980987 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 ... )
983989 assert .NoError (collect , listErr )
984990 assert .NotEmpty (collect , configMaps )
985991 assert .Len (collect , configMaps .Items , 4 )
@@ -993,12 +999,8 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) {
993999 listErr := k8sClient .List (clientCtx , configMaps , opts ... )
9941000 assert .NoError (collect , listErr )
9951001 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 )
10021004}
10031005
10041006func TestOpAMPBridgeReconciler_Reconcile (t * testing.T ) {
0 commit comments