Skip to content

test: add coverage across struct, commons, server, pd, store and cluster - #3309

Open
bitflicker64 wants to merge 13 commits into
apache:masterfrom
hugegraph:test-coverage-1.8
Open

bitflicker64 wants to merge 13 commits into
apache:masterfrom
hugegraph:test-coverage-1.8

Conversation

@bitflicker64

@bitflicker64 bitflicker64 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Purpose of the PR

Before 1.8.0 we wanted more executable tests module by module, with attention to the parts that changed recently: the Java 17 migration, the new hugegraph-struct module, and the RocksDB and JRaft upgrades. Several test classes in the repository also compiled but never ran, because no suite or Surefire include picked them up.

This PR only touches test classes and suite registration. There are no production, dependency, configuration, CI or documentation changes. Each module is a separate commit so it can be reviewed on its own.

Each module's new and newly registered tests, the Maven profile and suite that runs them, and the tests left unregistered with the reason

Main Changes

Commit Lines What it adds
test(struct) +451 Struct-side BytesBufferTest: varint rejection, unsigned limits, length-prefixed bytes, string endings, edge and index id encoding, partition and OLAP id parsing, tagged collections, buffer growth. EdgeIdTest: text form, parse errors, binary id generation.
test(commons) +899 TypedOptionTest (option parsing and checkers), HugeConfigValidationTest (URL normalization, input validation), HostNameVerifierTest (negative paths after #3307: SAN matching, wildcard scope, IP vs DNS, no CN fallback), rpc RpcConfigTest (self URL exclusion, invalid options, provider and consumer config, service cleanup on destroy).
test(server) +677 RocksDBStdSessionsLifecycleTest (unopened tables, rollback, reopen, lock release after force close and bad options, iterator double close, snapshot path), RocksDBIteratorPoolTest, HstoreTableRoutingTest. Registers ConsumersTest and MemoryManageTest, which existed but never ran.
test(pd) +692 KVOperationTest (encoding, null checks, truncated input, whitelist decoding), RaftKVStoreTest (writes go through raft, leader check, raft failure, state machine replay), PeerUtilTest, ZipUtilsTest (snapshot checksums, zip-slip entries). Registers RaftReflectionUtilTest.
test(store) +1029 Base58EncoderTest, KeyUtilTest, CRC64Test, ZipUtilsPathSafetyTest (both ZipUtils copies), SessionOperatorTest (writes, ranges, iterator release, snapshots), PartitionMetaCodecTest, HgBufferProxyTest. Registers HgStoreStateMachineTest, FutureClosureTest, HgAssertTest and HgPairTest. The reuseForks=false setting of the core execution is unchanged.
test(cluster) +164 SimpleClusterGraphTest: creates schema, vertices and an edge through the server, reads them back by id and by adjacency through the HStore backend, and checks that invalid vertex requests and unknown ids are rejected.

New RocksDB tests use TemporaryFolder instead of fixed paths. No new test binds a fixed port.

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • Run locally on JDK 17.0.20 and Maven 3.8.7, on 2026-10-11. The server and PD rows were re-run at 03ffdf0bc after the review fixes. Base is 36bc1c64b. The figures are run/failed/errors/skipped.
Command (from the repository root) Before After
mvn test -pl hugegraph-struct 110/0/0/0 129/0/0/0
mvn test -pl hugegraph-commons/hugegraph-common -Dtest=UnitTestSuite -DskipCommonsTests=false 366/2/4/0 389/2/4/0
mvn test -pl hugegraph-commons/hugegraph-rpc -Dtest=UnitTestSuite -DskipCommonsTests=false 25/0/0/0 31/0/0/0
mvn test -pl hugegraph-server/hugegraph-test -P unit-test 996/0/0/8 1027/0/0/8
mvn test -pl hugegraph-pd/hg-pd-test -P pd-core-test 113/0/0/2 149/0/0/2
mvn test -pl hugegraph-store/hg-store-test -P store-common-test 2/0/0/0 14/0/0/0
... -P store-rocksdb-test 3/0/0/0 19/0/0/0
... -P store-raftcore-test 16/0/0/0 27/0/0/0
... -P store-client-test 67/0/0/0 90/0/0/0
... -P store-core-test 93 run, 1 failure (see below) 100/0/0/0
mvn test -pl hugegraph-cluster-test/hugegraph-clustertest-test -P simple-cluster-test 6/0/0/0 8/0/0/0
  • The 6 common failures and errors happen both before and after this change, and they come from the test host. Two RestClientTest HTTPS tests time out reaching an external endpoint, and four MachineInfoTest tests find no MAC or IP address on that machine.
  • The one store-core failure before the change was HeartbeatShutdownTest, in a checkout where hg-store-node had not been compiled. With a full build it passes.
  • Every new class was also run on its own at least twice. For each module, one expectation was broken on purpose to confirm that the tests fail.
  • mvn editorconfig:check passes on every touched test module.
  • The table above was measured on the original base 36bc1c64b. After the branch was synced with master at de392632e, CI at 14b1f4136 ran the server UnitTestSuite (job server_memory) with 1103/0/0/8; that count includes unit tests that arrived from master.

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:

Known limitations

These tests were left out or left unregistered on purpose.

  • MemoryAllocateTest passes, but two of its tests force a 1 GiB heap or direct allocation that is never released, so it is a stress test rather than a default unit test. It is left unregistered and unchanged.
  • MemoryConsumerTest passes on its own but fails inside UnitTestSuite. An earlier test terminates the shared EventHub executor, and its clearBackend() calls then get RejectedExecutionException. It is left unregistered and unchanged.
  • PDWatchTest has no assertions and needs a live PD. PDPulseTest is marked @Useless and waits forever against a live PD without stores. Neither is registered.
  • The store client tests that need a running cluster are not registered. Seven classes in the CoreSuiteTest TODO block pass on their own; they are left for a follow-up.
  • The cluster harness cannot stop and restart single nodes yet, so this PR has no node-failure scenarios. multi-cluster-test was not run locally.

Some new tests exposed behaviour that looks wrong in production code. Those tests are not part of this PR; the findings will be reported separately:

  • In struct IdUtil, an id part that ends with a backtick does not survive escaping and unescaping. SplicingIdGenerator.split(concat("a", "b"))returns["a>b"]`.
  • In struct BytesBuffer.readVInt and readVLong, the leading == 0x80 check compares a signed byte with 128, so it is never true. wrap({0x80, 1}).readVInt() returns 1.
  • HugeConfig.validateOption skips the option checker when a value is already of the target Java type. A port of 70000 passed as an Integer is accepted.
  • RocksDBStdSessions.scan() opens a native iterator before the scan arguments are checked, and never closes it when the check fails.

The native cursor capacity-stop fixture now waits for the initial producer handoff before allowing the worker to stop. This preserves the existing capacity, edge-count and resource-release assertions without depending on thread scheduling. Production code is unchanged; the fix passed the relevant native tests, Java 17 reactor compilation and three independent reviews.

Add struct-local tests for BytesBuffer varint rejection, unsigned
limits, length-prefixed bytes, string endings, edge and index id
encoding, partition and OLAP id parsing, tagged collections and buffer
growth, plus EdgeId text form, parse errors and binary id generation.
Add common tests for typed option parsing and checkers, HugeConfig URL
normalization and input validation, and HostNameVerifier negative paths
(SAN matching, wildcard scope, IP vs DNS, no CN fallback). Add an RPC
test for self URL exclusion, invalid RpcOptions, provider and consumer
config, and service cleanup on destroy. Register all in UnitTestSuite.
Add unit tests for RocksDBStdSessions lifecycle and error paths (unopened
tables, rollback, reopen, lock release on force close and bad options,
iterator double close, snapshot path), the RocksDB iterator pool, and
HStore table partition routing. Register them in UnitTestSuite together
with the existing ConsumersTest, MemoryAllocateTest and MemoryManageTest,
which compiled but never ran.
Add PD core tests for KVOperation encoding and whitelist decoding,
RaftKVStore write routing through raft (leader check, raft failure,
state machine replay), PeerUtil config parsing and ZipUtils snapshot
checksums and zip-slip handling. Register them, plus the existing
RaftReflectionUtilTest, in PDCoreSuiteTest.
Add Store tests for Base58 encoding, edge owner keys, CRC64, both
ZipUtils copies (round trip and zip-slip entries), SessionOperator
writes, ranges, iterator release and snapshots, partition and shard
group metadata, and HgBufferProxy flow control. Register them, plus the
existing HgStoreStateMachineTest, FutureClosureTest, HgAssertTest and
HgPairTest, in the matching suites.
Add SimpleClusterGraphTest, which creates schema, vertices and an edge
through the server, reads them back by id and by adjacency through the
HStore backend, and checks that invalid vertex requests and unknown
ids are rejected. Register it in SimpleClusterSuiteTest.
@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.29%. Comparing base (68fb045) to head (14b1f41).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3309      +/-   ##
============================================
- Coverage     52.63%   51.29%   -1.35%     
- Complexity     2435     2497      +62     
============================================
  Files           770      759      -11     
  Lines         67694    66363    -1331     
  Branches       9172     8932     -240     
============================================
- Hits          35631    34038    -1593     
- Misses        28520    29080     +560     
+ Partials       3543     3245     -298     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bitflicker64 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Blocking: no. Summary: Test-only change, and every new or newly registered class runs in CI at this head with the counts the description gives. One minor point on a mock that would turn a regression into an endless loop instead of a failed assertion. Evidence: Read the full diff at a46e822 against base 36bc1c6 (31 files, +3912/-6) and the production code under test. CI logs at this head show struct 129, commons 389 and 31, server UnitTestSuite 1031, PDCoreSuiteTest 149, store suites 14/19/27/90/100 and SimpleClusterSuiteTest 8, all without failures. The two red jobs are outside this diff: server_hbase stopped on a 504 while downloading jacococli.jar after its tests passed, and macos-15-intel failed MultiNodeShortestPathApiTest.testPost in ApiTestSuite on a query timeout.

Stop the mocked raft iterator after one entry in
testFollowerReplayStopsOnStoreFailure, so a missing early return fails
the never() check instead of looping forever.

Unregister MemoryAllocateTest from UnitTestSuite: two of its tests force
an unreleased 1 GiB heap or direct allocation, which is a stress test
rather than a unit test for the default suite.

@imbajin imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two source-level test-harness findings at a46e822. These are independent of the existing RaftKVStoreTest loop discussion; no independent runtime reproduction was performed.

Copilot AI balanced review requested due to automatic review settings October 11, 2026 11:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The advertised MemoryAllocateTest registration is absent, leaving a core verification claim inaccurate.

1 open finding
What changed in this PR

Expands executable regression coverage across HugeGraph modules for Java 17, serialization, RocksDB/JRaft, HStore, RPC, and cluster behavior.

Changes:

  • Adds targeted unit tests across Struct, Commons, Server, PD, and Store.
  • Registers new and previously dormant tests in module suites.
  • Adds an end-to-end HStore cluster graph test.
File Description
hugegraph-struct/​.../​BytesBufferTest.java Tests binary encoding and validation.
hugegraph-struct/​.../​EdgeIdTest.java Tests edge ID parsing and encoding.
hugegraph-store/​.../​ZipUtilsPathSafetyTest.java Tests archive safety and round trips.
hugegraph-store/​.../​SessionOperatorTest.java Tests RocksDB session operations.
hugegraph-store/​.../​RocksDbSuiteTest.java Registers RocksDB tests.
hugegraph-store/​.../​CRC64Test.java Tests CRC64 behavior.
hugegraph-store/​.../​RaftSuiteTest.java Registers Raft tests.
hugegraph-store/​.../​PartitionMetaCodecTest.java Tests partition metadata conversion.
hugegraph-store/​.../​CoreSuiteTest.java Registers metadata tests.
hugegraph-store/​.../​KeyUtilTest.java Tests key ownership routing.
hugegraph-store/​.../​CommonSuiteTest.java Registers common Store tests.
hugegraph-store/​.../​Base58EncoderTest.java Tests Base58 encoding.
hugegraph-store/​.../​HgBufferProxyTest.java Tests buffered streaming behavior.
hugegraph-store/​.../​ClientSuiteTest.java Registers client tests.
hugegraph-server/​.../​UnitTestSuite.java Expands server suite registration.
hugegraph-server/​.../​RocksDBStdSessionsLifecycleTest.java Tests RocksDB lifecycle paths.
hugegraph-server/​.../​HstoreTableRoutingTest.java Tests HStore routing.
hugegraph-server/​.../​RocksDBIteratorPoolTest.java Tests iterator ownership and closure.
hugegraph-pd/​.../​ZipUtilsTest.java Tests PD snapshot archives.
hugegraph-pd/​.../​PeerUtilTest.java Tests Raft peer parsing.
hugegraph-pd/​.../​KVOperationTest.java Tests Raft operation serialization.
hugegraph-pd/​.../​RaftKVStoreTest.java Tests Raft-backed KV dispatch.
hugegraph-pd/​.../​PDCoreSuiteTest.java Registers PD tests.
hugegraph-commons/​.../​UnitTestSuite.java Registers RPC configuration tests.
hugegraph-commons/​.../​RpcConfigTest.java Tests RPC configuration and cleanup.
hugegraph-commons/​.../​UnitTestSuite.java Registers Commons tests.
hugegraph-commons/​.../​HostNameVerifierTest.java Tests certificate hostname matching.
hugegraph-commons/​.../​TypedOptionTest.java Tests typed option parsing.
hugegraph-commons/​.../​HugeConfigValidationTest.java Tests configuration validation.
hugegraph-cluster-test/​.../​SimpleClusterSuiteTest.java Registers cluster graph tests.
hugegraph-cluster-test/​.../​SimpleClusterGraphTest.java Tests graph operations through HStore.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@bitflicker64 bitflicker64 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Blocking: yes. Summary: The 21 new and 7 newly registered test classes are all picked up by a CI test run and pass at this head, but SessionOperatorTest.tearDown() deadlocks on the CF write lock whenever a test fails while the test thread still holds the read lock from prepare(), so a failure in that class turns into a hung store job with no test named. Evidence: read the full diff 36bc1c6..03ffdf0 (31 files) and the production classes each test targets; checked every new class against its suite and the surefire includes in the hg-store-test, hg-pd-test, hugegraph-clustertest-test and server hugegraph-test poms (struct tests run through the default surefire includes, commons through -Dtest=UnitTestSuite); confirmed from the job logs of run 38136372195 that the suites ran with the new counts (commons 389 and 31, server UnitTestSuite 1027 in server_memory, PDCoreSuiteTest 149, CommonSuiteTest 14, ClientSuiteTest 90, RocksDbSuiteTest 19, RaftSuiteTest 27, CoreSuiteTest 41, SimpleClusterSuiteTest 8, struct 129); reproduced the hang on Linux, JDK 17.0.20, with one assertion changed to fail and a jstack of the surefire fork. The red pd_store / store check at this head is ScanLifecycleTest.testReceivePreservesExternalInterrupt in ServerSuiteTest, which this PR does not touch; affected-module-tests is red only because it reports that job.

A test that fails between prepare() and commit() leaves the CF read lock
held by the test thread, and RocksDBSession.close() then parks forever
on the CF write lock. Release the thread's remaining read holds before
closing, and add a Timeout rule so a stuck lock fails the test instead
of hanging the store job.
Copilot AI balanced review requested due to automatic review settings October 12, 2026 07:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

5 open findings

🧠 Review effort: Lite

Null-check each native resource before closing it, so a failure in
setup() is reported as itself instead of a NullPointerException from
teardown().
Copilot AI balanced review requested due to automatic review settings October 12, 2026 09:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

bitflicker64 and others added 4 commits October 12, 2026 17:39
Check the direct URL the SOFA consumer is created with instead of the
private remoteUrls field, so the test follows what the client uses.
- encode lifecycle fixture keys and values as UTF-8
- assert native lock status without localized messages
- normalize malicious ZIP entries and isolate archives
- preserve containment and live-owner assertions
- merge the approved ASF server baseline
- inherit current startup and required CI fixtures
- preserve existing coverage portability fixes
- wait for the initial producer handoff before capacity stop
- preserve native cursor and producer cleanup assertions
- retain the existing capacity and edge-count expectations
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.

3 participants