Skip to content

test: parallel execution of e2e tests #1129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

osmman
Copy link
Collaborator

@osmman osmman commented Jun 2, 2025

Summary by Sourcery

Enable parallel execution of end-to-end tests by removing the -p 1 limitation and introducing a file-based mutex to serialize Cosign verification, preventing race conditions.

New Features:

  • Introduce a filemutex lock around Cosign verification in VerifyByCosign to prevent concurrent access issues.

Enhancements:

  • Allow e2e tests to run in parallel by removing the -p 1 flag from the Makefile test command.

Build:

  • Add github.com/alexflint/go-filemutex v1.3.0 as a dependency for filesystem locking.

Copy link

sourcery-ai bot commented Jun 2, 2025

Reviewer's Guide

This PR enables true parallel execution of e2e tests by removing the -p 1 flag in the Makefile and introducing a file-based mutex around cosign verification to prevent concurrent access, along with the necessary go-filemutex dependency.

Sequence Diagram: Mutex for Cosign Verification in Parallel Tests

sequenceDiagram
    participant E2ETest1 as E2E Test 1
    participant E2ETest2 as E2E Test 2
    participant FileMutex
    participant CosignProcess as Cosign Verification

    E2ETest1 ->> FileMutex: Lock()
    FileMutex -->> E2ETest1: Lock Acquired
    E2ETest1 ->> CosignProcess: Verify()
    CosignProcess -->> E2ETest1: Result
    E2ETest1 ->> FileMutex: Unlock()
    FileMutex -->> E2ETest1: Unlocked

    E2ETest2 ->> FileMutex: Lock()
    alt Test 1 holds or just released lock
        FileMutex -->> E2ETest2: Lock Acquired (may involve waiting if Test 1 held lock)
    else Lock was free
        FileMutex -->> E2ETest2: Lock Acquired
    end
    E2ETest2 ->> CosignProcess: Verify()
    CosignProcess -->> E2ETest2: Result
    E2ETest2 ->> FileMutex: Unlock()
    FileMutex -->> E2ETest2: Unlocked
Loading

Class Diagram: CosignVerifier Update with FileMutex Dependency

classDiagram
  class CosignVerifier {
    -mutex: FileMutex
    +VerifySignature() error  // Modified to use mutex
  }
  class FileMutex {
    <<dependency: github.com/alexflint/go-filemutex>>
    +New(filePath: string) *FileMutex
    +Lock() error
    +Unlock() error
  }
  CosignVerifier ..> FileMutex : uses
Loading

File-Level Changes

Change Details Files
Introduce file locking around cosign verification
  • Define a lockFileName constant
  • Compute lock file path in the system temp directory
  • Initialize a filemutex and panic on error
  • Acquire the lock before calling cosign verification and defer its release
  • Import os, filepath, and filemutex packages
test/e2e/support/tas/tas.go
Remove forced serialization of e2e tests
  • Omit the -p 1 flag from the go test invocation in the test-e2e Makefile target
Makefile
Add go-filemutex dependency
  • Require github.com/alexflint/go-filemutex v1.3.0 in go.mod
  • Update go.sum to reflect the new module
go.mod
go.sum

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @osmman - I've reviewed your changes - here's some feedback:

  • Rather than panicking on file mutex initialization, return an error or fail the test with a clear message so setup failures are more obvious.
  • Don’t ignore errors from m.Lock() and m.Unlock(); handle and surface them to avoid silent deadlocks or unlock failures.
  • For distributed test runs, consider using a cluster‐aware lock (e.g., a ConfigMap or leader election) instead of a local file lock for more robust synchronization.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@osmman osmman force-pushed the tturek/parallel-e2e-execution branch 2 times, most recently from 54032cd to 1419c40 Compare June 2, 2025 17:45
@osmman osmman marked this pull request as draft June 4, 2025 13:24
@osmman osmman force-pushed the tturek/parallel-e2e-execution branch 4 times, most recently from 7193910 to 1d92bc6 Compare June 7, 2025 11:52
@osmman osmman force-pushed the tturek/parallel-e2e-execution branch from 37d4928 to 90f55c9 Compare June 9, 2025 07:28
@osmman osmman force-pushed the tturek/parallel-e2e-execution branch from 90f55c9 to b228566 Compare June 9, 2025 08:55
@osmman osmman added the test label Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant