Skip to content

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

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

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

Conversation

@bitflicker64

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, MemoryAllocateTest 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, at this PR head. 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 1031/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.

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.

  • 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.

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 41.93%. Comparing base (36bc1c6) to head (a46e822).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3309      +/-   ##
============================================
+ Coverage     41.57%   41.93%   +0.36%     
- Complexity     7025     7103      +78     
============================================
  Files           762      761       -1     
  Lines         67060    66190     -870     
  Branches       9021     8920     -101     
============================================
- Hits          27880    27758     -122     
+ Misses        35969    35255     -714     
+ Partials       3211     3177      -34     

☔ 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.

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.

1 participant