Remove useless tests from Glassfish 4 instrumentation

This commit is contained in:
Luca Abbati 2019-05-29 17:24:51 +02:00
parent 37b734dd50
commit 19c0b21332
No known key found for this signature in database
GPG Key ID: C901DDA2FFE14529
5 changed files with 5 additions and 71 deletions

View File

@ -1,33 +0,0 @@
package datadog.trace.instrumentation.glassfish4
import com.sun.enterprise.v3.server.APIClassLoaderServiceImpl
import datadog.trace.agent.test.AgentTestRunner
class GlassfishInstrumentationTest extends AgentTestRunner {
def "classes not related to datadog can be black-listed"() {
setup:
def cli = new APIClassLoaderServiceImpl()
def cl = cli.getApiClassLoader()
cl.triggerAddToBlackList('com.some.Entity')
// def rf = ReflectionFactory.reflectionFactory
// def clazz = Class.forName('com.sun.enterprise.v3.server.APIClassLoaderServiceImpl$APIClassLoader')
// def objDef = clazz.getDeclaredConstructor(ClassLoader.class, ClassLoader.class)
// def intConstr = rf.newConstructorForSerialization(clazz, objDef)
// def instance = clazz.cast(intConstr.newInstance())
expect:
'com.some.Entity' in cl.blacklist
}
def "classes related to datadog are not black-listed"() {
setup:
def cli = new APIClassLoaderServiceImpl()
def cl = cli.getApiClassLoader()
cl.triggerAddToBlackList('io.opentracing.some.Entity')
expect:
!('io.opentracing.some.Entity' in cl.blacklist)
'__datadog_no_blacklist.io.opentracing.some.Entity' in cl.blacklist
}
}

View File

@ -1,34 +0,0 @@
package com.sun.enterprise.v3.server;
import java.util.HashSet;
import java.util.Set;
public class APIClassLoaderServiceImpl {
private APIClassLoader instance;
public APIClassLoaderServiceImpl() {
this.instance = new APIClassLoader();
}
public APIClassLoader getApiClassLoader() {
return instance;
}
private class APIClassLoader {
private Set<String> blacklist = new HashSet<String>();
public void triggerAddToBlackList(String name) {
addToBlackList(name);
}
private synchronized void addToBlackList(String name) {
blacklist.add(name);
}
public Set<String> getBlacklist() {
return blacklist;
}
}
}

View File

@ -6,7 +6,8 @@ muzzle {
pass {
group = 'org.glassfish.main.extras'
module = 'glassfish-embedded-all'
versions = "[4.1,4.1.2)"
versions = "[4.0,4.1.2)"
assertInverse = true
}
}
@ -28,7 +29,7 @@ dependencies {
implementation deps.autoservice
testCompile project(':dd-java-agent:testing')
// testCompile group: 'org.glassfish.main.extras', name: 'glassfish-embedded-all', version: '4.1.2'
testCompile group: 'org.glassfish.main.extras', name: 'glassfish-embedded-all', version: '4.1.2'
latestDepTestCompile sourceSets.test.output
}

View File

@ -29,7 +29,7 @@ import net.bytebuddy.matcher.ElementMatchers;
public final class GlassfishInstrumentation extends Instrumenter.Default {
public GlassfishInstrumentation() {
super("cassandra");
super("glassfish");
}
@Override

View File

@ -40,7 +40,7 @@ include ':dd-java-agent:instrumentation:elasticsearch:transport-2'
include ':dd-java-agent:instrumentation:elasticsearch:transport-5'
include ':dd-java-agent:instrumentation:elasticsearch:transport-5.3'
include ':dd-java-agent:instrumentation:elasticsearch:transport-6'
include ':dd-java-agent:instrumentation:glassfish-4.1'
include ':dd-java-agent:instrumentation:glassfish-4'
include ':dd-java-agent:instrumentation:grpc-1.5'
include ':dd-java-agent:instrumentation:hibernate'
include ':dd-java-agent:instrumentation:hibernate:core-3.3'