Skip to content

test: add dual DB engine test coverage with RocksDB support#12

Open
vividctrlalt wants to merge 3 commits intodevelopfrom
test/dual-db-engine-coverage
Open

test: add dual DB engine test coverage with RocksDB support#12
vividctrlalt wants to merge 3 commits intodevelopfrom
test/dual-db-engine-coverage

Conversation

@vividctrlalt
Copy link
Owner

Summary

java-tron supports both LevelDB and RocksDB, but the test suite only ran with the default engine (LevelDB). This PR adds dual DB engine test coverage so the same business tests can run under both engines, and fixes several related issues.

What changed

  • Dual DB engine override via Typesafe Config: Gradle testWithRocksDb task sets -Dstorage.db.engine=ROCKSDB, which ConfigFactory.load() merges automatically — no code changes needed in individual tests
  • ARM64 validation: Move ARM64 engine check from Storage.getDbEngineFromConfig() to explicit Args.validateConfig(), called in FullNode.main()
  • Parameterized DB tests: Create DbDataSourceImplTest with @RunWith(Parameterized.class) to run common DB operations against both LevelDB and RocksDB, eliminating ~400 lines of duplicate code
  • BaseMethodTest: New base class for tests requiring per-method Spring context isolation
  • Flaky test fixes: TrieTest, ConditionallyStopTest, NeedBeanCondition null-safety, NativeMessageQueue shutdown hook
  • CI workflow: Add testWithRocksDb step to pr-check.yml for x86_64 builds

Why

  1. RocksDB is the production engine on ARM64 and increasingly on x86 — tests should cover it
  2. Duplicate LevelDB/RocksDB test files were a maintenance burden (~900 lines of near-identical code)

Test plan

  • ./gradlew :framework:test — all existing tests pass
  • ./gradlew :framework:checkstyleTest — clean
  • CI all green on fork PR

- Extract shared test logic into DbDataSourceImplTest, BaseMethodTest, TestConstants
- Enable DB engine override via system property so tests run against both engines
- Refactor 20+ test classes to support dual-engine testing
- Fix flaky tests: FreezeTest, FreezeV2Test, VoteTest, ManagerTest, ShieldedReceiveTest
- Update build.gradle and CI workflow accordingly
@vividctrlalt vividctrlalt force-pushed the test/dual-db-engine-coverage branch from e61d378 to a9dfd5b Compare March 18, 2026 05:44
vividctrlalt and others added 2 commits March 18, 2026 09:16
Add assumeLevelDbAvailable() to DBIteratorTest.testLevelDb to skip
when LevelDB JNI is unavailable on ARM64 platforms.

Co-Authored-By: 3for <zouyudi@gmail.com>
On ARM64, LevelDB is not available at build time. Instead of throwing
an exception that breaks default config startup, warn and override
to RocksDB. Also uses equalsIgnoreCase for consistency.
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