Skip to content

Commit 42d5b87

Browse files
authored
upgrade hibernate tests to 6.2.38 (#1467)
1 parent b573d81 commit 42d5b87

File tree

7 files changed

+190
-893
lines changed

7 files changed

+190
-893
lines changed

.github/workflows/run-hibernate-orm-tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,10 @@ jobs:
6161
name: html-summary-report
6262
path: ./wrapper/build/report
6363
retention-days: 5
64+
- name: 'Archive container reports'
65+
if: ${{steps.changed-files.outputs.ONLY_DOCS && steps.changed-files.outputs.ONLY_DOCS == 'false' && !cancelled()}}
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: container-reports
69+
path: ./wrapper/build/test-results/*.tar.gz
70+
retention-days: 5

wrapper/src/test/java/integration/host/TestEnvironment.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public class TestEnvironment implements AutoCloseable {
7474
private static final String PROXIED_DOMAIN_NAME_SUFFIX = ".proxied";
7575
protected static final int PROXY_CONTROL_PORT = 8474;
7676
protected static final int PROXY_PORT = 8666;
77-
private static final String HIBERNATE_VERSION = "6.2.0.CR2";
77+
private static final String HIBERNATE_VERSION = "6.2.38";
7878

7979
private static final TestEnvironmentConfiguration config = new TestEnvironmentConfiguration();
8080
private static final boolean USE_OTLP_CONTAINER_FOR_TRACES = true;
@@ -1085,18 +1085,21 @@ private static void createTestContainer(TestEnvironment env) {
10851085
"aws/rds-test-container",
10861086
getContainerBaseImageName(env.info.getRequest()),
10871087
builder -> builder
1088+
.run("apk", "add", "--no-cache", "--upgrade", "bash")
10881089
.run("apk", "add", "git")
10891090
.run("git", "clone", "--depth", "1", "--branch", HIBERNATE_VERSION,
1090-
"https://github.com/hibernate/hibernate-orm.git", "/app/hibernate-orm"))
1091+
"https://github.com/hibernate/hibernate-orm.git", "/app/hibernate-orm")
1092+
.run("rm -f /app/libs/*-bundle-*.jar")
1093+
.run("rm -f /app/hibernate-orm/drivers/*-bundle-*.jar"))
1094+
.withCopyFileToContainer(MountableFile.forHostPath("./build/libs"),
1095+
"app/hibernate-orm/drivers")
10911096
.withCopyFileToContainer(MountableFile.forHostPath(
10921097
"src/test/resources/hibernate_files/databases.gradle"),
10931098
"app/hibernate-orm/gradle/databases.gradle")
10941099
.withCopyFileToContainer(MountableFile.forHostPath(
1095-
"src/test/resources/hibernate_files/hibernate-core.gradle"),
1096-
"hibernate-core/hibernate-core.gradle")
1097-
.withCopyFileToContainer(MountableFile.forHostPath(
1098-
"src/test/resources/hibernate_files/java-module.gradle"),
1099-
"app/hibernate-orm/gradle/java-module.gradle")
1100+
"src/test/resources/hibernate_files/PostgresIntervalSecondTest.java"),
1101+
"app/hibernate-orm/hibernate-core/src/test/java/org/hibernate/orm/test/type/"
1102+
+ "PostgresIntervalSecondTest.java")
11001103
.withCopyFileToContainer(MountableFile.forHostPath(
11011104
"src/test/resources/hibernate_files/collect_test_results.sh"),
11021105
"app/collect_test_results.sh");
@@ -1320,7 +1323,9 @@ private String[] buildHibernateCommands(boolean debugMode) {
13201323
"-DdbUser=" + dbInfo.getUsername(),
13211324
"-DdbPass=" + dbInfo.getPassword(),
13221325
"-DdbName=" + dbInfo.getDefaultDbName(),
1323-
"--no-parallel", "--no-daemon"
1326+
"--no-parallel",
1327+
"--no-daemon",
1328+
"--no-build-cache"
13241329
));
13251330

13261331
if (debugMode) {
@@ -1329,13 +1334,11 @@ private String[] buildHibernateCommands(boolean debugMode) {
13291334

13301335
switch (this.info.getRequest().getDatabaseEngine()) {
13311336
case PG:
1332-
command.add("-Pdb=amazon_ci");
1333-
command.add("-PexcludeTests=PostgreSQLSkipAutoCommitTest");
1337+
command.add("-Pdb=pg_amazon_ci");
13341338
break;
13351339
case MYSQL:
13361340
default:
1337-
command.add("-Pdb=amazon_mysql_ci");
1338-
command.add("-PexcludeTests=MySQLSkipAutoCommitTest");
1341+
command.add("-Pdb=mysql_amazon_ci");
13391342
break;
13401343
}
13411344
return command.toArray(new String[] {});
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package org.hibernate.orm.test.type;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import java.time.Duration;
6+
7+
import org.hibernate.annotations.JdbcTypeCode;
8+
import org.hibernate.cfg.AvailableSettings;
9+
import org.hibernate.dialect.PostgreSQLDialect;
10+
import org.hibernate.dialect.PostgreSQLIntervalSecondJdbcType;
11+
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
12+
import org.hibernate.persister.entity.EntityPersister;
13+
import org.hibernate.type.SqlTypes;
14+
import org.hibernate.type.descriptor.jdbc.JdbcType;
15+
import org.hibernate.type.descriptor.jdbc.NumericJdbcType;
16+
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
17+
18+
import org.hibernate.testing.orm.junit.DomainModel;
19+
import org.hibernate.testing.orm.junit.RequiresDialect;
20+
import org.hibernate.testing.orm.junit.ServiceRegistry;
21+
import org.hibernate.testing.orm.junit.SessionFactory;
22+
import org.hibernate.testing.orm.junit.SessionFactoryScope;
23+
import org.hibernate.testing.orm.junit.Setting;
24+
import org.junit.jupiter.api.Disabled;
25+
import org.junit.jupiter.api.Test;
26+
27+
import jakarta.persistence.Column;
28+
import jakarta.persistence.Entity;
29+
import jakarta.persistence.Id;
30+
import jakarta.persistence.Table;
31+
32+
/**
33+
* Test to see if using `@org.hibernate.annotations.JdbcTypeCode` or `@org.hibernate.annotations.JdbcType`
34+
* will override a default JdbcType set by a {@link AvailableSettings#PREFERRED_DURATION_JDBC_TYPE config property}.
35+
*/
36+
@SessionFactory
37+
@DomainModel(annotatedClasses = { PostgresIntervalSecondTest.EntityWithIntervalSecondDuration.class })
38+
@ServiceRegistry(settings = @Setting(name = AvailableSettings.PREFERRED_DURATION_JDBC_TYPE, value = "NUMERIC"))
39+
@RequiresDialect(PostgreSQLDialect.class)
40+
@Disabled
41+
public class PostgresIntervalSecondTest {
42+
43+
@Test
44+
public void verifyMappings(SessionFactoryScope scope) {
45+
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
46+
.getRuntimeMetamodels()
47+
.getMappingMetamodel();
48+
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(
49+
PostgresIntervalSecondTest.EntityWithIntervalSecondDuration.class );
50+
final JdbcTypeRegistry jdbcTypeRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
51+
52+
final JdbcType durationJdbcType = mappingMetamodel.getTypeConfiguration()
53+
.getBasicTypeForJavaType( Duration.class )
54+
.getJdbcType();
55+
56+
// default interval type set by a config property and should be `NUMERIC`
57+
assertThat( durationJdbcType ).isEqualTo( NumericJdbcType.INSTANCE );
58+
59+
final JdbcType intervalType = jdbcTypeRegistry.getDescriptor( SqlTypes.INTERVAL_SECOND );
60+
assertThat( intervalType ).isOfAnyClassIn( PostgreSQLIntervalSecondJdbcType.class );
61+
62+
// a simple duration field with no overrides - so should be using a default JdbcType
63+
assertThat( entityDescriptor.findAttributeMapping( "duration" )
64+
.getSingleJdbcMapping().getJdbcType() )
65+
.isEqualTo( durationJdbcType );
66+
67+
// a field that is using a @JdbcType annotation to override the JdbcType. Hence, the used JdbcType must match the one
68+
// set by the annotation.
69+
assertThat( entityDescriptor.findAttributeMapping( "durationJdbcType" )
70+
.getSingleJdbcMapping().getJdbcType() )
71+
.isNotEqualTo( durationJdbcType )
72+
.isOfAnyClassIn( PostgreSQLIntervalSecondJdbcType.class );
73+
74+
// a field that is using a @JdbcTypeCode annotation to override the JdbcType. Hence, the used JdbcType must match the one
75+
// set by the annotation.
76+
assertThat( entityDescriptor.findAttributeMapping( "durationJdbcTypeCode" )
77+
.getSingleJdbcMapping().getJdbcType() )
78+
.isEqualTo( intervalType );
79+
}
80+
81+
@Entity(name = "EntityWithIntervalSecondDuration")
82+
@Table(name = "EntityWithIntervalSecondDuration")
83+
public static class EntityWithIntervalSecondDuration {
84+
@Id
85+
private Integer id;
86+
87+
private Duration duration;
88+
89+
@Column(precision = 10, scale = 6)
90+
@JdbcTypeCode(SqlTypes.INTERVAL_SECOND)
91+
private Duration durationJdbcTypeCode;
92+
93+
@Column(precision = 10, scale = 6)
94+
@org.hibernate.annotations.JdbcType(PostgreSQLIntervalSecondJdbcType.class)
95+
private Duration durationJdbcType;
96+
97+
public EntityWithIntervalSecondDuration() {
98+
}
99+
}
100+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/sh
22

3-
find /app/hibernate-orm/*/target/reports/tests -type d -name test -print0 | tar -czvf "/app/build/test-results/hibernate-orm_$(date '+%Y-%m-%d_%H-%M-%S').tar.gz" --files-from -
3+
find /app/hibernate-orm/*/target/reports/tests -type d -name test -print0 | tar -czvf "/app/build/test-results/hibernate-orm-reports_$(date '+%Y-%m-%d_%H-%M-%S').tar.gz" --files-from -
4+
find /app/hibernate-orm/*/target/test-results/test -type d -name test -print0 | tar -czvf "/app/build/test-results/hibernate-orm-test-results_$(date '+%Y-%m-%d_%H-%M-%S').tar.gz" --files-from -

wrapper/src/test/resources/hibernate_files/databases.gradle

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ ext {
1515
dbUser = System.getProperty( 'dbUser', 'hibernate_orm_test' )
1616
dbPass = System.getProperty( 'dbPass', 'hibernate_orm_test' )
1717
dbName = System.getProperty( 'dbName', 'hibernate_orm_test' )
18+
runID = System.getProperty( 'runID', '' )
1819
dbBundle = [
19-
amazon_ci : [
20+
pg_amazon_ci : [
2021
'db.dialect' : 'org.hibernate.dialect.PostgreSQLDialect',
2122
'jdbc.driver': 'software.amazon.jdbc.Driver',
2223
'jdbc.user' : dbUser,
2324
'jdbc.pass' : dbPass,
2425
'jdbc.url' : 'jdbc:aws-wrapper:postgresql://' + dbHost + '/' + dbName + '?preparedStatementCacheQueries=0&escapeSyntaxCallMode=callIfNoReturn&wrapperPlugins=',
2526
'connection.init_sql' : ''
2627
],
27-
amazon_mysql_ci : [
28+
mysql_amazon_ci : [
2829
'db.dialect' : 'org.hibernate.dialect.MySQLDialect',
2930
'jdbc.driver': 'software.amazon.jdbc.Driver',
3031
'jdbc.user' : dbUser,
@@ -37,8 +38,9 @@ ext {
3738
'jdbc.driver': 'org.h2.Driver',
3839
'jdbc.user' : 'sa',
3940
'jdbc.pass' : '',
40-
'jdbc.url' : 'jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000',
41-
'connection.init_sql' : ''
41+
'jdbc.url' : 'jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE',
42+
'connection.init_sql' : '',
43+
'hibernate.dialect.native_param_markers' : 'true'
4244
],
4345
hsqldb : [
4446
'db.dialect' : 'org.hibernate.dialect.HSQLDialect',
@@ -53,15 +55,15 @@ ext {
5355
'jdbc.driver': 'org.apache.derby.iapi.jdbc.AutoloadedDriver',
5456
'jdbc.user' : 'hibernate_orm_test',
5557
'jdbc.pass' : 'hibernate_orm_test',
56-
'jdbc.url' : 'jdbc:derby:target/tmp/derby/hibernate_orm_test;databaseName=hibernate_orm_test;create=true',
58+
'jdbc.url' : 'jdbc:derby:memory:;databaseName=hibernate_orm_test;create=true',
5759
'connection.init_sql' : ''
5860
],
5961
derby_old : [
6062
'db.dialect' : 'org.hibernate.dialect.DerbyDialect',
6163
'jdbc.driver': 'org.apache.derby.jdbc.EmbeddedDriver',
6264
'jdbc.user' : 'hibernate_orm_test',
6365
'jdbc.pass' : 'hibernate_orm_test',
64-
'jdbc.url' : 'jdbc:derby:target/tmp/derby/hibernate_orm_test;databaseName=hibernate_orm_test;create=true',
66+
'jdbc.url' : 'jdbc:derby:memory:;databaseName=hibernate_orm_test;create=true',
6567
'connection.init_sql' : ''
6668
],
6769
pgsql : [
@@ -97,9 +99,18 @@ ext {
9799
'jdbc.user' : 'hibernate_orm_test',
98100
'jdbc.pass' : 'hibernate_orm_test',
99101
// Disable prepared statement caching to avoid issues with changing schemas
100-
'jdbc.url' : 'jdbc:jtds:sybase://' + dbHost + ':5000/hibernate_orm_test;maxStatements=0;cacheMetaData=false',
102+
'jdbc.url' : 'jdbc:jtds:sybase://' + dbHost + ':9000/hibernate_orm_test;maxStatements=0;cacheMetaData=false',
101103
'connection.init_sql' : 'set ansinull on'
102104
],
105+
sybase_jconn_ci : [
106+
'db.dialect' : 'org.hibernate.dialect.SybaseASEDialect',
107+
'jdbc.driver': 'com.sybase.jdbc4.jdbc.SybDriver',
108+
'jdbc.user' : 'hibernate_orm_test',
109+
'jdbc.pass' : 'hibernate_orm_test',
110+
// Disable prepared statement caching to avoid issues with changing schemas
111+
'jdbc.url' : 'jdbc:sybase:Tds:' + dbHost + ':9000/hibernate_orm_test',
112+
'connection.init_sql' : 'set ansinull on set quoted_identifier on'
113+
],
103114
mysql : [
104115
'db.dialect' : 'org.hibernate.dialect.MySQLDialect',
105116
'jdbc.driver': 'com.mysql.cj.jdbc.Driver',
@@ -137,7 +148,7 @@ ext {
137148
'jdbc.driver': 'com.mysql.jdbc.Driver',
138149
'jdbc.user' : 'hibernate_orm_test',
139150
'jdbc.pass' : 'hibernate_orm_test',
140-
'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test',
151+
'jdbc.url' : 'jdbc:mysql://' + dbHost + ':4000/hibernate_orm_test',
141152
'connection.init_sql' : ''
142153
],
143154
oracle : [
@@ -149,6 +160,14 @@ ext {
149160
'connection.init_sql' : ''
150161
],
151162
oracle_ci : [
163+
'db.dialect' : 'org.hibernate.dialect.OracleDialect',
164+
'jdbc.driver': 'oracle.jdbc.OracleDriver',
165+
'jdbc.user' : 'hibernate_orm_test',
166+
'jdbc.pass' : 'hibernate_orm_test',
167+
'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521/freepdb1',
168+
'connection.init_sql' : ''
169+
],
170+
oracle_xe_ci : [
152171
'db.dialect' : 'org.hibernate.dialect.OracleDialect',
153172
'jdbc.driver': 'oracle.jdbc.OracleDriver',
154173
'jdbc.user' : 'hibernate_orm_test',
@@ -168,13 +187,49 @@ ext {
168187
oracle_cloud_autonomous_tls : [
169188
'db.dialect' : 'org.hibernate.dialect.OracleDialect',
170189
'jdbc.driver': 'oracle.jdbc.OracleDriver',
171-
'jdbc.user' : 'hibernate_orm_test',
190+
'jdbc.user' : 'hibernate_orm_test_' + runID,
172191
'jdbc.pass' : 'Oracle_19_Password',
173192
// Requires dbHost (pointing to the right cloud region) AND dbService (unique database name).
174193
//
175194
// To avoid hibernate-spatial tests failure, JVM must be enabled as stated in documentation:
176195
// https://docs.oracle.com/en/cloud/paas/autonomous-database/adbsa/autonomous-oracle-java.html
177-
'jdbc.url' : 'jdbc:oracle:thin:@(description=(retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1521)(host=' + dbHost + '.oraclecloud.com))(connect_data=(service_name=' + dbService + '_low.adb.oraclecloud.com))(security=(ssl_server_dn_match=yes)))',
196+
'jdbc.url' : 'jdbc:oracle:thin:@(description=(retry_count=5)(retry_delay=1)(address=(protocol=tcps)(port=1521)(host=' + dbHost + '.oraclecloud.com))(connect_data=(service_name=' + dbService + '_tp.adb.oraclecloud.com))(security=(ssl_server_dn_match=no)))?oracle.jdbc.enableQueryResultCache=false&oracle.jdbc.thinForceDNSLoadBalancing=true&tcp.nodelay=yes',
197+
'connection.init_sql' : ''
198+
],
199+
oracle_cloud_db19c : [
200+
'db.dialect' : 'org.hibernate.dialect.OracleDialect',
201+
'jdbc.driver': 'oracle.jdbc.OracleDriver',
202+
'jdbc.user' : 'hibernate_orm_test_' + runID,
203+
'jdbc.pass' : 'Oracle_19_Password',
204+
// Requires dbHost (pointing to the right cloud region) AND dbService (unique database name).
205+
//
206+
// To avoid hibernate-spatial tests failure, JVM must be enabled as stated in documentation:
207+
// https://docs.oracle.com/en/cloud/paas/autonomous-database/adbsa/autonomous-oracle-java.html
208+
'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521/' + dbService,
209+
'connection.init_sql' : ''
210+
],
211+
oracle_cloud_db21c : [
212+
'db.dialect' : 'org.hibernate.dialect.OracleDialect',
213+
'jdbc.driver': 'oracle.jdbc.OracleDriver',
214+
'jdbc.user' : 'hibernate_orm_test_' + runID,
215+
'jdbc.pass' : 'Oracle_21_Password',
216+
// Requires dbHost (pointing to the right cloud region) AND dbService (unique database name).
217+
//
218+
// To avoid hibernate-spatial tests failure, JVM must be enabled as stated in documentation:
219+
// https://docs.oracle.com/en/cloud/paas/autonomous-database/adbsa/autonomous-oracle-java.html
220+
'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521/' + dbService,
221+
'connection.init_sql' : ''
222+
],
223+
oracle_cloud_db23c : [
224+
'db.dialect' : 'org.hibernate.dialect.OracleDialect',
225+
'jdbc.driver': 'oracle.jdbc.OracleDriver',
226+
'jdbc.user' : 'hibernate_orm_test_' + runID,
227+
'jdbc.pass' : 'Oracle_23_Password',
228+
// Requires dbHost (pointing to the right cloud region) AND dbService (unique database name).
229+
//
230+
// To avoid hibernate-spatial tests failure, JVM must be enabled as stated in documentation:
231+
// https://docs.oracle.com/en/cloud/paas/autonomous-database/adbsa/autonomous-oracle-java.html
232+
'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521/' + dbService,
178233
'connection.init_sql' : ''
179234
],
180235
mssql : [
@@ -266,7 +321,7 @@ if ( processTestResourcesTask != null ) {
266321
processTestResourcesTask.inputs.property( 'dbHost', dbHost )
267322
// processTestResourcesTask.inputs.property( "gradle.libs.versions.h2", project.getProperty( "gradle.libs.versions.h2", "2.1.214" ) )
268323
// processTestResourcesTask.inputs.property( "gradle.libs.versions.h2gis", project.getProperty( "gradle.libs.versions.h2gis", "2.1.0" ) )
269-
// processTestResourcesTask.inputs.property( "gradle.libs.versions.hsqldb", project.getProperty( "gradle.libs.versions.hsqldb", "2.7.1" ) )
324+
// processTestResourcesTask.inputs.property( "gradle.libs.versions.hsqldb", project.getProperty( "gradle.libs.versions.hsqldb", "2.7.2" ) )
270325
// processTestResourcesTask.inputs.property( "gradle.libs.versions.derby", project.getProperty( "gradle.libs.versions.derby", "10.15.2.0" ) )
271326
processTestResourcesTask.filter( ReplaceTokens, tokens: dbBundle[db] )
272327
}

0 commit comments

Comments
 (0)