Package org.apache.hadoop.hbase.http
Class TestProfilerBackendIsolated
java.lang.Object
org.apache.hadoop.hbase.http.TestProfilerBackendIsolated
@Tag("org.apache.hadoop.hbase.testclassification.MiscTests") @Tag("org.apache.hadoop.hbase.testclassification.SmallTests")
public class TestProfilerBackendIsolated
extends Object
Verifies
ProfilerBackend.detect(java.lang.String) fallback behaviour when
one.profiler.AsyncProfiler is absent from the classpath.
Each test loads ProfilerBackend through a custom ClassLoader that blocks
one.profiler.*, simulating a deployment where the async-profiler JAR was never packaged.
This is the exact scenario for users who have async-profiler installed as a native binary
(ASYNC_PROFILER_HOME) but are not allowed to bundle the JAR.
The split of LibraryBackend into its own file is what makes this possible:
ProfilerBackend.class carries no static reference to AsyncProfiler, so the
isolated loader can load it without a NoClassDefFoundError.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate MethoddetectMethod(ClassLoader loader) LoadsProfilerBackendthrough the given loader and returns itsdetect(String)method, made accessible across loader boundaries.private ClassLoaderReturns a ClassLoader that: - blocksone.profiler.*entirely (simulates absent async-profiler JAR) - reloadsorg.apache.hadoop.hbase.http.*classes fresh (so LibraryBackend resolves its own imports through this loader and also sees one.profiler.* as absent) - delegates everything else to the parentvoidLibrary present AND home set — LibraryBackend must still win (priority check).voidUser has async-profiler installed as a native binary (ASYNC_PROFILER_HOME set, bin/asprof present) but no JAR on the classpath.voidWhen the library IS on the classpath (normal test classpath), detect() must return LibraryBackend regardless of whether a home is set — library takes priority.voidWhen the library is absent AND no home is set, detect() must return null so that HttpServer registers DisabledServlet instead of crashing.
-
Field Details
-
tempDir
-
-
Constructor Details
-
TestProfilerBackendIsolated
public TestProfilerBackendIsolated()
-
-
Method Details
-
testDetectReturnsNullWhenLibraryAbsentAndNoHome
When the library is absent AND no home is set, detect() must return null so that HttpServer registers DisabledServlet instead of crashing.- Throws:
Exception
-
testDetectReturnsBinaryBackendWhenLibraryAbsentButHomeSet
User has async-profiler installed as a native binary (ASYNC_PROFILER_HOME set, bin/asprof present) but no JAR on the classpath. detect() must return BinaryBackend.- Throws:
Exception
-
testDetectReturnsLibraryBackendWhenLibraryPresent
When the library IS on the classpath (normal test classpath), detect() must return LibraryBackend regardless of whether a home is set — library takes priority. -
testDetectPrefersLibraryWhenBothPresent
Library present AND home set — LibraryBackend must still win (priority check).- Throws:
Exception
-
isolatedLoader
Returns a ClassLoader that: - blocksone.profiler.*entirely (simulates absent async-profiler JAR) - reloadsorg.apache.hadoop.hbase.http.*classes fresh (so LibraryBackend resolves its own imports through this loader and also sees one.profiler.* as absent) - delegates everything else to the parent -
detectMethod
LoadsProfilerBackendthrough the given loader and returns itsdetect(String)method, made accessible across loader boundaries.- Throws:
Exception
-