From 469f102b37872bf155f8397b858bca8c11c9ff82 Mon Sep 17 00:00:00 2001 From: Christian Schlotter Date: Mon, 18 Dec 2023 11:50:00 +0100 Subject: [PATCH] Fix finalizers test to not only rely on namespaced name --- test/framework/finalizers_helpers.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/framework/finalizers_helpers.go b/test/framework/finalizers_helpers.go index ffb865886178..49eaa3ce2b84 100644 --- a/test/framework/finalizers_helpers.go +++ b/test/framework/finalizers_helpers.go @@ -111,7 +111,7 @@ func getObjectsWithFinalizers(ctx context.Context, proxy ClusterProxy, namespace setFinalizers := obj.GetFinalizers() if len(setFinalizers) > 0 { - objsWithFinalizers[client.ObjectKey{Namespace: node.Object.Namespace, Name: node.Object.Name}.String()] = obj + objsWithFinalizers[fmt.Sprintf("%s/%s/%s", node.Object.Kind, node.Object.Namespace, node.Object.Name)] = obj } } @@ -124,11 +124,11 @@ func assertFinalizersExist(ctx context.Context, proxy ClusterProxy, namespace st var allErrs []error finalObjsWithFinalizers := getObjectsWithFinalizers(ctx, proxy, namespace) - for objNamespacedName, obj := range initialObjsWithFinalizers { + for objKindNamespacedName, obj := range initialObjsWithFinalizers { // verify if finalizers for this resource were set on reconcile - if _, valid := finalObjsWithFinalizers[objNamespacedName]; !valid { - allErrs = append(allErrs, fmt.Errorf("no finalizers set for %s/%s", - obj.GetKind(), objNamespacedName)) + if _, valid := finalObjsWithFinalizers[objKindNamespacedName]; !valid { + allErrs = append(allErrs, fmt.Errorf("no finalizers set for %s", + objKindNamespacedName)) continue } @@ -138,10 +138,10 @@ func assertFinalizersExist(ctx context.Context, proxy ClusterProxy, namespace st continue } - setFinalizers := finalObjsWithFinalizers[objNamespacedName].GetFinalizers() + setFinalizers := finalObjsWithFinalizers[objKindNamespacedName].GetFinalizers() if !reflect.DeepEqual(expectedFinalizers, setFinalizers) { - allErrs = append(allErrs, fmt.Errorf("expected finalizers do not exist for %s/%s: expected: %v, found: %v", - obj.GetKind(), objNamespacedName, expectedFinalizers, setFinalizers)) + allErrs = append(allErrs, fmt.Errorf("expected finalizers do not exist for %s: expected: %v, found: %v", + objKindNamespacedName, expectedFinalizers, setFinalizers)) } }