Skip to content

fix failing IT tests#2651

Merged
robfrank merged 30 commits intomainfrom
pr-2648
Oct 21, 2025
Merged

fix failing IT tests#2651
robfrank merged 30 commits intomainfrom
pr-2648

Conversation

@robfrank
Copy link
Collaborator

This pull request refactors multi-threaded test code across several test classes to improve reliability and maintainability. The changes focus on replacing manual thread management with ExecutorService and Future, ensuring proper shutdown and error handling, and improving synchronization in tests. Additionally, it replaces fixed sleep-based waits with Awaitility for more robust waiting in index compaction tests.

Concurrency improvements in tests:

  • Replaced manual thread creation and management with ExecutorService and Future in all major multi-threaded tests (ACIDTransactionTest.java, ExplicitLockingTransactionTest.java, RandomTestMultiThreadsTest.java). This change improves error handling, simplifies code, and ensures proper resource cleanup. [1] [2] [3] [4] [5] [6]
  • Added robust shutdown logic for ExecutorService, including timeout handling and forced shutdown if necessary, ensuring tests do not leave lingering threads. [1] [2] [3] [4] [5] [6]

Synchronization and waiting improvements:

  • Replaced fixed Thread.sleep() calls with Awaitility in LSMTreeIndexTest.java for waiting on index compaction, making tests more reliable and less dependent on arbitrary timeouts. [1] [2]
  • Removed unnecessary sleep statements after asynchronous operations in transaction tests, relying on proper completion mechanisms instead. [1] [2]

Code style and imports:

  • Updated import statements to explicitly import required concurrency, collection, and Awaitility classes, improving readability and maintainability. [1] [2] [3] [4] [5]

These changes modernize and stabilize the test suite, making it easier to maintain and less prone to intermittent failures due to thread management or timing issues.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @robfrank, 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 reliability and maintainability of the test suite by modernizing its approach to concurrency and synchronization. It transitions from error-prone manual thread management and fixed sleep durations to more robust and predictable mechanisms like ExecutorService for thread pooling and Awaitility for dynamic waiting conditions. These changes are crucial for preventing intermittent test failures and ensuring a stable testing environment.

Highlights

  • Concurrency Refactoring: Replaced manual thread creation and management with ExecutorService and Future across multiple multi-threaded test classes (ACIDTransactionTest.java, ExplicitLockingTransactionTest.java, RandomTestMultiThreadsTest.java, LSMTreeIndexTest.java, TypeLSMTreeIndexTest.java, HTTPGraphConcurrentIT.java). This improves error handling, simplifies code, and ensures proper resource cleanup.
  • Robust Shutdown Logic: Implemented robust shutdown logic for ExecutorService instances, including timeout handling and forced shutdown if necessary, to prevent lingering threads and ensure tests terminate cleanly.
  • Improved Waiting Mechanisms: Replaced fixed Thread.sleep() calls with Awaitility in LSMTreeIndexTest.java, TypeLSMTreeIndexTest.java, BaseGraphServerTest.java, HTTP2ServersCreateReplicatedDatabaseIT.java, HTTP2ServersIT.java, and WebSocketEventBusIT.java. This makes tests more reliable and less prone to intermittent failures due to arbitrary timeouts, especially for index compaction and server synchronization.
  • Removed Unnecessary Sleeps: Eliminated unnecessary Thread.sleep() statements after asynchronous operations in transaction tests, relying instead on proper completion mechanisms like db.async().waitCompletion().
  • Code Style and Imports: Updated import statements to explicitly include required concurrency, collection, and Awaitility classes, enhancing code readability and maintainability.
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 is a great step towards improving the reliability and maintainability of the test suite by replacing manual thread management and sleeps with modern concurrency utilities like ExecutorService and Awaitility. The changes are generally well-implemented.

I've found a few issues that need attention:

  • A critical bug in waitForReplicationIsCompleted where Awaitility is used incorrectly.
  • A critical issue in RandomTestMultiThreadsTest where an empty catch block can swallow exceptions.
  • Inconsistent use of wildcard vs. explicit imports across the modified files.
  • Some places where future.get() is used without a timeout, and exceptions are ignored, which can lead to hung or silently failing tests.
  • An unreachable code block in BaseGraphServerTest.
  • An unclear comment about a "double wait".

I've provided specific comments and suggestions for each of these points. Addressing them will make the test suite even more robust.

Comment on lines 89 to 93
try {
threads[i].join();
} catch (InterruptedException e) {
future.get();
} catch (InterruptedException | ExecutionException e) {
// IGNORE IT
}
Copy link
Contributor

Choose a reason for hiding this comment

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

high

Calling future.get() without a timeout can cause the test to hang indefinitely if a task gets stuck. Additionally, ignoring InterruptedException and ExecutionException is risky. InterruptedException should be handled by re-interrupting the current thread, and ignoring ExecutionException can hide test failures.

A more robust approach would be to use a timeout and fail the test upon any exception, similar to the implementation in ACIDTransactionTest.java. This same issue is present in testExplicitLockBucket, testExplicitLockTypeSQL, and testExplicitLockBucketSQL in this file.

    try {
      future.get(120, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      fail("Test interrupted while waiting for task completion", e);
    } catch (ExecutionException e) {
      fail("Test task failed with an exception", e.getCause());
    } catch (TimeoutException e) {
      fail("Test task timed out", e);
    }

@codacy-production
Copy link

codacy-production bot commented Oct 12, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.09% 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (73de426) 73088 46339 63.40%
Head commit (b80987d) 73090 (+2) 46407 (+68) 63.49% (+0.09%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#2651) 13 13 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@robfrank robfrank force-pushed the pr-2648 branch 4 times, most recently from 9978317 to aef391b Compare October 20, 2025 09:10
@mergify
Copy link
Contributor

mergify bot commented Oct 20, 2025

🧪 CI Insights

Here's what we observed from your CI run for b80987d.

🟢 All jobs passed!

But CI Insights is watching 👀

Copilot AI and others added 22 commits October 21, 2025 09:57
…e in HA and multithread tests

Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
…e in ACID and ExplicitLocking tests

Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
…e in LSMTree index tests

Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
…e in HTTPGraphConcurrentIT

Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
… calls

Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
…dsTest

Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
… with ExecutorService

Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
Co-authored-by: robfrank <413587+robfrank@users.noreply.github.com>
…e Awaitility timeout for replication completion
…enhance endpoint interaction, and improve response validation
@robfrank robfrank linked an issue Oct 21, 2025 that may be closed by this pull request
@robfrank robfrank added this to the 25.10.1 milestone Oct 21, 2025
@robfrank robfrank added the enhancement New feature or request label Oct 21, 2025
@robfrank robfrank self-assigned this Oct 21, 2025
@robfrank robfrank merged commit 732d083 into main Oct 21, 2025
19 of 22 checks passed
robfrank added a commit that referenced this pull request Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix failing integration tests

2 participants