Skip to content

test: improve and speed up testing#867

Open
kalbasit wants to merge 2 commits intomainfrom
02-11-test_improve_the_go_leak_testing
Open

test: improve and speed up testing#867
kalbasit wants to merge 2 commits intomainfrom
02-11-test_improve_the_go_leak_testing

Conversation

@kalbasit
Copy link
Owner

No description provided.

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. go Pull requests that update go code labels Feb 12, 2026
@dosubot
Copy link

dosubot bot commented Feb 12, 2026

Related Documentation

Checked 7 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @kalbasit, 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 enhances the efficiency and reliability of the test suite. It introduces several helper functions to manage timing-sensitive operations more effectively and reduces artificial delays, resulting in a faster test execution time. Furthermore, it integrates a goroutine leak detection library, improving the stability and correctness of concurrent tests by automatically identifying and preventing resource leaks.

Highlights

  • Test Speed Optimization: Introduced several helper functions (ensureTimestampProgression, pollWithBackoff, newSlowHandler, ensureLockHeld, ensureLockTTLExpiry) to standardize and optimize timing-sensitive tests, replacing arbitrary time.Sleep calls with more semantic and efficient synchronization mechanisms.
  • Reduced Test Delays: Significantly reduced numerous time.Sleep durations across the test suite, leading to faster execution of tests involving network delays, concurrent operations, background tasks, and work simulations.
  • Goroutine Leak Detection: Integrated go.uber.org/goleak into several tests for robust goroutine leak detection, replacing manual runtime.NumGoroutine() checks and enabling previously skipped tests, thereby improving test reliability and correctness.
Changelog
  • CLAUDE.md
    • Documented test optimization strategies, including timestamp verification and slow operation simulation.
  • go.mod
    • Added go.uber.org/goleak dependency.
  • pkg/cache/cache_distributed_test.go
    • Added pollWithBackoff helper and optimized sleep durations for concurrent tests.
  • pkg/cache/cache_internal_test.go
    • Added ensureTimestampProgression and pollWithBackoff helpers, refactored existing sleep/polling logic.
  • pkg/cache/cache_prefetch_test.go
    • Integrated goleak for goroutine leak detection and reduced sleep durations.
  • pkg/cache/cache_test.go
    • Added ensureTimestampProgression helper, refactored timestamp-related sleeps, and minimized work simulation delays.
  • pkg/cache/cdc_test.go
    • Integrated goleak for goroutine leak detection.
  • pkg/cache/select_upstream_leak_internal_test.go
    • Integrated goleak for goroutine leak detection and removed explicit sleep calls.
  • pkg/cache/upstream/cache_test.go
    • Introduced newSlowHandler for context-aware timeout tests and reduced various delays.
  • pkg/database/contract_test.go
    • Added ensureTimestampProgression helper and refactored timestamp-related sleeps.
  • pkg/lock/local/local_test.go
    • Added ensureLockHeld helper and optimized sleep durations for lock tests.
  • pkg/lock/postgres/postgres_test.go
    • Added ensureLockHeld helper and optimized sleep durations for lock tests.
  • pkg/lock/redis/redis_test.go
    • Added ensureLockHeld and ensureLockTTLExpiry helpers, and optimized sleep durations for lock tests.
Activity
  • No specific activity (comments, reviews, etc.) has been recorded for this pull request yet.
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
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 introduces significant improvements to the test suite, focusing on speed and reliability. Key changes include replacing time.Sleep calls with more descriptive helper functions, reducing sleep durations, and using go.uber.org/goleak to reliably detect goroutine leaks, which has allowed for several previously skipped tests to be re-enabled. Additionally, timeout tests are made faster by using context-aware handlers. The changes are well-executed and will improve the development workflow. I have one minor suggestion regarding a misleading comment in a new test helper function.

Base automatically changed from 02-11-feat_implement_zstd_compression_pooling_and_integrate_across_project to main February 12, 2026 09:43
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Feb 12, 2026
@kalbasit kalbasit force-pushed the 02-11-test_improve_the_go_leak_testing branch from 43756e5 to 164aaf3 Compare February 12, 2026 09:50
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Feb 12, 2026
@kalbasit kalbasit force-pushed the 02-11-test_improve_the_go_leak_testing branch from 95f7226 to 9aef8f5 Compare February 12, 2026 09:51
@kalbasit kalbasit force-pushed the 02-11-test_improve_the_go_leak_testing branch from fba7c56 to 4863355 Compare February 12, 2026 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update go code size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant