-
Notifications
You must be signed in to change notification settings - Fork 137
tapgarden: harden MockKeyRing
and fix flaky queueSeedlingsInBatch
test
#1824
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
Conversation
Summary of ChangesHello @ffranr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses test flakiness in the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively addresses the flaky test TestBatchedAssetIssuance/minting_with_cancellation
by hardening the MockKeyRing
and refining the test logic. The introduction of an atomic counter for DeriveNextKey
calls is a robust solution to avoid race conditions in test assertions. Replacing read locks with full mutex locks provides stronger consistency guarantees for the mock object. The test helper queueSeedlingsInBatch
is also improved by using wait.NoError
, which is more suitable for the asynchronous nature of the test.
My review includes a couple of suggestions to enhance the comments for the new exported functions in tapgarden/mock.go
to better align with the project's documentation standards.
Replace read-only locks with full mutex locks in MockKeyRing methods for simplicity. Ensure the full lock is acquired as the first operation in each method to maintain consistent and safe access.
Introduce an atomic counter `deriveNextKeyCallCount` in `MockKeyRing` to track calls to `DeriveNextKey` without relying on the internal mock mutex. This allows tests to query and reset the count directly in a thread-safe way. Update `queueSeedlingsInBatch` to: * replace `require.Eventually` with `wait.NoError`, so failures log the actual state for easier debugging, * relax the check from strict equality to `>=` expected, tolerating extra key derivations and reducing flakiness.
ff09d60
to
e28ce8d
Compare
Replace the use of `require.Eventually` with `wait.NoError` in `assertPendingBatchExists`. This lets the helper return detailed error messages (nil batch, wrong number of seedlings, fetch failure) instead of a generic boolean failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR makes several changes to stabilize
MockKeyRing
and reduce test flakiness inqueueSeedlingsInBatch
:NewMockKeyRing
On
calls.RLock
with full mutex locks, always acquired first in each method.DeriveNextKey
calls to avoid depending on the mock’s mutex.wait.NoError
instead ofrequire.Eventually
and relax equality checks to>=
expected.This is the error we're trying to fix (as seen in a recent CI run):