Skip to content

Commit d767d46

Browse files
committed
Fix most tests to work on all DBs and fix a bunch of connection leaks
1 parent 5d9f693 commit d767d46

File tree

80 files changed

+628
-185
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+628
-185
lines changed

.github/workflows/contributor-build.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ jobs:
7272
if: failure()
7373
with:
7474
name: test-reports-java8-${{ matrix.rdbms }}
75-
path: './**/target/reports/tests/test/'
75+
path: |
76+
./**/target/reports/tests/
77+
./**/target/reports/checkstyle/
7678
- name: Omit produced artifacts from build cache
7779
run: ./ci/before-cache.sh
7880
build11:
@@ -109,6 +111,8 @@ jobs:
109111
if: failure()
110112
with:
111113
name: test-reports-java11
112-
path: './**/target/reports/tests/test/'
114+
path: |
115+
./**/target/reports/tests/
116+
./**/target/reports/checkstyle/
113117
- name: Omit produced artifacts from build cache
114118
run: ./ci/before-cache.sh

ci/build-github.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
44

55
java -version
6-
./gradlew assemble
6+
77
if [ "$RDBMS" == 'mysql' ]; then
88
bash $DIR/../docker_db.sh mysql_5_7
99
elif [ "$RDBMS" == 'mysql8' ]; then

ci/build-travis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
44

55
java -version
6-
./gradlew assemble
6+
77
if [ "$RDBMS" == 'mysql' ]; then
88
sudo service mysql stop
99
bash $DIR/../docker_db.sh mysql_5_7

ci/build.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ goal=
44
if [ "$RDBMS" == "derby" ]; then
55
goal="-Pdb=derby"
66
elif [ "$RDBMS" == "mariadb" ]; then
7-
goal="-Pdb=mariadb"
7+
goal="-Pdb=mariadb_ci"
88
elif [ "$RDBMS" == "postgresql" ]; then
9-
goal="-Pdb=pgsql"
9+
goal="-Pdb=pgsql_ci"
1010
elif [ "$RDBMS" == "oracle" ]; then
11-
goal="-Pdb=oracle -Dhibernate.connection.url=jdbc:oracle:thin:@localhost:1521:XE -Dhibernate.connection.username=SYSTEM -Dhibernate.connection.password=Oracle18"
11+
goal="-Pdb=oracle_ci"
1212
elif [ "$RDBMS" == "db2" ]; then
13-
goal="-Pdb=db2 -Dhibernate.connection.url=jdbc:db2://localhost:50000/orm_test -Dhibernate.connection.username=orm_test -Dhibernate.connection.password=orm_test"
13+
goal="-Pdb=db2_ci"
1414
elif [ "$RDBMS" == "mssql" ]; then
15-
goal="-Pdb=mssql -Dhibernate.connection.url=jdbc:sqlserver://localhost:1433;databaseName= -Dhibernate.connection.username=sa -Dhibernate.connection.password=hibernate_orm_test"
15+
goal="-Pdb=mssql_ci"
1616
fi
1717

1818
exec ./gradlew check ${goal} -Plog-test-progress=true --stacktrace

docker_db.sh

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mysql_8_0() {
1212

1313
mariadb() {
1414
docker rm -f mariadb || true
15-
docker run --name mariadb -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -p3306:3306 -d mariadb:10.5.8 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
15+
docker run --name mariadb -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -p3306:3306 -d mariadb:10.5.8 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
1616
}
1717

1818
postgresql_9_5() {
@@ -22,10 +22,10 @@ postgresql_9_5() {
2222

2323
db2() {
2424
docker rm -f db2 || true
25-
docker run --name db2 --privileged -e DB2INSTANCE=orm_test -e DB2INST1_PASSWORD=orm_test -e DBNAME=orm_test -e LICENSE=accept -p 50000:50000 -d ibmcom/db2:11.5.0.0a
25+
docker run --name db2 --privileged -e DB2INSTANCE=orm_test -e DB2INST1_PASSWORD=orm_test -e DBNAME=orm_test -e LICENSE=accept -e AUTOCONFIG=false -e ARCHIVE_LOGS=false -e TO_CREATE_SAMPLEDB=false -e REPODB=false -p 50000:50000 -d ibmcom/db2:11.5.5.0
2626
# Give the container some time to start
2727
OUTPUT=
28-
while [[ $OUTPUT != *"Setup has completed"* ]]; do
28+
while [[ $OUTPUT != *"INSTANCE"* ]]; do
2929
echo "Waiting for DB2 to start..."
3030
sleep 10
3131
OUTPUT=$(docker logs db2)
@@ -35,14 +35,56 @@ db2() {
3535

3636
mssql() {
3737
docker rm -f mssql || true
38-
docker run --name mssql -d -p 1433:1433 -e "SA_PASSWORD=hibernate_orm_test" -e ACCEPT_EULA=Y microsoft/mssql-server-linux:2017-CU13
38+
docker run --name mssql -d -p 1433:1433 -e "SA_PASSWORD=Hibernate_orm_test" -e ACCEPT_EULA=Y microsoft/mssql-server-linux:2017-CU13
39+
sleep 5
40+
n=0
41+
until [ "$n" -ge 5 ]
42+
do
43+
# We need a database that uses a non-lock based MVCC approach
44+
# https://github.com/microsoft/homebrew-mssql-release/issues/2#issuecomment-682285561
45+
docker exec mssql bash -c 'echo "create database hibernate_orm_test collate SQL_Latin1_General_CP1_CI_AS; alter database hibernate_orm_test set READ_COMMITTED_SNAPSHOT ON" | /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Hibernate_orm_test -i /dev/stdin' && break
46+
echo "Waiting for SQL Server to start..."
47+
n=$((n+1))
48+
sleep 5
49+
done
50+
if [ "$n" -ge 5 ]; then
51+
echo "SQL Server failed to start and configure after 25 seconds"
52+
else
53+
echo "SQL Server successfully started"
54+
fi
3955
}
4056

4157
oracle() {
4258
docker rm -f oracle || true
4359
# We need to use the defaults
4460
# SYSTEM/Oracle18
4561
docker run --shm-size=1536m --name oracle -d -p 1521:1521 quillbuilduser/oracle-18-xe
62+
until [ "`docker inspect -f {{.State.Health.Status}} oracle`" == "healthy" ];
63+
do
64+
echo "Waiting for Oracle to start..."
65+
sleep 10;
66+
done
67+
echo "Oracle successfully started"
68+
# We increase file sizes to avoid online resizes as that requires lots of CPU which is restricted in XE
69+
docker exec oracle bash -c "source /home/oracle/.bashrc; bash -c \"
70+
cat <<EOF | \$ORACLE_HOME/bin/sqlplus sys/Oracle18@localhost/XE as sysdba
71+
alter database tempfile '/opt/oracle/oradata/XE/temp01.dbf' resize 400M;
72+
alter database datafile '/opt/oracle/oradata/XE/system01.dbf' resize 1000M;
73+
alter database datafile '/opt/oracle/oradata/XE/sysaux01.dbf' resize 600M;
74+
alter database datafile '/opt/oracle/oradata/XE/undotbs01.dbf' resize 300M;
75+
alter database add logfile group 4 '/opt/oracle/oradata/XE/redo04.log' size 500M reuse;
76+
alter database add logfile group 5 '/opt/oracle/oradata/XE/redo05.log' size 500M reuse;
77+
alter database add logfile group 6 '/opt/oracle/oradata/XE/redo06.log' size 500M reuse;
78+
79+
alter system switch logfile;
80+
alter system switch logfile;
81+
alter system switch logfile;
82+
alter system checkpoint;
83+
84+
alter database drop logfile group 1;
85+
alter database drop logfile group 2;
86+
alter database drop logfile group 3;
87+
EOF\""
4688
}
4789

4890
if [ -z ${1} ]; then

documentation/src/test/java/org/hibernate/userguide/events/ListenerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public void setName(String name) {
136136
}
137137

138138
//tag::events-jpa-callbacks-example[]
139-
@Entity
139+
@Entity(name = "Person")
140140
@EntityListeners( LastUpdateListener.class )
141141
public static class Person {
142142

documentation/src/test/java/org/hibernate/userguide/hql/HQLTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.hibernate.ScrollableResults;
2626
import org.hibernate.Session;
2727
import org.hibernate.dialect.CockroachDB192Dialect;
28+
import org.hibernate.dialect.DerbyDialect;
2829
import org.hibernate.dialect.H2Dialect;
2930
import org.hibernate.dialect.MySQL5Dialect;
3031
import org.hibernate.dialect.Oracle8iDialect;
@@ -1178,6 +1179,7 @@ public void test_hql_aggregate_functions_example_3() {
11781179
}
11791180

11801181
@Test
1182+
@SkipForDialect(value = DerbyDialect.class, comment = "See https://issues.apache.org/jira/browse/DERBY-2072")
11811183
public void test_hql_concat_function_example() {
11821184
doInJPA( this::entityManagerFactory, entityManager -> {
11831185
//tag::hql-concat-function-example[]
@@ -1312,6 +1314,7 @@ public void test_hql_sqrt_function_example() {
13121314

13131315
@Test
13141316
@SkipForDialect(SQLServerDialect.class)
1317+
@SkipForDialect(value = DerbyDialect.class, comment = "Comparisons between 'DATE' and 'TIMESTAMP' are not supported")
13151318
public void test_hql_current_date_function_example() {
13161319
doInJPA( this::entityManagerFactory, entityManager -> {
13171320
//tag::hql-current-date-function-example[]
@@ -1383,6 +1386,7 @@ public void test_hql_bit_length_function_example() {
13831386
}
13841387

13851388
@Test
1389+
@SkipForDialect(value = DerbyDialect.class, comment = "See https://issues.apache.org/jira/browse/DERBY-2072")
13861390
public void test_hql_cast_function_example() {
13871391
doInJPA( this::entityManagerFactory, entityManager -> {
13881392
//tag::hql-cast-function-example[]
@@ -1396,6 +1400,7 @@ public void test_hql_cast_function_example() {
13961400
}
13971401

13981402
@Test
1403+
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't support extract function")
13991404
public void test_hql_extract_function_example() {
14001405
doInJPA( this::entityManagerFactory, entityManager -> {
14011406
//tag::hql-extract-function-example[]
@@ -1550,6 +1555,7 @@ public void test_hql_collection_expressions_example_6() {
15501555
}
15511556

15521557
@Test
1558+
@SkipForDialect(value = DerbyDialect.class, comment = "Comparisons between 'DATE' and 'TIMESTAMP' are not supported")
15531559
public void test_hql_collection_expressions_example_7() {
15541560
doInJPA( this::entityManagerFactory, entityManager -> {
15551561
//tag::hql-collection-expressions-example[]
@@ -1565,6 +1571,7 @@ public void test_hql_collection_expressions_example_7() {
15651571
}
15661572

15671573
@Test
1574+
@SkipForDialect(value = DerbyDialect.class, comment = "Comparisons between 'DATE' and 'TIMESTAMP' are not supported")
15681575
public void test_hql_collection_expressions_example_8() {
15691576
doInJPA( this::entityManagerFactory, entityManager -> {
15701577
//tag::hql-collection-expressions-example[]

documentation/src/test/java/org/hibernate/userguide/mapping/basic/NClobCharArrayTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import javax.persistence.Lob;
1212

1313
import org.hibernate.annotations.Nationalized;
14+
import org.hibernate.dialect.DB2Dialect;
1415
import org.hibernate.dialect.MySQL5Dialect;
1516
import org.hibernate.dialect.PostgreSQL81Dialect;
1617
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
@@ -27,9 +28,10 @@
2728
@SkipForDialect(
2829
value = {
2930
PostgreSQL81Dialect.class,
30-
MySQL5Dialect.class
31+
MySQL5Dialect.class,
32+
DB2Dialect.class
3133
},
32-
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695"
34+
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695 and https://hibernate.atlassian.net/browse/HHH-10473"
3335
)
3436
public class NClobCharArrayTest extends BaseEntityManagerFunctionalTestCase {
3537

documentation/src/test/java/org/hibernate/userguide/mapping/basic/NClobStringTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import javax.persistence.Lob;
1212

1313
import org.hibernate.annotations.Nationalized;
14+
import org.hibernate.dialect.DB2Dialect;
1415
import org.hibernate.dialect.MySQL5Dialect;
1516
import org.hibernate.dialect.PostgreSQL81Dialect;
1617
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
@@ -27,9 +28,10 @@
2728
@SkipForDialect(
2829
value = {
2930
PostgreSQL81Dialect.class,
30-
MySQL5Dialect.class
31+
MySQL5Dialect.class,
32+
DB2Dialect.class
3133
},
32-
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695"
34+
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695 and https://hibernate.atlassian.net/browse/HHH-10473"
3335
)
3436
public class NClobStringTest extends BaseEntityManagerFunctionalTestCase {
3537

documentation/src/test/java/org/hibernate/userguide/mapping/basic/NClobTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.hibernate.annotations.Nationalized;
2020
import org.hibernate.dialect.AbstractHANADialect;
2121
import org.hibernate.dialect.CockroachDB192Dialect;
22+
import org.hibernate.dialect.DB2Dialect;
2223
import org.hibernate.dialect.MySQL5Dialect;
2324
import org.hibernate.dialect.PostgreSQL81Dialect;
2425
import org.hibernate.engine.jdbc.NClobProxy;
@@ -39,9 +40,10 @@
3940
PostgreSQL81Dialect.class,
4041
MySQL5Dialect.class,
4142
AbstractHANADialect.class,
42-
CockroachDB192Dialect.class
43+
CockroachDB192Dialect.class,
44+
DB2Dialect.class
4345
},
44-
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695"
46+
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695 and https://hibernate.atlassian.net/browse/HHH-10473"
4547
)
4648
public class NClobTest extends BaseEntityManagerFunctionalTestCase {
4749

0 commit comments

Comments
 (0)