Skip to content

Commit

Permalink
Rename instrumenter tests (#118462) (#118479)
Browse files Browse the repository at this point in the history
The "sythetic" tests are the only unit tests for the instrumenter. This
commit renames the test suite to be more clear it is the place to put
instrumenter tests.
  • Loading branch information
rjernst authored Dec 11, 2024
1 parent fcf634c commit 34a5457
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
* some ad-hoc test cases (e.g. overloaded methods, overloaded targets, multiple instrumentation, etc.)
*/
@ESTestCase.WithoutSecurityManager
public class SyntheticInstrumenterTests extends ESTestCase {
private static final Logger logger = LogManager.getLogger(SyntheticInstrumenterTests.class);
public class InstrumenterTests extends ESTestCase {
private static final Logger logger = LogManager.getLogger(InstrumenterTests.class);

/**
* Contains all the virtual methods from {@link TestClassToInstrument},
Expand Down Expand Up @@ -137,10 +137,10 @@ public void checkSomeStaticMethod(Class<?> callerClass, int arg, String anotherA
@Override
public void checkSomeInstanceMethod(Class<?> callerClass, Testable that, int arg, String anotherArg) {
checkSomeInstanceMethodCallCount++;
assertSame(SyntheticInstrumenterTests.class, callerClass);
assertSame(InstrumenterTests.class, callerClass);
assertThat(
that.getClass().getName(),
startsWith("org.elasticsearch.entitlement.instrumentation.impl.SyntheticInstrumenterTests$TestClassToInstrument")
startsWith("org.elasticsearch.entitlement.instrumentation.impl.InstrumenterTests$TestClassToInstrument")
);
assertEquals(123, arg);
assertEquals("def", anotherArg);
Expand All @@ -150,14 +150,14 @@ public void checkSomeInstanceMethod(Class<?> callerClass, Testable that, int arg
@Override
public void checkCtor(Class<?> callerClass) {
checkCtorCallCount++;
assertSame(SyntheticInstrumenterTests.class, callerClass);
assertSame(InstrumenterTests.class, callerClass);
throwIfActive();
}

@Override
public void checkCtor(Class<?> callerClass, int arg) {
checkCtorIntCallCount++;
assertSame(SyntheticInstrumenterTests.class, callerClass);
assertSame(InstrumenterTests.class, callerClass);
assertEquals(123, arg);
throwIfActive();
}
Expand Down Expand Up @@ -374,8 +374,8 @@ public void testInstrumenterWorksWithConstructors() throws Exception {
* Testable) which is not what would happen when it's run by the agent.
*/
private InstrumenterImpl createInstrumenter(Map<MethodKey, CheckMethod> checkMethods) {
String checkerClass = Type.getInternalName(SyntheticInstrumenterTests.MockEntitlementChecker.class);
String handleClass = Type.getInternalName(SyntheticInstrumenterTests.TestEntitlementCheckerHolder.class);
String checkerClass = Type.getInternalName(InstrumenterTests.MockEntitlementChecker.class);
String handleClass = Type.getInternalName(InstrumenterTests.TestEntitlementCheckerHolder.class);
String getCheckerClassMethodDescriptor = Type.getMethodDescriptor(Type.getObjectType(checkerClass));

return new InstrumenterImpl(handleClass, getCheckerClassMethodDescriptor, "_NEW", checkMethods);
Expand Down

0 comments on commit 34a5457

Please sign in to comment.