Skip to content

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

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

test: add dual DB engine test coverage with RocksDB support#12
vividctrlalt wants to merge 7 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

- Refactor config validation to support dual-engine (LevelDB/RocksDB) test override
- Add BaseMethodTest for per-method Spring context isolation
- Unify DB tests with parameterized dual-engine coverage
- Migrate 176+ BaseTest subclasses to support dual DB engine override
- Fix flaky tests (TrieTest, ConditionallyStopTest, NeedBeanCondition null safety)
- Add ARM64 RocksDB engine test support
- Add RocksDB engine test step to PR check workflow
- Centralize config file constants in TestEnv
…rride

Replace withDbEngineOverride() CLI injection with Gradle systemProperty
'storage.db.engine' which ConfigFactory.load() merges automatically.
Rename TestEnv back to TestConstants to minimize review diff.
Restore 212 test files to develop state. The DB engine override is now
handled by Gradle systemProperty injection via Typesafe Config, so
individual test files no longer need withDbEngineOverride() wrapping
or TestConstants->TestEnv rename.
Test conflicts with Gradle system property injection on ARM64 CI.
The -Dstorage.db.engine=ROCKSDB override makes LEVELDB rejection
tests impossible to run on real ARM64 environments.
testConfigStorageDefaults expects LEVELDB but ARM64 CI injects
-Dstorage.db.engine=ROCKSDB. Use system property as expected value.
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