Skip to content

Commit 82e66d0

Browse files
committed
Make use of connection pooling in most tests
1 parent f43eb74 commit 82e66d0

File tree

351 files changed

+2071
-1550
lines changed

Some content is hidden

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

351 files changed

+2071
-1550
lines changed

ci/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ elif [ "$RDBMS" == "edb" ] || [ "$RDBMS" == "edb_10" ]; then
2020
goal="-Pdb=edb_ci -DdbHost=localhost:5444"
2121
elif [ "$RDBMS" == "oracle" ]; then
2222
# I have no idea why, but these tests don't seem to work on CI...
23-
goal="-Pdb=oracle_ci -PexcludeTests=**.LockTest.testQueryTimeout*"
23+
goal="-Pdb=oracle_ci"
2424
elif [ "$RDBMS" == "oracle_11_2" ]; then
2525
# I have no idea why, but these tests don't seem to work on CI...
2626
goal="-Pdb=oracle_legacy_ci -PexcludeTests=**.LockTest.testQueryTimeout*"

docker_db.sh

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -494,18 +494,23 @@ oracle_setup() {
494494
sleep 5;
495495
# On WSL, health-checks intervals don't work for Podman, so run them manually
496496
if command -v podman > /dev/null; then
497-
$CONTAINER_CLI healthcheck run oracle > /dev/null
497+
$PRIVILEGED_CLI $CONTAINER_CLI healthcheck run oracle > /dev/null
498498
fi
499-
HEALTHSTATUS="`$CONTAINER_CLI inspect -f $HEALTCHECK_PATH oracle`"
499+
HEALTHSTATUS="`$PRIVILEGED_CLI $CONTAINER_CLI inspect -f $HEALTCHECK_PATH oracle`"
500500
HEALTHSTATUS=${HEALTHSTATUS##+( )} #Remove longest matching series of spaces from the front
501501
HEALTHSTATUS=${HEALTHSTATUS%%+( )} #Remove longest matching series of spaces from the back
502502
done
503503
sleep 2;
504504
echo "Oracle successfully started"
505505
# We increase file sizes to avoid online resizes as that requires lots of CPU which is restricted in XE
506-
$CONTAINER_CLI exec oracle bash -c "source /home/oracle/.bashrc; bash -c \"
506+
$PRIVILEGED_CLI $CONTAINER_CLI exec oracle bash -c "source /home/oracle/.bashrc; bash -c \"
507507
cat <<EOF | \$ORACLE_HOME/bin/sqlplus / as sysdba
508508
set timing on
509+
-- Remove DISABLE_OOB parameter from Listener configuration and restart it
510+
!echo Enabling OOB for Listener...
511+
!echo NAMES.DIRECTORY_PATH=\(EZCONNECT,TNSNAMES\) > /opt/oracle/oradata/dbconfig/XE/sqlnet.ora
512+
!lsnrctl reload
513+
509514
-- Increasing redo logs
510515
alter database add logfile group 4 '\$ORACLE_BASE/oradata/XE/redo04.log' size 500M reuse;
511516
alter database add logfile group 5 '\$ORACLE_BASE/oradata/XE/redo05.log' size 500M reuse;
@@ -569,14 +574,14 @@ oracle_setup_old() {
569574
sleep 5;
570575
# On WSL, health-checks intervals don't work for Podman, so run them manually
571576
if command -v podman > /dev/null; then
572-
$CONTAINER_CLI healthcheck run oracle > /dev/null
577+
$PRIVILEGED_CLI $CONTAINER_CLI healthcheck run oracle > /dev/null
573578
fi
574-
HEALTHSTATUS="`$CONTAINER_CLI inspect -f $HEALTCHECK_PATH oracle`"
579+
HEALTHSTATUS="`$PRIVILEGED_CLI $CONTAINER_CLI inspect -f $HEALTCHECK_PATH oracle`"
575580
HEALTHSTATUS=${HEALTHSTATUS##+( )} #Remove longest matching series of spaces from the front
576581
HEALTHSTATUS=${HEALTHSTATUS%%+( )} #Remove longest matching series of spaces from the back
577582
done
578583
# We increase file sizes to avoid online resizes as that requires lots of CPU which is restricted in XE
579-
$CONTAINER_CLI exec oracle bash -c "source /home/oracle/.bashrc; bash -c \"
584+
$PRIVILEGED_CLI $CONTAINER_CLI exec oracle bash -c "source /home/oracle/.bashrc; bash -c \"
580585
cat <<EOF | \$ORACLE_HOME/bin/sqlplus / as sysdba
581586
alter database tempfile '\$ORACLE_BASE/oradata/XE/temp.dbf' resize 400M;
582587
alter database datafile '\$ORACLE_BASE/oradata/XE/system.dbf' resize 1000M;
@@ -626,15 +631,30 @@ EOF\""
626631
echo "Oracle successfully started"
627632
}
628633

634+
disable_userland_proxy() {
635+
if [[ "$HEALTCHECK_PATH" == "{{.State.Health.Status}}" ]]; then
636+
if [[ ! -f /etc/docker/daemon.json ]]; then
637+
sudo service docker stop
638+
echo '{"userland-proxy": false}' > /etc/docker/daemon.json
639+
sudo service docker start
640+
elif ! grep -q userland-proxy /etc/docker/daemon.json; then
641+
docker_daemon_json=$(</etc/docker/daemon.json)
642+
sudo service docker stop
643+
echo "${docker_daemon_json/\}/,}\"userland-proxy\": false}" > /etc/docker/daemon.json
644+
sudo service docker start
645+
fi
646+
fi
647+
}
648+
629649
oracle() {
630650
oracle_21
631651
}
632652

633653
oracle_11() {
634-
$CONTAINER_CLI rm -f oracle || true
654+
$PRIVILEGED_CLI $CONTAINER_CLI rm -f oracle || true
635655
# We need to use the defaults
636656
# SYSTEM/Oracle18
637-
$CONTAINER_CLI run --name oracle -d -p 1521:1521 -e ORACLE_PASSWORD=Oracle18 \
657+
$PRIVILEGED_CLI $CONTAINER_CLI run --name oracle -d -p 1521:1521 -e ORACLE_PASSWORD=Oracle18 \
638658
--health-cmd healthcheck.sh \
639659
--health-interval 5s \
640660
--health-timeout 5s \
@@ -643,24 +663,13 @@ oracle_11() {
643663
oracle_setup_old
644664
}
645665

646-
oracle_18() {
647-
$CONTAINER_CLI rm -f oracle || true
648-
# We need to use the defaults
649-
# SYSTEM/Oracle18
650-
$CONTAINER_CLI run --name oracle -d -p 1521:1521 -e ORACLE_PASSWORD=Oracle18 \
651-
--health-cmd healthcheck.sh \
652-
--health-interval 5s \
653-
--health-timeout 5s \
654-
--health-retries 10 \
655-
docker.io/gvenzl/oracle-xe:18.4.0-full
656-
oracle_setup
657-
}
658-
659666
oracle_21() {
660-
$CONTAINER_CLI rm -f oracle || true
667+
$PRIVILEGED_CLI $CONTAINER_CLI rm -f oracle || true
668+
disable_userland_proxy
661669
# We need to use the defaults
662670
# SYSTEM/Oracle18
663-
$CONTAINER_CLI run --name oracle -d -p 1521:1521 -e ORACLE_PASSWORD=Oracle18 \
671+
$PRIVILEGED_CLI $CONTAINER_CLI run --name oracle -d -p 1521:1521 -e ORACLE_PASSWORD=Oracle18 \
672+
--cap-add cap_net_raw \
664673
--health-cmd healthcheck.sh \
665674
--health-interval 5s \
666675
--health-timeout 5s \
@@ -924,7 +933,6 @@ if [ -z ${1} ]; then
924933
echo -e "\tmysql_5_7"
925934
echo -e "\toracle"
926935
echo -e "\toracle_21"
927-
echo -e "\toracle_18"
928936
echo -e "\toracle_11"
929937
echo -e "\tpostgresql"
930938
echo -e "\tpostgresql_15"

gradle/databases.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ ext {
3535
'jdbc.driver': 'org.apache.derby.iapi.jdbc.AutoloadedDriver',
3636
'jdbc.user' : 'hibernate_orm_test',
3737
'jdbc.pass' : 'hibernate_orm_test',
38-
'jdbc.url' : 'jdbc:derby:target/tmp/derby/hibernate_orm_test;databaseName=hibernate_orm_test;create=true',
39-
'connection.init_sql' : 'CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(\'derby.locks.waitTimeout\', \'10\')'
38+
'jdbc.url' : 'jdbc:derby:memory:;databaseName=hibernate_orm_test;create=true',
39+
'connection.init_sql' : ''
4040
],
4141
derby_old : [
4242
'db.dialect' : 'org.hibernate.dialect.DerbyDialect',
4343
'jdbc.driver': 'org.apache.derby.jdbc.EmbeddedDriver',
4444
'jdbc.user' : 'hibernate_orm_test',
4545
'jdbc.pass' : 'hibernate_orm_test',
46-
'jdbc.url' : 'jdbc:derby:target/tmp/derby/hibernate_orm_test;databaseName=hibernate_orm_test;create=true',
47-
'connection.init_sql' : 'CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(\'derby.locks.waitTimeout\', \'10\')'
46+
'jdbc.url' : 'jdbc:derby:memory:;databaseName=hibernate_orm_test;create=true',
47+
'connection.init_sql' : ''
4848
],
4949
pgsql : [
5050
'db.dialect' : 'org.hibernate.dialect.PostgreSQLDialect',
@@ -136,15 +136,15 @@ ext {
136136
'jdbc.driver': 'oracle.jdbc.OracleDriver',
137137
'jdbc.user' : 'hibernate_orm_test',
138138
'jdbc.pass' : 'hibernate_orm_test',
139-
'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521/xepdb1?oracle.jdbc.ReadTimeout=10000',
139+
'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521/xepdb1',
140140
'connection.init_sql' : ''
141141
],
142142
oracle_ci : [
143143
'db.dialect' : 'org.hibernate.dialect.OracleDialect',
144144
'jdbc.driver': 'oracle.jdbc.OracleDriver',
145145
'jdbc.user' : 'hibernate_orm_test',
146146
'jdbc.pass' : 'hibernate_orm_test',
147-
'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521/xepdb1?oracle.jdbc.ReadTimeout=10000',
147+
'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521/xepdb1',
148148
'connection.init_sql' : ''
149149
],
150150
oracle_legacy_ci : [
@@ -153,7 +153,7 @@ ext {
153153
'jdbc.user' : 'hibernate_orm_test',
154154
'jdbc.pass' : 'hibernate_orm_test',
155155
// For 11 version that doesn't have any XEPDB1 database service
156-
'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521:XE?oracle.jdbc.ReadTimeout=10000',
156+
'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521:XE',
157157
'connection.init_sql' : ''
158158
],
159159
oracle_cloud_autonomous_tls : [

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/MySQLLegacyDialect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ private String withTimeout(String lockString, int timeout) {
12511251
case LockOptions.WAIT_FOREVER:
12521252
return lockString;
12531253
default:
1254-
return supportsWait() ? lockString + " wait " + timeout : lockString;
1254+
return supportsWait() ? lockString + " wait " + getTimeoutInSeconds( timeout ) : lockString;
12551255
}
12561256
}
12571257

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/OracleLegacyDialect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ private String withTimeout(String lockString, int timeout) {
12481248
case LockOptions.WAIT_FOREVER:
12491249
return lockString;
12501250
default:
1251-
return supportsWait() ? lockString + " wait " + Math.round(timeout / 1e3f) : lockString;
1251+
return supportsWait() ? lockString + " wait " + getTimeoutInSeconds( timeout ) : lockString;
12521252
}
12531253
}
12541254

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/TimesTenDialect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ private String withTimeout(String lockString, int timeout) {
290290
case LockOptions.WAIT_FOREVER:
291291
return lockString;
292292
default:
293-
return supportsWait() ? lockString + " wait " + Math.round( timeout / 1e3f ) : lockString;
293+
return supportsWait() ? lockString + " wait " + getTimeoutInSeconds( timeout ) : lockString;
294294
}
295295
}
296296

hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/CommunityDialectFactoryTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.hibernate.service.spi.ServiceRegistryImplementor;
2020

2121
import org.hibernate.testing.junit4.BaseUnitTestCase;
22+
import org.hibernate.testing.util.ServiceRegistryUtil;
2223
import org.junit.Before;
2324
import org.junit.Test;
2425

@@ -36,7 +37,7 @@ public void setUp() {
3637
final BootstrapServiceRegistry bootReg = new BootstrapServiceRegistryBuilder().applyClassLoader(
3738
CommunityDialectFactoryTest.class.getClassLoader()
3839
).build();
39-
registry = new StandardServiceRegistryBuilder( bootReg ).build();
40+
registry = ServiceRegistryUtil.serviceRegistryBuilder( bootReg ).build();
4041

4142
dialectFactory = new DialectFactoryImpl();
4243
dialectFactory.injectServices( (ServiceRegistryImplementor) registry );

hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.sql.SQLFeatureNotSupportedException;
3030
import java.sql.Statement;
3131
import java.sql.Types;
32-
import java.time.Duration;
3332
import java.time.temporal.TemporalAccessor;
3433
import java.util.Arrays;
3534
import java.util.Date;
@@ -878,11 +877,10 @@ public String getReadLockString(String aliases, int timeout) {
878877

879878
@Override
880879
public String getWriteLockString(int timeout) {
881-
long timeoutInSeconds = getLockWaitTimeoutInSeconds( timeout );
882-
if ( timeoutInSeconds > 0 ) {
883-
return getForUpdateString() + " wait " + timeoutInSeconds;
880+
if ( timeout > 0 ) {
881+
return getForUpdateString() + " wait " + getTimeoutInSeconds( timeout );
884882
}
885-
else if ( timeoutInSeconds == 0 ) {
883+
else if ( timeout == 0 ) {
886884
return getForUpdateNowaitString();
887885
}
888886
else {
@@ -893,7 +891,7 @@ else if ( timeoutInSeconds == 0 ) {
893891
@Override
894892
public String getWriteLockString(String aliases, int timeout) {
895893
if ( timeout > 0 ) {
896-
return getForUpdateString( aliases ) + " wait " + getLockWaitTimeoutInSeconds( timeout );
894+
return getForUpdateString( aliases ) + " wait " + getTimeoutInSeconds( timeout );
897895
}
898896
else if ( timeout == 0 ) {
899897
return getForUpdateNowaitString( aliases );
@@ -903,16 +901,6 @@ else if ( timeout == 0 ) {
903901
}
904902
}
905903

906-
private long getLockWaitTimeoutInSeconds(int timeoutInMilliseconds) {
907-
Duration duration = Duration.ofMillis( timeoutInMilliseconds );
908-
long timeoutInSeconds = duration.getSeconds();
909-
if ( duration.getNano() != 0 && LOG.isInfoEnabled() ) {
910-
LOG.info( "Changing the query timeout from " + timeoutInMilliseconds + " ms to " + timeoutInSeconds
911-
+ " s, because HANA requires the timeout in seconds" );
912-
}
913-
return timeoutInSeconds;
914-
}
915-
916904
@Override
917905
public String getQueryHintString(String query, List<String> hints) {
918906
return query + " with hint (" + String.join( ",", hints ) + ")";

hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,10 @@ public String applyLocksToSql(String sql, LockOptions aliasedLockOptions, Map<St
21802180
return sql + new ForUpdateFragment( this, aliasedLockOptions, keyColumnNames ).toFragmentString();
21812181
}
21822182

2183+
protected int getTimeoutInSeconds(int millis) {
2184+
return millis == 0 ? 0 : Math.max( 1, Math.round( millis / 1e3f ) );
2185+
}
2186+
21832187

21842188
// table support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21852189

hibernate-core/src/main/java/org/hibernate/dialect/MariaDB103Dialect.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*/
77
package org.hibernate.dialect;
88

9-
import java.time.Duration;
10-
119
import org.hibernate.LockOptions;
1210

1311
/**
@@ -31,15 +29,10 @@ public String getWriteLockString(int timeout) {
3129
}
3230

3331
if ( timeout > 0 ) {
34-
return getForUpdateString() + " wait " + getLockWaitTimeoutInSeconds( timeout );
32+
return getForUpdateString() + " wait " + getTimeoutInSeconds( timeout );
3533
}
3634

3735
return getForUpdateString();
3836
}
3937

40-
private static long getLockWaitTimeoutInSeconds(int timeoutInMilliseconds) {
41-
Duration duration = Duration.ofMillis( timeoutInMilliseconds );
42-
return duration.getSeconds();
43-
}
44-
4538
}

0 commit comments

Comments
 (0)