Skip to content

[test] Store mock state in memory, not filesystem#253

Merged
joshlf merged 1 commit intomainfrom
G86ee0f76d74006e946270bbc7c09349115e82fe1
Dec 28, 2025
Merged

[test] Store mock state in memory, not filesystem#253
joshlf merged 1 commit intomainfrom
G86ee0f76d74006e946270bbc7c09349115e82fe1

Conversation

@joshlf
Copy link
Owner

@joshlf joshlf commented Dec 28, 2025


Latest Update: v15 — Compare vs v14

📚 Full Patch History

Links show the diff between the row version and the column version.

Version v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v15 v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v14 v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v13 v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v12 v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v11 v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v10 v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v9 v8 v7 v6 v5 v4 v3 v2 v1 Base
v8 v7 v6 v5 v4 v3 v2 v1 Base
v7 v6 v5 v4 v3 v2 v1 Base
v6 v5 v4 v3 v2 v1 Base
v5 v4 v3 v2 v1 Base
v4 v3 v2 v1 Base
v3 v2 v1 Base
v2 v1 Base
v1 Base

@gemini-code-assist
Copy link

Summary of Changes

Hello @joshlf, 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 significantly refactors the testing infrastructure by transitioning the mock server's state management from filesystem-based persistence to an in-memory model. This change aims to improve the performance and reliability of tests by reducing disk I/O and simplifying state synchronization. The mock_bin now communicates with a dedicated mock HTTP server to manage git operations and PR states, providing a more robust and efficient testing environment.

Highlights

  • In-memory Mock State: The mock server now stores its state (e.g., PRs, pushed refs) entirely in memory using Arc<RwLock<MockState>>, eliminating filesystem I/O for state management.
  • Mock Git Proxy: The mock_bin now acts as a proxy for git commands, communicating with the in-memory mock server via HTTP (ureq) to record and respond to git operations, rather than directly manipulating a state file.
  • Dependency Changes: The gix crate, previously used for robust file locking, has been removed, and ureq has been added to facilitate HTTP communication within the mock testing infrastructure.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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

  1. 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 refactors the test utility's mock server by moving from file-based state management to an in-memory, Arc<RwLock> protected MockState accessed via an HTTP server. The mock git binary now acts as a client, forwarding commands to this new mock server using ureq, which then handles the logic, updates the shared state, and decides whether to passthrough to the real git. This change involved adding ureq and related dependencies, and updating test contexts to interact with the in-memory state. A review comment highlighted a potential concurrency issue in the new handle_git mock server endpoint, suggesting that the write lock on the MockState should only be acquired when git push commands are processed, rather than at the beginning of every git command, to improve parallel test execution.

@joshlf joshlf force-pushed the G86ee0f76d74006e946270bbc7c09349115e82fe1 branch from c231793 to a3a5a75 Compare December 28, 2025 18:36
@joshlf joshlf force-pushed the Gb462b837be676eec65acb43dc749cd34dad8a8c9 branch from e4b76f8 to 4fb566e Compare December 28, 2025 18:36
@joshlf joshlf force-pushed the G86ee0f76d74006e946270bbc7c09349115e82fe1 branch from a3a5a75 to 6f12e4d Compare December 28, 2025 19:09
@joshlf joshlf force-pushed the Gb462b837be676eec65acb43dc749cd34dad8a8c9 branch from 4fb566e to c3fe941 Compare December 28, 2025 19:09
@joshlf joshlf force-pushed the G86ee0f76d74006e946270bbc7c09349115e82fe1 branch from 6f12e4d to a6d09ac Compare December 28, 2025 19:12
@joshlf joshlf force-pushed the Gb462b837be676eec65acb43dc749cd34dad8a8c9 branch from c3fe941 to 1bef753 Compare December 28, 2025 19:12
@joshlf
Copy link
Owner Author

joshlf commented Dec 28, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 primarily focuses on refactoring the test infrastructure to use an in-memory mock server state managed by Arc<RwLock<MockState>> instead of file-based mock_state.json for improved test reliability and performance. This change involved updating testutil/src/lib.rs to manage the mock state directly and modifying test files like tests/prevent_push_to_closed_pr.rs and tests/reproduce_pagination_bug.rs to interact with this new in-memory state. The mock git binary (testutil/src/mock_bin.rs) was refactored to communicate with the mock HTTP server via ureq for Git command interception and response handling, replacing its previous file-locking mechanism. Correspondingly, testutil/src/mock_server.rs was updated to include a new handle_git endpoint for processing these requests and managing the shared MockState. Additionally, the Cargo.lock file received numerous dependency updates across various crates, and testutil/Cargo.toml removed the gix dependency while adding ureq. A [[bin]] entry for gherrit was also added to Cargo.toml. A review comment suggested restoring more descriptive expect messages in testutil/src/mock_server.rs for better debugging, specifically for serde_json::from_str calls related to parsing title and body fields.

@joshlf joshlf force-pushed the G86ee0f76d74006e946270bbc7c09349115e82fe1 branch from a6d09ac to 82fb137 Compare December 28, 2025 19:18
@joshlf
Copy link
Owner Author

joshlf commented Dec 28, 2025

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a 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 refactors the test suite's mocking infrastructure to store mock state in memory instead of on the filesystem. This is a significant improvement that should lead to more reliable and faster tests by avoiding filesystem I/O and potential race conditions.

The core changes involve:

  • Using an Arc<RwLock<MockState>> to manage shared, mutable state in memory for the mock server.
  • Reworking the mock git binary to act as an HTTP proxy to the mock server, centralizing mocking logic.
  • Updating test helpers and tests to interact with the new in-memory state management.

The changes are well-implemented and follow the stated goal. I've only left a few minor suggestions in testutil/src/mock_server.rs to improve the debuggability of tests by using expect() with descriptive messages instead of unwrap().

@joshlf joshlf force-pushed the G86ee0f76d74006e946270bbc7c09349115e82fe1 branch from 82fb137 to 183f60e Compare December 28, 2025 19:24
Base automatically changed from Gb462b837be676eec65acb43dc749cd34dad8a8c9 to main December 28, 2025 19:24
@joshlf joshlf force-pushed the G86ee0f76d74006e946270bbc7c09349115e82fe1 branch 2 times, most recently from 59c1e16 to 4531e02 Compare December 28, 2025 19:35
@joshlf joshlf force-pushed the G86ee0f76d74006e946270bbc7c09349115e82fe1 branch 3 times, most recently from c9eaad5 to 7522e34 Compare December 28, 2025 20:43
@joshlf joshlf mentioned this pull request Dec 28, 2025
gherrit-pr-id: G86ee0f76d74006e946270bbc7c09349115e82fe1
@joshlf joshlf force-pushed the G86ee0f76d74006e946270bbc7c09349115e82fe1 branch from 7522e34 to e44cf98 Compare December 28, 2025 21:16
@joshlf joshlf merged commit fb632af into main Dec 28, 2025
1 check passed
@joshlf joshlf deleted the G86ee0f76d74006e946270bbc7c09349115e82fe1 branch December 28, 2025 21:18
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.

1 participant