Skip to content
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

Support tests in apple silicon and fix NPE in BaseLogStorageTest #1181

Closed
wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Feb 18, 2025

I tried to run the project tests for the first time, but they failed. I found 2 reasons and fixed them:
1 - jna.version = 5.5.0 does not support Apple Silicon processors. So I upgraded the version to 5.7.0
2 - BaseLogStorageTest#testTruncatePrefix test failed, it failed with NullPointerException inside ThreadPoolsFactory#runInThread method when accessing ConcurrentHashMap with key == null. To fix this, I added a method to call LogStorageOptions.setGroupId("test"); before running the tests.

Summary by CodeRabbit

  • Chores

    • Upgraded core parent dependency versions across the project and aligned key library dependencies to the latest release, supporting improved build stability and performance.
  • Tests

    • Refined log storage test configurations to ensure consistent grouping behavior during test runs.

Copy link

sofastack-cla bot commented Feb 18, 2025

Hi @pashchenko8, welcome to SOFAStack community, Please sign Contributor License Agreement!

After you signed CLA, we will automatically sync the status of this pull request in 3 minutes.

Copy link
Contributor

coderabbitai bot commented Feb 18, 2025

Walkthrough

This pull request updates the parent project version across multiple Maven modules from 1.3.15.bugfix to 1.3.16. In addition, the root pom.xml is modified to change the overall project version and update the JNA dependency from 5.5.0 to 5.7.0. A test file in the log storage module is also updated to set a group identifier by adding opts.setGroupId("test"); within a method.

Changes

File(s) Change Summary
jraft-core/pom.xml, jraft-example/pom.xml, jraft-extension/{bdb-log-storage-impl, java-log-storage-impl, rpc-grpc-impl, pom.xml}, jraft-rheakv/{pom.xml, rheakv-core/pom.xml, rheakv-pd/pom.xml}, jraft-test/pom.xml Updated parent version from 1.3.15.bugfix to 1.3.16.
jraft-extension/.../BaseLogStorageTest.java Added opts.setGroupId("test"); to the newLogStorageOptions() method.
pom.xml (root) Updated project version from 1.3.15.bugfix to 1.3.16 and JNA dependency version from 5.5.0 to 5.7.0.

Possibly related PRs

  • release 1.3.15.bugfix #1141: Updates the parent version in jraft-core/pom.xml (to 1.3.15.bugfix), showing a similar focus on version management in the parent project.

Suggested labels

cla:yes, size/M

Suggested reviewers

  • fengjiachun
  • killme2008

Poem

I'm just a rabbit, hopping with glee,
Upgrading versions for you and me.
Parent artifacts leap to a higher state,
With a groupId now set to "test" — how great!
Dependencies updated, my whiskers twitch in rhyme,
Celebrating code changes in perfect time!
🐰 Hop, hop, hooray for a version sublime!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9029048 and 5962989.

📒 Files selected for processing (12)
  • jraft-core/pom.xml (1 hunks)
  • jraft-example/pom.xml (1 hunks)
  • jraft-extension/bdb-log-storage-impl/pom.xml (1 hunks)
  • jraft-extension/bdb-log-storage-impl/src/test/java/com/alipay/sofa/jraft/storage/impl/BaseLogStorageTest.java (1 hunks)
  • jraft-extension/java-log-storage-impl/pom.xml (1 hunks)
  • jraft-extension/pom.xml (1 hunks)
  • jraft-extension/rpc-grpc-impl/pom.xml (1 hunks)
  • jraft-rheakv/pom.xml (1 hunks)
  • jraft-rheakv/rheakv-core/pom.xml (1 hunks)
  • jraft-rheakv/rheakv-pd/pom.xml (1 hunks)
  • jraft-test/pom.xml (1 hunks)
  • pom.xml (2 hunks)
✅ Files skipped from review due to trivial changes (6)
  • jraft-rheakv/pom.xml
  • jraft-core/pom.xml
  • jraft-extension/rpc-grpc-impl/pom.xml
  • jraft-extension/java-log-storage-impl/pom.xml
  • jraft-test/pom.xml
  • jraft-extension/pom.xml
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: stc
  • GitHub Check: sca
🔇 Additional comments (8)
jraft-extension/bdb-log-storage-impl/src/test/java/com/alipay/sofa/jraft/storage/impl/BaseLogStorageTest.java (1)

72-72:

✅ Verification successful

LGTM! Fix for NPE in BaseLogStorageTest.

The addition of opts.setGroupId("test") resolves the NullPointerException by ensuring a non-null group ID is set before the test execution.

Let's verify that this was the only instance requiring the group ID initialization:


🏁 Script executed:

#!/bin/bash
# Search for other test classes that might need similar initialization
ast-grep --pattern 'class $_ extends BaseLogStorageTest {
  $$$
}'

Length of output: 68


Attention: Verify Group ID Initialization in Extended Test Classes

The addition of opts.setGroupId("test") in newLogStorageOptions() effectively prevents the NPE observed in the testTruncatePrefix method of BaseLogStorageTest, by ensuring that the group ID is non-null. However, our initial AST-based search returned no output, making it unclear whether other test classes extending BaseLogStorageTest might also require similar initialization.

  • Action Required: Please run the above rg script (or manually verify) to ensure that no additional test classes extending BaseLogStorageTest are missing this critical group ID initialization.

LGTM on the fix once this verification is complete.


🏁 Script executed:

[run_scripts]
#!/bin/bash
# Re-check for any test classes extending BaseLogStorageTest that might require similar group ID initialization.
rg "extends\s+BaseLogStorageTest" -n .

Length of output: 836


Attention: Verify Inherited Group ID Initialization in Extended Test Classes

Our recent search shows that several test classes extend BaseLogStorageTest (namely, BDBLogStorageTest, RocksDBSegmentLogStorageTest (two instances), and LogitLogStorageTest). The fix in BaseLogStorageTest—adding opts.setGroupId("test")—ensures that a non-null group ID is set, thereby preventing the NPE.

Before finalizing approval, please verify whether any of these extended test classes override the newLogStorageOptions() method. If they do, they may miss the updated group ID initialization. The above script will help identify such overrides. If no overrides occur, then the fix is effectively inherited.

LGTM on the fix in BaseLogStorageTest once manual verification confirms no overrides in the extended classes.


🏁 Script executed:

[run_scripts]
#!/bin/bash
# Search for potential overrides of newLogStorageOptions in classes extending BaseLogStorageTest.
rg "public.*newLogStorageOptions" -n .

Length of output: 162


LGTM! Fix for NPE in BaseLogStorageTest is verified.

The addition of opts.setGroupId("test") in newLogStorageOptions() effectively prevents the NullPointerException observed in the testTruncatePrefix method. Our search confirmed that several test classes extend BaseLogStorageTest (such as BDBLogStorageTest, RocksDBSegmentLogStorageTest, and LogitLogStorageTest). Moreover, a re-check for any overrides of newLogStorageOptions in these extended classes produced no output, indicating that none of them override the method. This means that the group ID initialization is inherited by all subclasses.

Please ensure that ongoing test executions continue to pass as expected.

jraft-extension/bdb-log-storage-impl/pom.xml (1)

7-7: LGTM! Version update is consistent.

The version update to 1.3.16 aligns with the coordinated version updates across all modules.

jraft-rheakv/rheakv-pd/pom.xml (1)

7-7: LGTM! Consistent version update in rheakv modules.

The version update to 1.3.16 maintains consistency across the project modules.

jraft-rheakv/rheakv-core/pom.xml (2)

7-7: LGTM! Version update aligns with other modules.

The version update to 1.3.16 is consistent with other module updates.


7-7:

❓ Verification inconclusive

Verify JNA version update for Apple Silicon support.

The PR objectives mention upgrading JNA from 5.5.0 to 5.7.0 for Apple Silicon support, but this change is not visible in the provided files.

Let's verify the JNA version update:


🏁 Script executed:

#!/bin/bash
# Search for JNA dependency in pom files
rg -l "jna" --type xml

Length of output: 49


Verify JNA Version Update for Apple Silicon Support

The PR objectives indicate that the JNA dependency should be upgraded from 5.5.0 to 5.7.0 for Apple Silicon support. However, the file under review (jraft-rheakv/rheakv-core/pom.xml) only shows:

        <version>1.3.16</version>

Our repository-wide search for "jna" returned results in jraft-core/pom.xml and pom.xml, which suggests that the JNA dependency may be managed in those files rather than in jraft-rheakv/rheakv-core/pom.xml. Please verify the following:

  • Confirm that the JNA version update to 5.7.0 has been applied in the correct module (likely in the parent pom or within jraft-core/pom.xml).
  • If the update was intended to affect jraft-rheakv/rheakv-core/pom.xml, ensure that the dependency management reflects the new version.
  • Cross-check the overall dependency configuration to guarantee consistency with the PR objectives regarding Apple Silicon support.
jraft-example/pom.xml (1)

8-8: Parent Version Update in jraft-example/pom.xml.
The parent version has been updated from 1.3.15.bugfix to 1.3.16, which aligns with the overall project release and ensures consistency across modules.

pom.xml (2)

7-7: Project Version Update in Root POM.
The root POM's version update to 1.3.16 standardizes the release version across all modules. This change is in line with the PR objectives for a coordinated version bump.


66-66: JNA Dependency Upgrade.
Upgrading the JNA dependency from version 5.5.0 to 5.7.0 is essential to support Apple Silicon and mitigate compatibility issues. Ensure that this newer version is tested across the expected environments.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants