Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 17, 2025

Overview

This PR adds two new e2e test cases to verify that a ResourceOverride in one namespace won't override resources in another namespace, ensuring proper namespace isolation.

Problem

We needed to validate that when a ResourceOverride is created in a specific namespace and references a placement (either ClusterResourcePlacement or ResourcePlacement), it only affects resources within that namespace and doesn't leak to other namespaces.

Solution

Added two comprehensive test cases following existing test patterns:

1. ClusterResourcePlacement (CRP) Test Case

Located in test/e2e/placement_ro_test.go, this test:

  • Creates two separate namespaces (namespace-A and namespace-B) with their own ConfigMaps
  • Creates two ClusterResourcePlacement resources (CRP-A for namespace-A, CRP-B for namespace-B)
  • Creates a ResourceOverride in namespace-A that references CRP-A and adds annotations
  • Validates that:
    • ConfigMap in namespace-A receives the override annotations
    • ConfigMap in namespace-B does not receive the override annotations (verified with Consistently)

2. ResourcePlacement (RP) Test Case

Located in test/e2e/resource_placement_ro_test.go, this test:

  • Creates two separate namespaces with their own ConfigMaps
  • Creates two ResourcePlacement resources (RP-A in namespace-A, RP-B in namespace-B)
  • Creates a ResourceOverride in namespace-A that references RP-A and adds annotations
  • Validates that:
    • ConfigMap in namespace-A receives the override annotations
    • ConfigMap in namespace-B does not receive the override annotations (verified with Consistently)

Additional Changes

  • Helper Function: Added cleanupNamespace function in test/e2e/utils_test.go to support test cleanup by deleting namespaces from the hub cluster
  • Import Addition: Added cmpopts import for more precise annotation comparison in test assertions
  • Code Quality: All code formatted with make reviewable and follows existing test patterns

Testing

The tests:

  • Follow the established Ginkgo/Gomega testing patterns used throughout the e2e suite
  • Use proper Eventually/Consistently patterns for async verification
  • Include comprehensive setup and cleanup to avoid test pollution
  • Compile successfully and are ready for execution in the e2e test environment

Resolves the issue by providing comprehensive validation of namespace isolation for ResourceOverride functionality.

Original prompt

This section details on the original issue you should resolve

<issue_title>test: add an e2e test to validate resourceoverride</issue_title>
<issue_description>We need to verify that resourceoverride in one namespace won't over ride resources in another namespace. Please add an e2e test to cover this case.</issue_description>

<agent_instructions>can you please follow the existing test styles and add a test case with CPR and one test case with RP?</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@ryanzhang-oss copilot can you give this issue a try again?

Fixes #71


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 3 commits October 17, 2025 23:34
Co-authored-by: ryanzhang-oss <59209500+ryanzhang-oss@users.noreply.github.com>
Add two new e2e test cases to verify that resourceoverride in one namespace
won't override resources in another namespace:

1. CRP test case: Creates two separate namespaces with configmaps and CRPs,
   then creates an RO in namespace-A that should only affect resources in
   namespace-A, not namespace-B.

2. RP test case: Creates two separate namespaces with configmaps and RPs,
   then creates an RO in namespace-A that should only affect resources in
   namespace-A, not namespace-B.

Also adds cleanupNamespace helper function to support test cleanup.

Co-authored-by: ryanzhang-oss <59209500+ryanzhang-oss@users.noreply.github.com>
Co-authored-by: ryanzhang-oss <59209500+ryanzhang-oss@users.noreply.github.com>
Copilot AI changed the title [WIP] Add e2e test to validate resourceoverride functionality test: add e2e tests to validate resourceoverride namespace isolation Oct 17, 2025
Copilot finished work on behalf of ryanzhang-oss October 17, 2025 23:51
Copilot AI requested a review from ryanzhang-oss October 17, 2025 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: add an e2e test to validate resourceoverride

2 participants