Skip to content

Commit b0c9225

Browse files
committed
HHH-14892 Use tmpfs for MySQL and enable parallel testing for it
1 parent 9c33f81 commit b0c9225

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

docker_db.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ mysql_setup() {
7979
-e MYSQL_PASSWORD=hibernate_orm_test \
8080
-e MYSQL_ROOT_PASSWORD=hibernate_orm_test \
8181
-e MYSQL_DATABASE=hibernate_orm_test \
82+
--tmpfs /var/lib/mysql \
8283
-p3306:3306 -d "${image_value}" \
8384
--character-set-server=utf8mb4 \
8485
--collation-server=utf8mb4_0900_as_cs \
@@ -101,9 +102,42 @@ mysql_setup() {
101102

102103
if [ "$n" -gt 5 ]; then
103104
echo "MySQL failed to start and configure after 30 seconds"
105+
exit 1
104106
else
105107
echo "MySQL successfully started"
106108
fi
109+
110+
# Wait for MySQL to become ready
111+
OUTPUT=
112+
n=0
113+
until [ "$n" -gt 5 ]; do
114+
OUTPUT="$( { $CONTAINER_CLI exec mysql bash -c "mysqladmin ping -u root -phibernate_orm_test"; } 2>/dev/null )"
115+
if [[ $OUTPUT == *"alive"* ]]; then
116+
break;
117+
fi
118+
n=$((n+1))
119+
echo "Waiting for MySQL to be ready..."
120+
sleep 2
121+
done
122+
123+
if [ "$n" -gt 5 ]; then
124+
echo "MySQL failed to become ready after 10 seconds"
125+
exit 1
126+
else
127+
echo "MySQL is ready"
128+
fi
129+
130+
databases=()
131+
for n in $(seq 1 $(($(nproc)/2)))
132+
do
133+
databases+=("hibernate_orm_test_${n}")
134+
done
135+
create_cmd=
136+
for i in "${!databases[@]}";do
137+
create_cmd+="create database ${databases[i]}; grant all privileges on ${databases[i]}.* to 'hibernate_orm_test'@'%';"
138+
done
139+
$CONTAINER_CLI exec mysql bash -c "mysql -u root -phibernate_orm_test -e \"${create_cmd}\"" 2>/dev/null
140+
echo "MySQL databases were successfully setup"
107141
}
108142

109143
mariadb() {

hibernate-core/hibernate-core.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ tasks.withType( Test.class ).each { test ->
261261

262262
// see GradleParallelTestingResolver for how the test worker id is resolved in JDBC configs
263263
if ( project.db == "h2" || project.db == "hsqldb" || project.db == "pgsql_ci" || project.db == "edb_ci"
264-
|| project.db == "oracle_ci" || project.db == "oracle_xe_ci" ) {
264+
|| project.db == "oracle_ci" || project.db == "oracle_xe_ci" || project.db == "mysql_ci" ) {
265265
// Most systems have multi-threading and maxing out a core on both threads will hurt performance
266266
// Also, as soon as we hit 16+ threads, the returns are diminishing, so divide by 4
267267
def threadCount = Runtime.runtime.availableProcessors()

hibernate-envers/hibernate-envers.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ configurations {
5757
tasks.withType( Test.class ).each { test ->
5858
// see GradleParallelTestingResolver for how the test worker id is resolved in JDBC configs
5959
if ( project.db == "h2" || project.db == "hsqldb" || project.db == "pgsql_ci" || project.db == "edb_ci"
60-
|| project.db == "oracle_ci" || project.db == "oracle_xe_ci" ) {
60+
|| project.db == "oracle_ci" || project.db == "oracle_xe_ci" || project.db == "mysql_ci" ) {
6161
// Most systems have multi-threading and maxing out a core on both threads will hurt performance
6262
// Also, as soon as we hit 16+ threads, the returns are diminishing, so divide by 4
6363
def threadCount = Runtime.runtime.availableProcessors()

local-build-plugins/src/main/groovy/local.databases.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ ext {
145145
'jdbc.driver': 'com.mysql.cj.jdbc.Driver',
146146
'jdbc.user' : 'hibernate_orm_test',
147147
'jdbc.pass' : 'hibernate_orm_test',
148-
'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test?allowPublicKeyRetrieval=true',
148+
'jdbc.url' : 'jdbc:mysql://' + dbHost + '/hibernate_orm_test_$worker?allowPublicKeyRetrieval=true',
149149
'jdbc.datasource' : 'com.mysql.jdbc.Driver',
150150
// 'jdbc.datasource' : 'com.mysql.cj.jdbc.MysqlDataSource',
151151
'connection.init_sql' : ''

0 commit comments

Comments
 (0)