Skip to content

Commit dcea7cc

Browse files
committed
Address review comments
Signed-off-by: chiragkyal <ckyal@redhat.com>
1 parent 21ac393 commit dcea7cc

2 files changed

Lines changed: 33 additions & 7 deletions

File tree

test/e2e/trustmanager_bundle_test.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,25 @@ var _ = Describe("Bundle", Ordered, Label("Platform:Generic", "Feature:TrustMana
7575
var (
7676
testNS *corev1.Namespace
7777
testCertPEM1, testCertPEM2, expiredCertPEM string
78+
79+
originalUnsupportedAddonFeatures string
80+
originalOperatorLogLevel string
7881
)
7982

8083
BeforeAll(func() {
81-
By("enabling TrustManager feature gate")
82-
err := patchSubscriptionWithEnvVars(ctx, loader, map[string]string{
84+
By("capturing original UNSUPPORTED_ADDON_FEATURES from subscription before patching")
85+
var err error
86+
originalUnsupportedAddonFeatures, err = getSubscriptionEnvVar(ctx, loader, "UNSUPPORTED_ADDON_FEATURES")
87+
Expect(err).ShouldNot(HaveOccurred())
88+
89+
By("capturing original OPERATOR_LOG_LEVEL from subscription before patching")
90+
originalOperatorLogLevel, err = getSubscriptionEnvVar(ctx, loader, "OPERATOR_LOG_LEVEL")
91+
Expect(err).ShouldNot(HaveOccurred())
92+
93+
By("enabling TrustManager feature gate via subscription")
94+
err = patchSubscriptionWithEnvVars(ctx, loader, map[string]string{
8395
"UNSUPPORTED_ADDON_FEATURES": "TrustManager=true",
96+
"OPERATOR_LOG_LEVEL": "4",
8497
})
8598
Expect(err).ShouldNot(HaveOccurred())
8699

@@ -109,6 +122,23 @@ var _ = Describe("Bundle", Ordered, Label("Platform:Generic", "Feature:TrustMana
109122
testNS = createNamespaceWithCleanup(ctx, "bundle-e2e-", map[string]string{bundleTestNamespaceLabel: "true"})
110123
})
111124

125+
AfterAll(func() {
126+
By("restoring UNSUPPORTED_ADDON_FEATURES and OPERATOR_LOG_LEVEL on subscription to pre-suite values")
127+
err := patchSubscriptionWithEnvVars(ctx, loader, map[string]string{
128+
"UNSUPPORTED_ADDON_FEATURES": originalUnsupportedAddonFeatures,
129+
"OPERATOR_LOG_LEVEL": originalOperatorLogLevel,
130+
})
131+
Expect(err).ShouldNot(HaveOccurred())
132+
if originalUnsupportedAddonFeatures == "" {
133+
By("waiting for operator deployment to rollout after removing UNSUPPORTED_ADDON_FEATURES")
134+
err = waitForDeploymentEnvVarRemovedAndRollout(ctx, operatorNamespace, operatorDeploymentName, "UNSUPPORTED_ADDON_FEATURES", lowTimeout)
135+
} else {
136+
By("waiting for operator deployment to rollout with restored UNSUPPORTED_ADDON_FEATURES")
137+
err = waitForDeploymentEnvVarAndRollout(ctx, operatorNamespace, operatorDeploymentName, "UNSUPPORTED_ADDON_FEATURES", originalUnsupportedAddonFeatures, lowTimeout)
138+
}
139+
Expect(err).ShouldNot(HaveOccurred())
140+
})
141+
112142
// ===== Group 1: Default TrustManager =====
113143
Context("with default TrustManager configuration", Ordered, func() {
114144
BeforeAll(func() { createTrustManager(ctx, newTrustManagerCR()) })

test/e2e/trustmanager_helpers_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,7 @@ func deleteBundle(ctx context.Context, name string) {
302302

303303
func createBundleWithCleanup(ctx context.Context, bundle *trustapi.Bundle) {
304304
Eventually(func() error {
305-
err := bundleClient.Create(ctx, bundle)
306-
if apierrors.IsAlreadyExists(err) {
307-
return nil
308-
}
309-
return err
305+
return bundleClient.Create(ctx, bundle)
310306
}, lowTimeout, fastPollInterval).Should(Succeed(), "failed to create Bundle %q (webhook may not be ready yet)", bundle.Name)
311307
DeferCleanup(func() { deleteBundle(ctx, bundle.Name) })
312308
}

0 commit comments

Comments
 (0)