Skip to content

CM-869: Add test coverage for configurable TrustNamespace#391

Merged
openshift-merge-bot[bot] merged 14 commits intoopenshift:masterfrom
arun717:trustnamespace_impl
Apr 2, 2026
Merged

CM-869: Add test coverage for configurable TrustNamespace#391
openshift-merge-bot[bot] merged 14 commits intoopenshift:masterfrom
arun717:trustnamespace_impl

Conversation

@arun717
Copy link
Copy Markdown
Contributor

@arun717 arun717 commented Mar 26, 2026

This PR adds comprehensive test coverage for the configurable trust namespace feature.
The core functionality was already fully implemented in PR #379. This PR satisfies the remaining CM-869 acceptance criteria by adding the missing unit and e2e tests.

JIRA

  • Issue: CM-869
  • Parent: CM-861 - [Tech Preview] Integrate Trust Manager with Cert Manager Operator

What's Already Implemented (PR #379)

The trust namespace feature is fully functional:

  • ✅ API field spec.trustManagerConfig.trustNamespace with default "cert-manager"
  • ✅ Namespace existence validation
  • ✅ Degraded condition when namespace doesn't exist
  • ✅ RBAC resources placed in correct namespaces:
    • Trust-manager Role/RoleBinding → trust namespace
    • Leader election Role/RoleBinding → operand namespace
  • ✅ Deployment --trust-namespace argument configuration
  • ✅ Status field status.trustNamespace updates

What This PR Adds

Unit Tests

File: pkg/controller/trustmanager/controller_test.go

  • Test: "trust namespace does not exist sets degraded true"
    • Verifies Degraded=True condition when namespace is missing
  • Test: "custom trust namespace configures resources correctly"
    • Verifies successful reconciliation with custom namespace
  • Test function: TestStatusTrustNamespaceUpdate
    • Verifies status.trustNamespace for default and custom values

File: pkg/controller/trustmanager/test_utils.go

  • Added WithTrustNamespace() builder method

E2E Tests

File: test/e2e/trustmanager_test.go

  • Test: "should report trust namespace in status"
    • Verifies default trust namespace appears in status
  • Test: "should configure resources with custom trust namespace"
    • Creates custom namespace
    • Verifies Role/RoleBinding created in trust namespace
    • Verifies leader election Role/RoleBinding in operand namespace
    • Verifies deployment has correct --trust-namespace arg
    • Verifies status.trustNamespace matches spec
  • Test: "should set degraded condition when trust namespace does not exist"
    • Verifies Degraded=True for missing namespace
    • Creates namespace and verifies recovery to Ready=True

File: test/e2e/utils_test.go

  • Added WithTrustNamespace() builder method

Test Results

All unit tests pass:
✅ TestProcessReconcileRequest: 5/5 subtests PASS
✅ TestStatusTrustNamespaceUpdate: 2/2 subtests PASS
✅ Build: SUCCESS

Acceptance Criteria

All CM-869 acceptance criteria are met:

  • ✅ Trust namespace existence is checked
  • ✅ The operator sets Degrade condition if it does not exist
  • ✅ RBAC is configured correctly
  • --trust-namespace arg set correctly in deployment
  • ✅ TrustManagerStatus.TrustNamespace updated
  • ✅ Necessary e2e and UTs are added

Commits

Following conventional commits format:

  • test(trustmanager): add unit tests for trust namespace configuration
  • test(e2e): add e2e tests for trust namespace configuration

Testing

Unit Tests

go test ./pkg/controller/trustmanager -v -run
"TestProcessReconcileRequest|TestStatusTrustNamespaceUpdate"

Build Verification

make verify
go build ./pkg/controller/trustmanager

E2E Tests

E2E tests will run in CI. The new tests are in the "trust namespace configuration" context.

Checklist

- Unit tests added and passing
- E2E tests added
- Code builds successfully
- Follows conventional commits format
- All acceptance criteria met
- No new dependencies added
- Documentation updated (if needed) - N/A, feature already documented

---
🤖 Generated with Claude Code via /jira:solve [CM-869](https://redhat.atlassian.net/browse/CM-869) cert-manager-operator
---

Arun Maurya and others added 2 commits March 26, 2026 16:40
Add missing unit test coverage for configurable trust namespace feature.

The trust namespace configuration was already fully implemented in PR openshift#379.
This commit adds comprehensive unit tests to verify the implementation and
satisfy CM-869 acceptance criteria.

Tests added:
- Trust namespace validation when namespace doesn't exist
- Custom trust namespace configuration with successful reconciliation
- Status field updates for both default and custom namespace values

Without these tests, the trust namespace validation logic was not adequately
covered, making it harder to catch regressions.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add comprehensive end-to-end tests for trust namespace configuration.

Tests verify:
1. Custom trust namespace RBAC placement
   - Role/RoleBinding created in trust namespace
   - Leader election Role/RoleBinding in operand namespace
2. Deployment configuration with correct --trust-namespace arg
3. Status field updates matching spec configuration
4. Degraded condition when trust namespace doesn't exist
5. Recovery to Ready=True after namespace creation

These tests ensure the trust namespace feature works correctly in a real
cluster environment and that all resources are created in the correct
namespaces as required by CM-869.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Mar 26, 2026

@arun717: This pull request references CM-869 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target either version "4.22." or "openshift-4.22.", but it targets "cert-manager-1.19" instead.

Details

In response to this:

This PR adds comprehensive test coverage for the configurable trust namespace feature.
The core functionality was already fully implemented in PR #379. This PR satisfies the remaining CM-869 acceptance criteria by adding the missing unit and e2e tests.

JIRA

  • Issue: CM-869
  • Parent: CM-861 - [Tech Preview] Integrate Trust Manager with Cert Manager Operator

What's Already Implemented (PR #379)

The trust namespace feature is fully functional:

  • ✅ API field spec.trustManagerConfig.trustNamespace with default "cert-manager"
  • ✅ Namespace existence validation
  • ✅ Degraded condition when namespace doesn't exist
  • ✅ RBAC resources placed in correct namespaces:
    • Trust-manager Role/RoleBinding → trust namespace
    • Leader election Role/RoleBinding → operand namespace
  • ✅ Deployment --trust-namespace argument configuration
  • ✅ Status field status.trustNamespace updates

What This PR Adds

Unit Tests

File: pkg/controller/trustmanager/controller_test.go

  • Test: "trust namespace does not exist sets degraded true"
    • Verifies Degraded=True condition when namespace is missing
  • Test: "custom trust namespace configures resources correctly"
    • Verifies successful reconciliation with custom namespace
  • Test function: TestStatusTrustNamespaceUpdate
    • Verifies status.trustNamespace for default and custom values

File: pkg/controller/trustmanager/test_utils.go

  • Added WithTrustNamespace() builder method

E2E Tests

File: test/e2e/trustmanager_test.go

  • Test: "should report trust namespace in status"
    • Verifies default trust namespace appears in status
  • Test: "should configure resources with custom trust namespace"
    • Creates custom namespace
    • Verifies Role/RoleBinding created in trust namespace
    • Verifies leader election Role/RoleBinding in operand namespace
    • Verifies deployment has correct --trust-namespace arg
    • Verifies status.trustNamespace matches spec
  • Test: "should set degraded condition when trust namespace does not exist"
    • Verifies Degraded=True for missing namespace
    • Creates namespace and verifies recovery to Ready=True

File: test/e2e/utils_test.go

  • Added WithTrustNamespace() builder method

Test Results

All unit tests pass:
✅ TestProcessReconcileRequest: 5/5 subtests PASS
✅ TestStatusTrustNamespaceUpdate: 2/2 subtests PASS
✅ Build: SUCCESS

Acceptance Criteria

All CM-869 acceptance criteria are met:

  • ✅ Trust namespace existence is checked
  • ✅ The operator sets Degrade condition if it does not exist
  • ✅ RBAC is configured correctly
  • --trust-namespace arg set correctly in deployment
  • ✅ TrustManagerStatus.TrustNamespace updated
  • ✅ Necessary e2e and UTs are added

Commits

Following conventional commits format:

  • test(trustmanager): add unit tests for trust namespace configuration
  • test(e2e): add e2e tests for trust namespace configuration

Testing

Unit Tests

go test ./pkg/controller/trustmanager -v -run
"TestProcessReconcileRequest|TestStatusTrustNamespaceUpdate"

Build Verification

make verify
go build ./pkg/controller/trustmanager

E2E Tests

E2E tests will run in CI. The new tests are in the "trust namespace configuration" context.

Checklist

- Unit tests added and passing
- E2E tests added
- Code builds successfully
- Follows conventional commits format
- All acceptance criteria met
- No new dependencies added
- Documentation updated (if needed) - N/A, feature already documented

---
🤖 Generated with Claude Code via /jira:solve [CM-869](https://redhat.atlassian.net/browse/CM-869) cert-manager-operator
---

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 26, 2026
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 26, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Mar 26, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

Important

Review skipped

Auto reviews are limited based on label configuration.

🚫 Review skipped — only excluded labels are configured. (1)
  • do-not-merge/work-in-progress

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 983d16ed-eb2a-45be-99ad-f299f3d24fa0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds unit and e2e tests and builder helpers around TrustManager trust-namespace behavior, plus a one-line comment punctuation change; covers default/custom TrustNamespace status, degraded state when the namespace is missing, immutability checks, recovery after creating a missing namespace, and status-update logic tests.

Changes

Cohort / File(s) Summary
Controller unit tests & helpers
pkg/controller/trustmanager/controller_test.go, pkg/controller/trustmanager/test_utils.go, pkg/controller/trustmanager/install_trustmanager_test.go
Extended controller unit tests with cases for missing configured Namespace (sets Degraded=True, Ready=False, specific message) and successful reconciliation when a custom TrustNamespace exists; added TestUpdateStatusObservedState to verify status population and update counts; added builder method WithTrustNamespace.
E2E tests & builders
test/e2e/trustmanager_test.go, test/e2e/utils_test.go
Added E2E tests to create DNS-safe per-test trust namespaces, assert default and custom tm.Status.TrustNamespace, verify trust-manager Deployment arg --trust-namespace=<custom>, resource scoping (Role/RoleBinding) in custom namespace vs leader-election in operand namespace, immutability rejection for spec.trustNamespace updates, degraded-state when namespace missing and recovery after creation; added WithTrustNamespace builder.
Webhook comment
pkg/controller/trustmanager/webhooks.go
Non-functional comment punctuation change in updateWebhookClientConfig (added trailing period).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@arun717 arun717 marked this pull request as ready for review March 30, 2026 05:33
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 30, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/e2e/trustmanager_test.go`:
- Around line 861-874: The test relies on an external reconcile trigger when the
missing trust Namespace is created, causing flakiness; fix by explicitly
triggering reconciliation instead of changing controller behavior: after
creating the missing Namespace in the test, perform an update/patch on the
TrustManager CR via trustManagerClient() (e.g., touch a metadata annotation or
increment a dummy field) to force the controller to requeue/reconcile, then
proceed to the existing Eventually assertions that inspect tm.Status conditions
(Degraded and Ready). Alternatively, if you prefer a controller change, add a
Namespace watch in the controller or change the missing-namespace error from
IRRECOVERABLE to RECOVERABLE so the controller requeues automatically (choose
one approach and implement consistently).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d7ef543c-ba42-4dae-9c4b-62f3c4c1e46c

📥 Commits

Reviewing files that changed from the base of the PR and between 359b345 and 7a0aea0.

📒 Files selected for processing (5)
  • pkg/controller/trustmanager/controller_test.go
  • pkg/controller/trustmanager/test_utils.go
  • pkg/controller/trustmanager/webhooks.go
  • test/e2e/trustmanager_test.go
  • test/e2e/utils_test.go

@chiragkyal
Copy link
Copy Markdown
Member

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
pkg/controller/trustmanager/install_trustmanager_test.go (1)

119-130: Assert the object passed into StatusUpdate to prevent false-positive tests

Right now the mock ignores obj, so the test can pass even if StatusUpdate receives stale/wrong data. Capture and assert the TrustManager payload passed to StatusUpdate (not just local tm state).

Suggested hardening
 			mock.StatusUpdateCalls(func(ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption) error {
+				gotTM, ok := obj.(*v1alpha1.TrustManager)
+				if !ok {
+					t.Fatalf("StatusUpdate called with unexpected type %T", obj)
+				}
+				gotTM = gotTM.DeepCopy()
+				_ = gotTM // store in outer var and assert via tt.assertStatus on updated payload
 				return nil
 			})

As per coding guidelines, "Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/controller/trustmanager/install_trustmanager_test.go` around lines 119 -
130, The mock currently ignores the object passed into StatusUpdate which can
hide stale/wrong payloads; update the mock.StatusUpdateCalls handler in the test
to capture the incoming obj parameter, assert it is a *v1alpha1.TrustManager (or
cast accordingly), and compare its relevant fields to the expected tm (use
deep-equal or cmp.Diff) and fail the test if they differ before returning nil;
ensure the assertion checks the captured object rather than only relying on
local tm and keep StatusUpdateCallCount checks intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@pkg/controller/trustmanager/install_trustmanager_test.go`:
- Around line 119-130: The mock currently ignores the object passed into
StatusUpdate which can hide stale/wrong payloads; update the
mock.StatusUpdateCalls handler in the test to capture the incoming obj
parameter, assert it is a *v1alpha1.TrustManager (or cast accordingly), and
compare its relevant fields to the expected tm (use deep-equal or cmp.Diff) and
fail the test if they differ before returning nil; ensure the assertion checks
the captured object rather than only relying on local tm and keep
StatusUpdateCallCount checks intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9d979f02-f02e-49d6-8bc0-2d4f564c332b

📥 Commits

Reviewing files that changed from the base of the PR and between cfb6441 and 9d0373c.

📒 Files selected for processing (2)
  • pkg/controller/trustmanager/controller_test.go
  • pkg/controller/trustmanager/install_trustmanager_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/controller/trustmanager/controller_test.go

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/e2e/trustmanager_test.go`:
- Around line 579-593: The tests create a fixed namespace name (customTrustNS)
and defer a delete without waiting, causing racey AlreadyExists errors; update
the test to generate a unique per-spec namespace (e.g., append a random or the
test's name/suffix) when creating the Namespace (replace usages of
customTrustNS) and change the deferred cleanup in the same scope to delete and
then poll until the namespace is actually removed (use the Kubernetes client to
Get the Namespace in a loop and treat NotFound as success) to ensure deletion is
complete before other specs reuse the name; apply the same change to the other
custom-namespace creation/cleanup blocks referenced in the file.
- Around line 598-602: The Eventually assertion indexes
deployment.Spec.Template.Spec.Containers[0] directly which can panic if the
container slice is empty; update the assertion in the Eventually block to first
assert the container slice has at least one element (e.g.
Expect(len(deployment.Spec.Template.Spec.Containers)).To(BeNumerically(">", 0)))
before accessing Containers[0], then check that Containers[0].Args contains the
expected "--trust-namespace=..." element using the existing
Expect/ContainElement pattern to avoid transient panics in reconcile states.
- Around line 694-701: The test accesses rb.Subjects[0] without asserting
Subjects is non-empty, which can panic; update the Eventually check that
retrieves the RoleBinding (via clientset.RbacV1().RoleBindings(...).Get) to
first assert that rb.Subjects is not nil/has length > 0 (e.g., Gomega
Expect(len(rb.Subjects)).Should(BeNumerically(">", 0)) or
Expect(rb.Subjects).ShouldNot(BeEmpty())) before accessing rb.Subjects[0], then
keep the existing assertions on rb.Subjects[0].Name and rb.Subjects[0].Namespace
and call verifyTrustManagerManagedLabels(rb.Labels).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 946f478a-7e82-45f1-9e44-70e5fbbcb96c

📥 Commits

Reviewing files that changed from the base of the PR and between 9d0373c and 9cf508c.

📒 Files selected for processing (1)
  • test/e2e/trustmanager_test.go

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 31, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/e2e/trustmanager_test.go (1)

627-633: Assert that the default --trust-namespace flag is gone too.

This still passes if the deployment renders both --trust-namespace=cert-manager and the custom value, so it doesn't fully verify the override.

Suggested tightening
 			Eventually(func(g Gomega) {
 				deployment, err := clientset.AppsV1().Deployments(trustManagerNamespace).Get(ctx, trustManagerDeploymentName, metav1.GetOptions{})
 				g.Expect(err).ShouldNot(HaveOccurred())
 				g.Expect(len(deployment.Spec.Template.Spec.Containers)).Should(BeNumerically(">", 0))
-				g.Expect(deployment.Spec.Template.Spec.Containers[0].Args).Should(ContainElement(fmt.Sprintf("--trust-namespace=%s", customTrustNS)))
+				args := deployment.Spec.Template.Spec.Containers[0].Args
+				g.Expect(args).Should(ContainElement(fmt.Sprintf("--trust-namespace=%s", customTrustNS)))
+				g.Expect(args).ShouldNot(ContainElement("--trust-namespace=cert-manager"))
 			}, lowTimeout, fastPollInterval).Should(Succeed())
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/e2e/trustmanager_test.go`:
- Around line 696-721: Add assertions to ensure the trust-manager Role and
RoleBinding are absent from the operand namespace (cert-manager) after creating
the TrustManager with a custom trust namespace: after verifying the Role and
RoleBinding exist in customTrustNS (created via createTrustTestNamespace and
createTrustManager), call
clientset.RbacV1().Roles(certManagerNamespace).Get(...) for trustManagerRoleName
and expect a NotFound error, and similarly call
clientset.RbacV1().RoleBindings(certManagerNamespace).Get(...) for
trustManagerRoleBindingName and expect NotFound; keep verifying the subjects and
labels for the custom namespace checks (verifyTrustManagerManagedLabels,
trustManagerServiceAccountName, trustManagerNamespace) unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5eb4dd53-a23d-49af-8014-164e904833f4

📥 Commits

Reviewing files that changed from the base of the PR and between 9cf508c and 89dbd8d.

📒 Files selected for processing (2)
  • pkg/controller/trustmanager/install_trustmanager_test.go
  • test/e2e/trustmanager_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/controller/trustmanager/install_trustmanager_test.go

@openshift-ci openshift-ci bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 31, 2026
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 1, 2026
@arun717
Copy link
Copy Markdown
Contributor Author

arun717 commented Apr 1, 2026

/retest

Copy link
Copy Markdown
Member

@chiragkyal chiragkyal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/cc @bharath-b-rh

@openshift-ci openshift-ci bot requested a review from bharath-b-rh April 1, 2026 13:43
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 1, 2026
@chiragkyal
Copy link
Copy Markdown
Member

It only extends test coverage. No new user-facing changes.

/label docs-approved
/label px-approved
/label qe-approved
/hold
until we resolve the review comments

@openshift-ci openshift-ci bot added docs-approved Signifies that Docs has signed off on this PR do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR labels Apr 1, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 1, 2026

@arun717: This pull request references CM-869 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target either version "4.22." or "openshift-4.22.", but it targets "cert-manager-1.19" instead.

Details

In response to this:

This PR adds comprehensive test coverage for the configurable trust namespace feature.
The core functionality was already fully implemented in PR #379. This PR satisfies the remaining CM-869 acceptance criteria by adding the missing unit and e2e tests.

JIRA

  • Issue: CM-869
  • Parent: CM-861 - [Tech Preview] Integrate Trust Manager with Cert Manager Operator

What's Already Implemented (PR #379)

The trust namespace feature is fully functional:

  • ✅ API field spec.trustManagerConfig.trustNamespace with default "cert-manager"
  • ✅ Namespace existence validation
  • ✅ Degraded condition when namespace doesn't exist
  • ✅ RBAC resources placed in correct namespaces:
    • Trust-manager Role/RoleBinding → trust namespace
    • Leader election Role/RoleBinding → operand namespace
  • ✅ Deployment --trust-namespace argument configuration
  • ✅ Status field status.trustNamespace updates

What This PR Adds

Unit Tests

File: pkg/controller/trustmanager/controller_test.go

  • Test: "trust namespace does not exist sets degraded true"
    • Verifies Degraded=True condition when namespace is missing
  • Test: "custom trust namespace configures resources correctly"
    • Verifies successful reconciliation with custom namespace
  • Test function: TestStatusTrustNamespaceUpdate
    • Verifies status.trustNamespace for default and custom values

File: pkg/controller/trustmanager/test_utils.go

  • Added WithTrustNamespace() builder method

E2E Tests

File: test/e2e/trustmanager_test.go

  • Test: "should report trust namespace in status"
    • Verifies default trust namespace appears in status
  • Test: "should configure resources with custom trust namespace"
    • Creates custom namespace
    • Verifies Role/RoleBinding created in trust namespace
    • Verifies leader election Role/RoleBinding in operand namespace
    • Verifies deployment has correct --trust-namespace arg
    • Verifies status.trustNamespace matches spec
  • Test: "should set degraded condition when trust namespace does not exist"
    • Verifies Degraded=True for missing namespace
    • Creates namespace and verifies recovery to Ready=True

File: test/e2e/utils_test.go

  • Added WithTrustNamespace() builder method

Test Results

All unit tests pass:
✅ TestProcessReconcileRequest: 5/5 subtests PASS
✅ TestStatusTrustNamespaceUpdate: 2/2 subtests PASS
✅ Build: SUCCESS

Acceptance Criteria

All CM-869 acceptance criteria are met:

  • ✅ Trust namespace existence is checked
  • ✅ The operator sets Degrade condition if it does not exist
  • ✅ RBAC is configured correctly
  • --trust-namespace arg set correctly in deployment
  • ✅ TrustManagerStatus.TrustNamespace updated
  • ✅ Necessary e2e and UTs are added

Commits

Following conventional commits format:

  • test(trustmanager): add unit tests for trust namespace configuration
  • test(e2e): add e2e tests for trust namespace configuration

Testing

Unit Tests

go test ./pkg/controller/trustmanager -v -run
"TestProcessReconcileRequest|TestStatusTrustNamespaceUpdate"

Build Verification

make verify
go build ./pkg/controller/trustmanager

E2E Tests

E2E tests will run in CI. The new tests are in the "trust namespace configuration" context.

Checklist

- Unit tests added and passing
- E2E tests added
- Code builds successfully
- Follows conventional commits format
- All acceptance criteria met
- No new dependencies added
- Documentation updated (if needed) - N/A, feature already documented

---
🤖 Generated with Claude Code via /jira:solve [CM-869](https://redhat.atlassian.net/browse/CM-869) cert-manager-operator
---

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 1, 2026
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 2, 2026
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 2, 2026
@arun717
Copy link
Copy Markdown
Contributor Author

arun717 commented Apr 2, 2026

/retest

Copy link
Copy Markdown
Member

@chiragkyal chiragkyal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 2, 2026
@chiragkyal
Copy link
Copy Markdown
Member

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 2, 2026
@arun717
Copy link
Copy Markdown
Contributor Author

arun717 commented Apr 2, 2026

/retest

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 2, 2026

@arun717: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-operator-tech-preview 4725276 link false /test e2e-operator-tech-preview

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Copy link
Copy Markdown
Contributor

@bharath-b-rh bharath-b-rh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/label docs-approved
/label px-approved

Since changes are w.r.t tests, taking CI results as indicator adding the label.
/label qe-approved

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 2, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: arun717, bharath-b-rh, chiragkyal

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 2, 2026
@openshift-merge-bot openshift-merge-bot bot merged commit 64ddff2 into openshift:master Apr 2, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. docs-approved Signifies that Docs has signed off on this PR jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants