Skip to content

plumbing: ssh, fix concurrent test failures due to cert key generation#2043

Merged
pjbgf merged 1 commit into
go-git:mainfrom
aymanbagabas:ssh-known-test
Apr 30, 2026
Merged

plumbing: ssh, fix concurrent test failures due to cert key generation#2043
pjbgf merged 1 commit into
go-git:mainfrom
aymanbagabas:ssh-known-test

Conversation

@aymanbagabas
Copy link
Copy Markdown
Member

Before we added t.Parallel to run test in parallel, the test known_hosts file was generated once and memoized for reuse across test functions. This was done to avoid the overhead of generating new keys for each test function, which can be slow. However, with tests now running in parallel, this shared state caused concurrent test failures when multiple tests tried to generate and memoize cert keys at the same time.

Moreover, the key generation in general takes a negligible amount of time compared to the overall test runtime, so the memoization optimization is not as critical as it once was.

Fixes: https://github.com/go-git/go-git/actions/runs/25137758637/job/73680183936?pr=2042

Before we added t.Parallel to run test in parallel, the test known_hosts
file was generated once and memoized for reuse across test functions.
This was done to avoid the overhead of generating new keys for each test
function, which can be slow. However, with tests now running in
parallel, this shared state caused concurrent test failures when
multiple tests tried to generate and memoize cert keys at the same time.

Moreover, the key generation in general takes a negligible amount of
time compared to the overall test runtime, so the memoization
optimization is not as critical as it once was.

Signed-off-by: Ayman Bagabas <[email protected]>
Copy link
Copy Markdown
Member

@pjbgf pjbgf left a comment

Choose a reason for hiding this comment

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

@aymanbagabas thanks for working on this. 🙇

@pjbgf pjbgf merged commit b195ffa into go-git:main Apr 30, 2026
17 checks passed
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.

2 participants