diff --git a/instrumentation/hibernate/hibernate-4.3/javaagent/hibernate-4.3-javaagent.gradle b/instrumentation/hibernate/hibernate-4.3/javaagent/hibernate-4.3-javaagent.gradle index 22df5fe0ca09..050123d81f7f 100644 --- a/instrumentation/hibernate/hibernate-4.3/javaagent/hibernate-4.3-javaagent.gradle +++ b/instrumentation/hibernate/hibernate-4.3/javaagent/hibernate-4.3-javaagent.gradle @@ -1,4 +1,5 @@ apply from: "$rootDir/gradle/instrumentation.gradle" +apply plugin: 'org.unbroken-dome.test-sets' muzzle { pass { @@ -9,8 +10,23 @@ muzzle { } } +testSets { + version5Test { + dirName = 'test' + } + version6Test { + dirName = 'test' + } + + latestDepTest { + dirName = 'test' + } +} + +test.dependsOn version5Test, version6Test + dependencies { - library group: 'org.hibernate', name: 'hibernate-core', version: '4.3.0.Final' + implementation group: 'org.hibernate', name: 'hibernate-core', version: '4.3.0.Final' implementation project(':instrumentation:hibernate:hibernate-common:javaagent') @@ -19,15 +35,25 @@ dependencies { testInstrumentation project(':instrumentation:hibernate:hibernate-3.3:javaagent') testInstrumentation project(':instrumentation:hibernate:hibernate-4.0:javaagent') - testLibrary group: 'org.hibernate', name: 'hibernate-entitymanager', version: '4.3.0.Final' + testImplementation group: 'org.hibernate', name: 'hibernate-entitymanager', version: '4.3.0.Final' testImplementation group: 'org.hsqldb', name: 'hsqldb', version: '2.0.0' //First version to work with Java 14 - testLibrary group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.8.0.RELEASE' + testImplementation group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.8.0.RELEASE' + + version5TestImplementation group: 'org.hibernate', name: 'hibernate-core', version: '5.0.0.Final' + version5TestImplementation group: 'org.hibernate', name: 'hibernate-entitymanager', version: '5.0.0.Final' + version5TestImplementation group: 'org.springframework.data', name: 'spring-data-jpa', version: '2.3.0.RELEASE' + + version6TestImplementation group: 'org.hibernate', name: 'hibernate-core', version: '6.0.0.Alpha6' + version6TestImplementation group: 'org.hibernate', name: 'hibernate-entitymanager', version: '6.0.0.Alpha6' + version6TestImplementation group: 'org.springframework.data', name: 'spring-data-jpa', version: '2.3.0.RELEASE' - // TODO(anuraaga): Investigate why these tests don't pass on 5 or 6 - // https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/1042 - latestDepTestLibrary group: 'org.hibernate', name: 'hibernate-core', version: '4.+' - latestDepTestLibrary group: 'org.hibernate', name: 'hibernate-entitymanager', version: '4.+' + testImplementation group: 'javax.activation', name: 'javax.activation-api', version: '1.2.0' + testImplementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1' + testImplementation group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '2.3.3' - latestDepTestLibrary group: 'org.springframework.data', name: 'spring-data-jpa', version: '(,2.4.0)' + // hibernate 6 is alpha so use 5 as latest version + latestDepTestImplementation group: 'org.hibernate', name: 'hibernate-core', version: '5.+' + latestDepTestImplementation group: 'org.hibernate', name: 'hibernate-entitymanager', version: '5.+' + latestDepTestImplementation group: 'org.springframework.data', name: 'spring-data-jpa', version: '(2.4.0,)' } diff --git a/instrumentation/hibernate/hibernate-4.3/javaagent/src/test/groovy/ProcedureCallTest.groovy b/instrumentation/hibernate/hibernate-4.3/javaagent/src/test/groovy/ProcedureCallTest.groovy index 062c1273d11c..d583b9b57976 100644 --- a/instrumentation/hibernate/hibernate-4.3/javaagent/src/test/groovy/ProcedureCallTest.groovy +++ b/instrumentation/hibernate/hibernate-4.3/javaagent/src/test/groovy/ProcedureCallTest.groovy @@ -17,6 +17,7 @@ import org.hibernate.SessionFactory import org.hibernate.cfg.Configuration import org.hibernate.exception.SQLGrammarException import org.hibernate.procedure.ProcedureCall +import org.junit.Assume import spock.lang.Shared class ProcedureCallTest extends AgentInstrumentationSpecification { @@ -55,6 +56,16 @@ class ProcedureCallTest extends AgentInstrumentationSpecification { } } + def callProcedure(ProcedureCall call) { + try { + call.getOutputs() + } catch (Exception exception) { + // ignore failures on hibernate 6 where this functionality has not been implemented yet + Assume.assumeFalse("org.hibernate.NotYetImplementedFor6Exception" == exception.getClass().getName()) + throw exception + } + } + def "test ProcedureCall"() { setup: @@ -62,7 +73,7 @@ class ProcedureCallTest extends AgentInstrumentationSpecification { session.beginTransaction() ProcedureCall call = session.createStoredProcedureCall("TEST_PROC") - call.getOutputs() + callProcedure(call) session.getTransaction().commit() session.close() @@ -114,10 +125,11 @@ class ProcedureCallTest extends AgentInstrumentationSpecification { session.beginTransaction() ProcedureCall call = session.createStoredProcedureCall("TEST_PROC") - call.registerParameter("nonexistent", Long, ParameterMode.IN) - call.getParameterRegistration("nonexistent").bindValue(420L) + def parameterRegistration = call.registerParameter("nonexistent", Long, ParameterMode.IN) + Assume.assumeTrue(parameterRegistration.metaClass.getMetaMethod("bindValue", Object) != null) + parameterRegistration.bindValue(420L) try { - call.getOutputs() + callProcedure(call) } catch (Exception e) { // We expected this. } diff --git a/instrumentation/hibernate/hibernate-4.3/javaagent/src/test/groovy/SpringJpaTest.groovy b/instrumentation/hibernate/hibernate-4.3/javaagent/src/test/groovy/SpringJpaTest.groovy index b8c362162986..c6ba0a7ddb71 100644 --- a/instrumentation/hibernate/hibernate-4.3/javaagent/src/test/groovy/SpringJpaTest.groovy +++ b/instrumentation/hibernate/hibernate-4.3/javaagent/src/test/groovy/SpringJpaTest.groovy @@ -41,7 +41,7 @@ class SpringJpaTest extends AgentInstrumentationSpecification { "${SemanticAttributes.DB_SYSTEM.key}" "hsqldb" "${SemanticAttributes.DB_NAME.key}" "test" "${SemanticAttributes.DB_USER.key}" "sa" - "${SemanticAttributes.DB_STATEMENT.key}" "select customer0_.id as id1_0_, customer0_.firstName as firstNam2_0_, customer0_.lastName as lastName3_0_ from Customer customer0_" + "${SemanticAttributes.DB_STATEMENT.key}" ~/select ([^\.]+)\.id([^\,]*), ([^\.]+)\.firstName([^\,]*), ([^\.]+)\.lastName(.*)from Customer(.*)/ "${SemanticAttributes.DB_CONNECTION_STRING.key}" "hsqldb:mem:" } } @@ -104,7 +104,7 @@ class SpringJpaTest extends AgentInstrumentationSpecification { "${SemanticAttributes.DB_SYSTEM.key}" "hsqldb" "${SemanticAttributes.DB_NAME.key}" "test" "${SemanticAttributes.DB_USER.key}" "sa" - "${SemanticAttributes.DB_STATEMENT.key}" "select customer0_.id as id1_0_0_, customer0_.firstName as firstNam2_0_0_, customer0_.lastName as lastName3_0_0_ from Customer customer0_ where customer0_.id=?" + "${SemanticAttributes.DB_STATEMENT.key}" ~/select ([^\.]+)\.id([^\,]*), ([^\.]+)\.firstName([^\,]*), ([^\.]+)\.lastName (.*)from Customer (.*)where ([^\.]+)\.id( ?)=( ?)\?/ "${SemanticAttributes.DB_CONNECTION_STRING.key}" "hsqldb:mem:" } } @@ -140,7 +140,7 @@ class SpringJpaTest extends AgentInstrumentationSpecification { "${SemanticAttributes.DB_SYSTEM.key}" "hsqldb" "${SemanticAttributes.DB_NAME.key}" "test" "${SemanticAttributes.DB_USER.key}" "sa" - "${SemanticAttributes.DB_STATEMENT.key}" "select customer0_.id as id1_0_, customer0_.firstName as firstNam2_0_, customer0_.lastName as lastName3_0_ from Customer customer0_ where customer0_.lastName=?" + "${SemanticAttributes.DB_STATEMENT.key}" ~/select ([^\.]+)\.id([^\,]*), ([^\.]+)\.firstName([^\,]*), ([^\.]+)\.lastName (.*)from Customer (.*)(where ([^\.]+)\.lastName( ?)=( ?)\?|)/ "${SemanticAttributes.DB_CONNECTION_STRING.key}" "hsqldb:mem:" } } @@ -161,7 +161,7 @@ class SpringJpaTest extends AgentInstrumentationSpecification { "${SemanticAttributes.DB_SYSTEM.key}" "hsqldb" "${SemanticAttributes.DB_NAME.key}" "test" "${SemanticAttributes.DB_USER.key}" "sa" - "${SemanticAttributes.DB_STATEMENT.key}" "select customer0_.id as id1_0_0_, customer0_.firstName as firstNam2_0_0_, customer0_.lastName as lastName3_0_0_ from Customer customer0_ where customer0_.id=?" + "${SemanticAttributes.DB_STATEMENT.key}" ~/select ([^\.]+)\.id([^\,]*), ([^\.]+)\.firstName([^\,]*), ([^\.]+)\.lastName (.*)from Customer (.*)where ([^\.]+)\.id( ?)=( ?)\?/ "${SemanticAttributes.DB_CONNECTION_STRING.key}" "hsqldb:mem:" } }