Skip to content

Commit 5c5e862

Browse files
test/e2e: more fixes
Signed-off-by: Steve Kuznetsov <[email protected]>
1 parent 87a3d95 commit 5c5e862

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

test/e2e/subscription_e2e_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
"os"
78
"path/filepath"
89
"reflect"
910
"strings"
@@ -3100,6 +3101,11 @@ func fetchSubscription(crc versioned.Interface, namespace, name string, checker
31003101

31013102
func buildSubscriptionCleanupFunc(crc versioned.Interface, subscription *operatorsv1alpha1.Subscription) cleanupFunc {
31023103
return func() {
3104+
if env := os.Getenv("SKIP_CLEANUP"); env != "" {
3105+
fmt.Printf("Skipping cleanup of install plan for subscription %s/%s...\n", subscription.GetNamespace(), subscription.GetName())
3106+
return
3107+
}
3108+
31033109
if installPlanRef := subscription.Status.InstallPlanRef; installPlanRef != nil {
31043110
installPlan, err := crc.OperatorsV1alpha1().InstallPlans(subscription.GetNamespace()).Get(context.Background(), installPlanRef.Name, metav1.GetOptions{})
31053111
if err == nil {

test/e2e/user_defined_sa_test.go

+17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package e2e
33
import (
44
"context"
55
"fmt"
6+
"os"
67

78
"github.com/blang/semver/v4"
89
. "github.com/onsi/ginkgo/v2"
@@ -242,6 +243,10 @@ func newServiceAccount(client operatorclient.ClientInterface, namespace, name st
242243
Expect(sa).ToNot(BeNil())
243244

244245
cleanup = func() {
246+
if env := os.Getenv("SKIP_CLEANUP"); env != "" {
247+
fmt.Printf("Skipping cleanup of service account %s/%s...\n", sa.GetNamespace(), sa.GetName())
248+
return
249+
}
245250
err := client.KubernetesInterface().CoreV1().ServiceAccounts(sa.GetNamespace()).Delete(context.TODO(), sa.GetName(), metav1.DeleteOptions{})
246251
Expect(err).ToNot(HaveOccurred())
247252
}
@@ -268,6 +273,10 @@ func newOperatorGroupWithServiceAccount(client versioned.Interface, namespace, n
268273
Expect(og).ToNot(BeNil())
269274

270275
cleanup = func() {
276+
if env := os.Getenv("SKIP_CLEANUP"); env != "" {
277+
fmt.Printf("Skipping cleanup of operator group %s/%s...\n", og.GetNamespace(), og.GetName())
278+
return
279+
}
271280
err := client.OperatorsV1().OperatorGroups(og.GetNamespace()).Delete(context.TODO(), og.GetName(), metav1.DeleteOptions{})
272281
Expect(err).ToNot(HaveOccurred())
273282
}
@@ -538,6 +547,14 @@ func grantPermission(t GinkgoTInterface, client operatorclient.ClientInterface,
538547
require.NoError(t, err)
539548

540549
cleanup = func() {
550+
if env := os.Getenv("SKIP_CLEANUP"); env != "" {
551+
fmt.Printf("Skipping cleanup of role %s/%s...\n", role.GetNamespace(), role.GetName())
552+
fmt.Printf("Skipping cleanup of role binding %s/%s...\n", binding.GetNamespace(), binding.GetName())
553+
fmt.Printf("Skipping cleanup of cluster role %s...\n", clusterrole.GetName())
554+
fmt.Printf("Skipping cleanup of cluster role binding %s...\n", clusterbinding.GetName())
555+
return
556+
}
557+
541558
err := client.KubernetesInterface().RbacV1().Roles(role.GetNamespace()).Delete(context.TODO(), role.GetName(), metav1.DeleteOptions{})
542559
require.NoError(t, err)
543560

0 commit comments

Comments
 (0)