Repository navigation
Conversation
RaftEngine is a singleton reached through getInstance(). Tests that need a private engine build it reflectively, as PDNativeOwnerTest already does. Fixes apache#2655
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3380 +/- ##
==========================================
Coverage 55.93% 55.93%
- Complexity 2277 2313 +36
==========================================
Files 774 776 +2
Lines 68534 68865 +331
Branches 9333 9414 +81
==========================================
+ Hits 38334 38523 +189
- Misses 26634 26760 +126
- Partials 3566 3582 +16
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
bitflicker64
left a comment
There was a problem hiding this comment.
Blocking: no. Summary: Making the RaftEngine constructor private is correct and complete at this head; the only callers of new RaftEngine() outside the class were RaftKVStoreTest and RaftEngineReadinessTest, and both now build a private engine through the same reflective helper PDNativeOwnerTest already uses, so their behaviour is unchanged. Evidence: read the full diff at 4e39665; searched the whole repository at this head for new RaftEngine, subclasses and spy(RaftEngine...) (only the singleton field initializer remains; other tests use mock(RaftEngine.class), which does not call the constructor), found no RaftEngine references outside hugegraph-pd and no Spring or config-based instantiation; both changed tests are in PDCoreSuiteTest, which the pd_store / pd job runs with -P pd-core-test, and that job passed at this head along with every other non-skipped check.
imbajin
left a comment
There was a problem hiding this comment.
Blocking: no. Summary: The private-constructor change matches the singleton usage in this repository, and both isolated test constructions remain supported through reflection. Evidence: Exact-head diff and repository-wide constructor search; workflow run 39465275148 completed successfully with the PD job passing. No local tests were run. Score: 8.5/10
4e39665 to
b57bc5c
Compare
Purpose of the PR
RaftEngineis a singleton reached throughRaftEngine.getInstance(), but its constructor is public, so code can create a second engine that never joins the raft group.Main Changes
RaftEngine()is nowprivate.RaftEngineReadinessTestandRaftKVStoreTestbuilt private engines withnew RaftEngine(); they now use the same reflectivenewEngine()helperPDNativeOwnerTestalready uses. Their behaviour is unchanged.Nothing else constructs
RaftEngine: production code and other tests usegetInstance()ormock(RaftEngine.class)(Mockito creates mocks without calling the constructor). Store only depends onRaftReflectionUtilfrom hg-pd-core.Verifying these changes
RaftEngineReadinessTest,RaftKVStoreTest,PDNativeOwnerTest.Ran locally:
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-core-test(190 tests, 0 failures, 2 skipped) andmvn editorconfig:checkon hg-pd-core and hg-pd-test.Does this PR potentially affect the following parts?
Documentation Status
Doc - TODO: required documentation is pending; complete it before merging.Doc - Done: documentation is included here or linked below.Doc - No Need: no user-visible documentation is affected.Documentation files in this PR or paired hugegraph-doc PR:
🤖 Generated with Claude Code