-
Notifications
You must be signed in to change notification settings - Fork 1.8k
chore(pubsub): Topic race condition; SMT test failure #5381
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
TestCreateSubscriptionWithSMT has been failing in repo-wide builds with a nil topic error. * update getOrCreateTopic test function to avoid race between checking topic existence and creating the topic. (tests are using t.Parallel(), so it can happen across tests) * in TestCreateSubscriptionWithSMT: * use shared getOrCreateTopic rather than local code. (local code had a bug which only occured when topic didn't already exist.) * use test specific topicID * use only one Retry block in body of the test so new topic both lives long enough to run the test and is cleaned up by defer.
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.
Summary of Changes
Hello @briandorsey, 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 a persistent test failure in TestCreateSubscriptionWithSMT by resolving a race condition in topic creation and refactoring the test's setup. The changes enhance the reliability and isolation of the test, ensuring consistent behavior across parallel executions and proper resource management.
Highlights
- Race Condition Fix: The getOrCreateTopic helper function was updated to prevent a race condition that could occur when parallel tests checked for topic existence and then attempted to create it. The new logic attempts to create the topic first and handles AlreadyExists errors.
- Test Refactor: The TestCreateSubscriptionWithSMT function was refactored to utilize the shared and improved getOrCreateTopic helper, replacing its previous local topic creation logic which had a bug.
- Test Isolation: A test-specific topic ID is now used within TestCreateSubscriptionWithSMT to ensure better isolation and prevent conflicts with other tests.
- Test Reliability: The TestCreateSubscriptionWithSMT now uses a single Retry block, ensuring the topic lives long enough for the test to complete and is properly cleaned up via defer.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
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 .gemini/
folder in the base of the repository. Detailed instructions can be found here.
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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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 resolves a race condition in the getOrCreateTopic
test helper by adopting an 'act-then-check' strategy. It also rectifies a failing test, TestCreateSubscriptionWithSMT
, by utilizing this improved helper, employing a test-specific topic ID, and ensuring proper resource cleanup. The changes are well-reasoned and correctly address the reported issues. My review includes a suggestion to enhance error message formatting for improved debuggability in the test helper.
Description
TestCreateSubscriptionWithSMT has been failing in repo-wide builds with a nil topic error.
Helps fix tests failing in Renovate PR #5225
Checklist
go test -v ./..
(see Testing)gofmt
(see Formatting)go vet
(see Formatting)