Skip to content

Conversation

@agaudreault
Copy link
Member

@agaudreault agaudreault commented Dec 18, 2025

Test Isolation Infrastructure: Introduced a test isolation mechanism by generating unique identifiers for each e2e test that will be appended to the resource it creates, preventing conflicts between runs and move towards parallel test execution.

Key Components:

  • TestState struct: Holds the unique identifiers (id, shortId, name, deploymentNamespace) for each test instead of being defined as global package variable
  • TestContext interface: Standardized interface that all fixture contexts implement to access unique test identifiers

Refactor Details

Before: Tests relied on shared global state and hardcoded names, causing conflicts when tests ran in parallel or when resources weren't properly cleaned up between runs. Sometimes, a test would start with existing objects in Terminating state making the test fail and behaviour unpredictable.

After: Each test creates a TestState with unique identifiers through EnsureCleanState(), which is embedded in all fixture contexts (app, cluster, account, project, repos, etc.). The GivenWithSameState() pattern allows multiple fixture types to share the same test "state" within a single test. Resources created through the Actions have a unique name for the given state.

Core Changes:

  1. test/e2e/fixture/context.go: Added TestContext interface and TestState struct with unique ID generation
  2. All fixture contexts: Now embed TestState and implement TestContext interface
  3. Resource naming: All resources (apps, clusters, accounts) use GetName() which returns the unique test name
  4. Namespace isolation: Each test gets a unique deployment namespace via DeploymentNamespace()

Tests Requiring Major Changes

TestClusterDelete (cluster_test.go:268-330)

  • Change: Persist a temporary kubeconfig file with a valid cluster for the unique cluster name.
  • Reason: Cluster removal command needs to target the uniquely-named cluster created by the test, this name must be present in the kubeconfig to remove the RBAC roles.
  • Impact: RBAC cleanup verification now works correctly and locally without having the current context named default

TestArgoCDSupportsMultipleServiceAccountsWithDifferingRBACOnSameCluster (deployment_test.go:158-206)

  • Change: Refactored createNamespaceScopedUser() to use c.ShortID() for generating unique names for namespaces, service accounts, roles, and cluster secrets. The test labels were addwed so they are part of the usual cleanup in EnsureCleanState and the code that existed to clean them up has been removed since it was obsolete.
  • Reason: Test creates multiple namespaces, service accounts, and cluster secrets that must have unique names to avoid conflicts between test runs
  • Impact: Complex RBAC test can now run in isolation, creating multiple users with distinct permissions without colliding with previous test runs

Part of #24307

Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
@bunnyshell
Copy link

bunnyshell bot commented Dec 18, 2025

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@agaudreault agaudreault changed the title implement isolation tesat(e2e): add isolation by ensuring unique name Dec 18, 2025
@agaudreault agaudreault changed the title tesat(e2e): add isolation by ensuring unique name test(e2e): add isolation by ensuring unique name Dec 18, 2025
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
@agaudreault agaudreault marked this pull request as ready for review January 8, 2026 01:09
@agaudreault agaudreault requested a review from a team as a code owner January 8, 2026 01:09
@crenshaw-dev crenshaw-dev merged commit dab6f3b into argoproj:master Jan 9, 2026
26 checks passed
@reggie-k reggie-k added the cherry-pick/3.3 Candidate for cherry picking into the 3.3 release label Feb 3, 2026
@argo-cd-cherry-pick-bot
Copy link

❌ Cherry-pick failed for 3.3. Please check the workflow logs for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick/3.3 Candidate for cherry picking into the 3.3 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants