Skip to content

Conversation

@bootjp
Copy link
Owner

@bootjp bootjp commented Dec 13, 2025

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @bootjp, 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 focuses on a significant refactoring of the createNode test utility function within adapter/test_util.go. The primary objective is to enhance the clarity, modularity, and maintainability of the test setup logic by decomposing a monolithic function into several specialized helper functions. This change also incorporates a subtle yet crucial fix for goroutine variable capture, ensuring more robust and predictable test execution.

Highlights

  • Refactoring of createNode Function: The createNode test utility function has been extensively refactored into smaller, more focused helper functions, improving readability and maintainability.
  • Improved Test Setup Logic: New helper functions such as assignPorts, buildRaftConfig, setupNodes, waitForNodeListeners, and waitForRaftReadiness have been introduced to streamline the node creation and verification process in tests.
  • Goroutine Variable Capture Fix: Anonymous goroutines responsible for serving gRPC and Redis servers now explicitly capture necessary variables, preventing potential issues with variable scope in loops during test execution.
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.

@bootjp bootjp changed the title Feature/fix create node Refactor test utilities and remove time import Dec 13, 2025
@bootjp bootjp changed the title Refactor test utilities and remove time import Refactor test utilities and flaky test Dec 13, 2025
Copy link
Contributor

@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 createNode test utility function by breaking it down into smaller, more focused helper functions. This is a great improvement for readability and maintainability. I've added a couple of suggestions to further improve the new helper functions: one to improve test execution efficiency by parallelizing checks, and another to remove a redundant check to make the code cleaner.

Comment on lines +133 to +147
for _, n := range nodes {
assert.Eventually(t, func() bool {
conn, err := d.DialContext(ctx, "tcp", n.grpcAddress)
if err != nil {
return false
}
_ = conn.Close()
conn, err = d.DialContext(ctx, "tcp", n.redisAddress)
if err != nil {
return false
}
_ = conn.Close()
return true
}, waitTimeout, waitInterval)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The current implementation waits for each node's listeners sequentially. This can slow down tests, especially with a larger number of nodes. By using t.Run with t.Parallel(), we can check all nodes concurrently, which can significantly speed up the test suite.

Suggested change
for _, n := range nodes {
assert.Eventually(t, func() bool {
conn, err := d.DialContext(ctx, "tcp", n.grpcAddress)
if err != nil {
return false
}
_ = conn.Close()
conn, err = d.DialContext(ctx, "tcp", n.redisAddress)
if err != nil {
return false
}
_ = conn.Close()
return true
}, waitTimeout, waitInterval)
}
for _, node := range nodes {
n := node // capture range variable
t.Run("wait for "+n.grpcAddress, func(t *testing.T) {
t.Parallel()
assert.Eventually(t, func() bool {
conn, err := d.DialContext(ctx, "tcp", n.grpcAddress)
if err != nil {
return false
}
_ = conn.Close()
conn, err = d.DialContext(ctx, "tcp", n.redisAddress)
if err != nil {
return false
}
_ = conn.Close()
return true
}, waitTimeout, waitInterval)
})
}

Comment on lines +152 to +154
assert.Eventually(t, func() bool {
return nodes[0].raft.State() == raft.Leader
}, waitTimeout, waitInterval)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This assert.Eventually call is redundant because the subsequent assert.Eventually block already checks if nodes[0] is the leader within its loop. Removing this will make the function cleaner and slightly more efficient.

@bootjp bootjp merged commit 70e2161 into main Dec 13, 2025
7 checks passed
@bootjp bootjp deleted the feature/fix-create-node branch December 13, 2025 13:58
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