@@ -19,7 +19,6 @@ import (
1919 "k8s.io/apimachinery/pkg/util/uuid"
2020 "k8s.io/apimachinery/pkg/util/wait"
2121 "k8s.io/client-go/util/retry"
22- "k8s.io/utils/ptr"
2322 "sigs.k8s.io/controller-runtime/pkg/client"
2423
2524 rolloutmanagerv1alpha1 "github.com/argoproj-labs/argo-rollouts-manager/api/v1alpha1"
@@ -275,7 +274,7 @@ func CreateNamespace(name string) *corev1.Namespace {
275274 // If the Namespace already exists, delete it first
276275 if err := k8sClient .Get (context .Background (), client .ObjectKeyFromObject (ns ), ns ); err == nil {
277276 // Namespace exists, so delete it first
278- Expect (deleteNamespace (context .Background (), ns .Name , k8sClient )).To (Succeed ())
277+ Expect (deleteNamespaceAndVerify (context .Background (), ns .Name , k8sClient )).To (Succeed ())
279278 }
280279
281280 ns = & corev1.Namespace {ObjectMeta : metav1.ObjectMeta {
@@ -304,7 +303,7 @@ func CreateManagedNamespace(name string, managedByNamespace string) *corev1.Name
304303 // If the Namespace already exists, delete it first
305304 if err := k8sClient .Get (context .Background (), client .ObjectKeyFromObject (ns ), ns ); err == nil {
306305 // Namespace exists, so delete it first
307- Expect (deleteNamespace (context .Background (), ns .Name , k8sClient )).To (Succeed ())
306+ Expect (deleteNamespaceAndVerify (context .Background (), ns .Name , k8sClient )).To (Succeed ())
308307 }
309308
310309 ns = & corev1.Namespace {ObjectMeta : metav1.ObjectMeta {
@@ -344,12 +343,10 @@ func DeleteNamespace(ns *corev1.Namespace) {
344343
345344 k8sClient , _ , err := utils .GetE2ETestKubeClientWithError ()
346345 Expect (err ).ToNot (HaveOccurred ())
347- err = k8sClient .Delete (context .Background (), ns , & client.DeleteOptions {PropagationPolicy : ptr .To (metav1 .DeletePropagationForeground )})
348346
349- // Error shouldn't occur, UNLESS it's because the NS no longer exists
350- if err != nil && ! apierr .IsNotFound (err ) {
351- Expect (err ).ToNot (HaveOccurred ())
352- }
347+ err = deleteNamespaceAndVerify (context .Background (), ns .Name , k8sClient )
348+ Expect (err ).ToNot (HaveOccurred ())
349+
353350}
354351
355352// EnvNonOLM checks if NON_OLM var is set; this variable is set when testing on GitOps operator that is not installed via OLM
@@ -708,15 +705,15 @@ func ensureTestNamespacesDeleted(ctx context.Context, k8sClient client.Client) e
708705
709706 // delete selected namespaces
710707 for _ , namespace := range nsList .Items {
711- if err := deleteNamespace (ctx , namespace .Name , k8sClient ); err != nil {
708+ if err := deleteNamespaceAndVerify (ctx , namespace .Name , k8sClient ); err != nil {
712709 return fmt .Errorf ("unable to delete namespace '%s': %w" , namespace .Name , err )
713710 }
714711 }
715712 return nil
716713}
717714
718- // deleteNamespace deletes a namespace, and waits for it to be reported as deleted.
719- func deleteNamespace (ctx context.Context , namespaceParam string , k8sClient client.Client ) error {
715+ // deleteNamespaceAndVerify deletes a namespace, and waits for it to be reported as deleted.
716+ func deleteNamespaceAndVerify (ctx context.Context , namespaceParam string , k8sClient client.Client ) error {
720717
721718 GinkgoWriter .Println ("Deleting Namespace" , namespaceParam )
722719
@@ -980,3 +977,7 @@ func outputPodLog(podSubstring string) {
980977 GinkgoWriter .Println ("----------------------------------------------------------------" )
981978
982979}
980+
981+ func IsUpstreamOperatorTests () bool {
982+ return false // This function should return true if running from argocd-operator repo, false if running from gitops-operator repo. This is to distinguish between tests in upstream argocd-operator and downstream gitops-operator repos.
983+ }
0 commit comments