Skip to content

HBASE-30206 Add test factory helpers for CacheAccessService-backed ca…#8359

Open
VladRodionov wants to merge 1 commit into
apache:HBASE-30018from
VladRodionov:HBASE-30206-cache-access-service-test-factory
Open

HBASE-30206 Add test factory helpers for CacheAccessService-backed ca…#8359
VladRodionov wants to merge 1 commit into
apache:HBASE-30018from
VladRodionov:HBASE-30206-cache-access-service-test-factory

Conversation

@VladRodionov

Copy link
Copy Markdown
Contributor

Summary

This PR adds test-only factory helpers for creating CacheAccessService instances backed by existing legacy BlockCache implementations.

The goal is to make test migration to CacheAccessService less verbose. Many existing tests directly instantiate concrete BlockCache implementations such as LruBlockCache, LruAdaptiveBlockCache, TinyLfuBlockCache, and BucketCache. For integration-style tests that only need a cache facade, replacing a one-line constructor with several lines of BlockCache construction plus CacheAccessService wrapping adds noise.

This PR provides constructor-shaped test helpers that keep those tests concise while preserving the current legacy-backed implementation path.

Changes

  • Adds CacheAccessServices.fromConfiguration(Configuration), which creates a CacheAccessService through the existing BlockCacheFactory path.
  • Adds CacheAccessServiceTestFactory with helpers that mirror constructors for:
    • LruBlockCache
    • LruAdaptiveBlockCache
    • TinyLfuBlockCache
    • BucketCache
  • Adds CacheAccessServiceTestInstance for tests that need both:
    • the concrete BlockCache instance for implementation-specific assertions, and
    • the CacheAccessService facade for exercising the new access path.
  • Adds unit coverage for the new test factory helpers.

Compatibility notes

The factory helpers are test-only bridge utilities. They currently create legacy BlockCache implementations and wrap them with BlockCacheBackedCacheAccessService.

This does not change production cache construction. It also does not migrate existing cache implementations to CacheEngine. Later, when CacheEngine and topology-backed services are available, these factory internals can be updated without rewriting all integration-style tests again.

Out of scope

  • No production BlockCacheFactory refactoring.
  • No CacheEngine adapter migration.
  • No migration of LruBlockCache, LruAdaptiveBlockCache, TinyLfuBlockCache, or BucketCache to CacheEngine.
  • No broad migration of existing tests.
  • No cache behavior or cache semantics changes.

Testing

Ran:

mvn -pl hbase-server -Dtest=TestCacheAccessServiceTestFactory test
mvn -pl hbase-server -DskipTests compile
mvn -pl hbase-server spotless:check
mvn -pl hbase-server checkstyle:check

Disclosure

Parts of this PR, including helper code structure and PR description text, were prepared with assistance from ChatGPT 5.5 and reviewed by the author.

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