Skip to content

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

Merged
taklwu merged 1 commit into
apache:HBASE-30018from
VladRodionov:HBASE-30206-cache-access-service-test-factory
Jun 16, 2026
Merged

HBASE-30206 Add test factory helpers for CacheAccessService-backed ca…#8359
taklwu merged 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds bridge utilities to simplify test migration from legacy BlockCache implementations to the newer CacheAccessService facade, while keeping the underlying legacy cache construction paths intact.

Changes:

  • Add CacheAccessServices.fromConfiguration(Configuration) to build a CacheAccessService via the existing BlockCacheFactory path.
  • Introduce test-only helpers (CacheAccessServiceTestFactory, CacheAccessServiceTestInstance) to create/wrap legacy cache implementations with a CacheAccessService.
  • Add a new unit test class covering the new test factory helpers.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/CacheAccessServices.java Adds a Configuration-based factory method for producing CacheAccessService via BlockCacheFactory.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/CacheAccessServiceTestFactory.java Provides test-only “constructor-shaped” helpers to create legacy caches and return a CacheAccessService or paired instance.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/CacheAccessServiceTestInstance.java Adds a helper wrapper that keeps a concrete BlockCache alongside its CacheAccessService facade.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/cache/TestCacheAccessServiceTestFactory.java Adds unit tests for the new test factory helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@taklwu taklwu 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.

LGTM

@taklwu taklwu merged commit ccc5ca1 into apache:HBASE-30018 Jun 16, 2026
7 of 8 checks passed
@VladRodionov

Copy link
Copy Markdown
Contributor Author

Thank you, @taklwu for review.

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