@@ -978,7 +978,8 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) {
978
978
979
979
assert .EventuallyWithT (t , func (collect * assert.CollectT ) {
980
980
configMaps := & v1.ConfigMapList {}
981
- listErr := k8sClient .List (clientCtx , configMaps , opts ... )
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 ... )
982
983
assert .NoError (collect , listErr )
983
984
assert .NotEmpty (collect , configMaps )
984
985
assert .Len (collect , configMaps .Items , 4 )
@@ -992,8 +993,12 @@ func TestOpenTelemetryCollectorReconciler_VersionedConfigMaps(t *testing.T) {
992
993
listErr := k8sClient .List (clientCtx , configMaps , opts ... )
993
994
assert .NoError (collect , listErr )
994
995
assert .NotEmpty (collect , configMaps )
995
- assert .Len (collect , configMaps .Items , 3 )
996
- }, time .Second * 5 , time .Millisecond )
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
997
1002
}
998
1003
999
1004
func TestOpAMPBridgeReconciler_Reconcile (t * testing.T ) {
0 commit comments