Skip to content

Commit 940f15b

Browse files
committed
HHH-15528 Add Cockroach to Jenkins nightly test matrix and fix issues
1 parent f7acf4d commit 940f15b

File tree

66 files changed

+1246
-290
lines changed

Some content is hidden

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

66 files changed

+1246
-290
lines changed

.github/workflows/contributor-build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ jobs:
4747
- rdbms: db2
4848
- rdbms: mssql
4949
- rdbms: sybase
50+
# Running with CockroachDB requires at least 2-4 vCPUs, which we don't have on GH Actions runners
51+
# - rdbms: cockroachdb
5052
# Running with HANA requires at least 8GB memory just for the database, which we don't have on GH Actions runners
5153
# - rdbms: hana
5254
steps:

Jenkinsfile

+16-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ stage('Configure') {
5454
new BuildEnvironment( testJdkVersion: '20', testJdkLauncherArgs: '--enable-preview' )
5555
];
5656

57+
if ( env.CHANGE_ID ) {
58+
if ( pullRequest.labels.contains( 'cockroachdb' ) ) {
59+
this.environments.add( new BuildEnvironment( dbName: 'cockroachdb', node: 'LongDuration', longRunning: true ) )
60+
}
61+
}
62+
5763
helper.configure {
5864
file 'job-configuration.yaml'
5965
// We don't require the following, but the build helper plugin apparently does
@@ -117,6 +123,13 @@ stage('Build') {
117123
try {
118124
stage('Start database') {
119125
switch (buildEnv.dbName) {
126+
case "cockroachdb":
127+
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
128+
docker.image('cockroachdb/cockroach:v21.1.21').pull()
129+
}
130+
sh "./docker_db.sh cockroachdb"
131+
state[buildEnv.tag]['containerName'] = "cockroach"
132+
break;
120133
case "mysql":
121134
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
122135
docker.image('mysql:5.7').pull()
@@ -197,13 +210,13 @@ stage('Build') {
197210
withEnv(["RDBMS=${buildEnv.dbName}"]) {
198211
try {
199212
if (buildEnv.dbLockableResource == null) {
200-
timeout( [time: 120, unit: 'MINUTES'] ) {
213+
timeout( [time: buildEnv.longRunning ? 240 : 120, unit: 'MINUTES'] ) {
201214
sh cmd
202215
}
203216
}
204217
else {
205218
lock(buildEnv.dbLockableResource) {
206-
timeout( [time: 120, unit: 'MINUTES'] ) {
219+
timeout( [time: buildEnv.longRunning ? 240 : 120, unit: 'MINUTES'] ) {
207220
sh cmd
208221
}
209222
}
@@ -243,6 +256,7 @@ class BuildEnvironment {
243256
String dbLockableResource
244257
String additionalOptions
245258
String notificationRecipients
259+
boolean longRunning
246260

247261
String toString() { getTag() }
248262
String getTag() { "${node ? node + "_" : ''}${testJdkVersion ? 'jdk_' + testJdkVersion + '_' : '' }${dbName}" }

ci/build.sh

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ elif [ "$RDBMS" == "sybase" ]; then
3838
goal="-Pdb=sybase_ci"
3939
elif [ "$RDBMS" == "tidb" ]; then
4040
goal="-Pdb=tidb"
41+
elif [ "$RDBMS" == "cockroachdb" ]; then
42+
goal="-Pdb=cockroachdb"
4143
fi
4244

4345
# Only run checkstyle in the H2 build,

ci/database-start.sh

+2
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ elif [ "$RDBMS" == 'hana' ]; then
2222
bash $DIR/../docker_db.sh hana
2323
elif [ "$RDBMS" == 'sybase' ]; then
2424
bash $DIR/../docker_db.sh sybase
25+
elif [ "$RDBMS" == 'cockroachdb' ]; then
26+
bash $DIR/../docker_db.sh cockroachdb
2527
fi

docker_db.sh

+18-6
Original file line numberDiff line numberDiff line change
@@ -495,18 +495,26 @@ hana() {
495495

496496
cockroachdb() {
497497
$CONTAINER_CLI rm -f cockroach || true
498-
$CONTAINER_CLI run -d --name=cockroach -p 26257:26257 -p 8080:8080 docker.io/cockroachdb/cockroach:v21.2.10 start-single-node \
499-
--insecure --store=type=mem,size=0.25 --advertise-addr=localhost
498+
LOG_CONFIG="
499+
sinks:
500+
stderr:
501+
channels: all
502+
filter: ERROR
503+
redact: false
504+
exit-on-error: true
505+
"
506+
$CONTAINER_CLI run -d --name=cockroach -m 3g -p 26257:26257 -p 8080:8080 docker.io/cockroachdb/cockroach:v21.2.16 start-single-node \
507+
--insecure --store=type=mem,size=640MiB --advertise-addr=localhost --log="$LOG_CONFIG"
500508
OUTPUT=
501509
while [[ $OUTPUT != *"CockroachDB node starting"* ]]; do
502510
echo "Waiting for CockroachDB to start..."
503511
sleep 10
504512
# Note we need to redirect stderr to stdout to capture the logs
505513
OUTPUT=$($CONTAINER_CLI logs cockroach 2>&1)
506514
done
507-
echo "Enabling experimental box2d operators and some ptimized settings for running the tests"
515+
echo "Enabling experimental box2d operators and some optimized settings for running the tests"
508516
#settings documented in https://www.cockroachlabs.com/docs/v21.2/local-testing.html#use-a-local-single-node-cluster-with-in-memory-storage
509-
$CONTAINER_CLI exec -it cockroach bash -c "cat <<EOF | ./cockroach sql --insecure
517+
$CONTAINER_CLI exec cockroach bash -c "cat <<EOF | ./cockroach sql --insecure
510518
SET CLUSTER SETTING sql.spatial.experimental_box2d_comparison_operators.enabled = on;
511519
SET CLUSTER SETTING kv.raft_log.disable_synchronization_unsafe = true;
512520
SET CLUSTER SETTING kv.range_merge.queue_interval = '50ms';
@@ -516,8 +524,12 @@ SET CLUSTER SETTING jobs.retention_time = '15s';
516524
SET CLUSTER SETTING schemachanger.backfiller.buffer_increment = '128 KiB';
517525
SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false;
518526
SET CLUSTER SETTING kv.range_split.by_load_merge_delay = '5s';
519-
ALTER RANGE default CONFIGURE ZONE USING "gc.ttlseconds" = 5;
520-
ALTER DATABASE system CONFIGURE ZONE USING "gc.ttlseconds" = 5;
527+
SET CLUSTER SETTING timeseries.storage.enabled = false;
528+
SET CLUSTER SETTING timeseries.storage.resolution_10s.ttl = '0s';
529+
SET CLUSTER SETTING timeseries.storage.resolution_30m.ttl = '0s';
530+
ALTER RANGE default CONFIGURE ZONE USING \"gc.ttlseconds\" = 10;
531+
ALTER DATABASE system CONFIGURE ZONE USING \"gc.ttlseconds\" = 10;
532+
ALTER DATABASE defaultdb CONFIGURE ZONE USING \"gc.ttlseconds\" = 10;
521533
quit
522534
EOF
523535
"

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
1818
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
1919
import org.hibernate.persister.entity.EntityPersister;
20+
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
2021

2122
import org.hibernate.testing.orm.junit.DomainModel;
2223
import org.hibernate.testing.orm.junit.SessionFactory;
@@ -39,34 +40,35 @@ public void verifyMappings(SessionFactoryScope scope) {
3940
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
4041
.getRuntimeMetamodels()
4142
.getMappingMetamodel();
43+
final JdbcTypeRegistry jdbcTypeRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
4244
final EntityPersister entityDescriptor = mappingMetamodel.getEntityDescriptor(EntityOfByteArrays.class);
4345

4446
{
4547
final BasicAttributeMapping primitive = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("primitive");
4648
final JdbcMapping jdbcMapping = primitive.getJdbcMapping();
4749
assertThat(jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass(), equalTo(byte[].class));
48-
assertThat( jdbcMapping.getJdbcType().getJdbcTypeCode(), equalTo( Types.VARBINARY));
50+
assertThat( jdbcMapping.getJdbcType(), equalTo( jdbcTypeRegistry.getDescriptor( Types.VARBINARY ) ) );
4951
}
5052

5153
{
5254
final BasicAttributeMapping primitive = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("wrapper");
5355
final JdbcMapping jdbcMapping = primitive.getJdbcMapping();
5456
assertThat(jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass(), equalTo(Byte[].class));
55-
assertThat( jdbcMapping.getJdbcType().getJdbcTypeCode(), equalTo( Types.VARBINARY));
57+
assertThat( jdbcMapping.getJdbcType(), equalTo( jdbcTypeRegistry.getDescriptor( Types.VARBINARY ) ) );
5658
}
5759

5860
{
5961
final BasicAttributeMapping primitive = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("primitiveLob");
6062
final JdbcMapping jdbcMapping = primitive.getJdbcMapping();
6163
assertThat(jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass(), equalTo(byte[].class));
62-
assertThat( jdbcMapping.getJdbcType().getJdbcTypeCode(), equalTo( Types.BLOB));
64+
assertThat( jdbcMapping.getJdbcType(), equalTo( jdbcTypeRegistry.getDescriptor( Types.BLOB ) ) );
6365
}
6466

6567
{
6668
final BasicAttributeMapping primitive = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("wrapperLob");
6769
final JdbcMapping jdbcMapping = primitive.getJdbcMapping();
6870
assertThat(jdbcMapping.getJavaTypeDescriptor().getJavaTypeClass(), equalTo(Byte[].class));
69-
assertThat( jdbcMapping.getJdbcType().getJdbcTypeCode(), equalTo( Types.BLOB));
71+
assertThat( jdbcMapping.getJdbcType(), equalTo( jdbcTypeRegistry.getDescriptor( Types.BLOB ) ) );
7072
}
7173

7274
scope.inTransaction(

documentation/src/test/java/org/hibernate/userguide/multitenancy/AbstractMultiTenancyTest.java

+29-22
Original file line numberDiff line numberDiff line change
@@ -144,36 +144,43 @@ protected SessionFactory sessionFactory(Map<String, Object> settings) {
144144
HibernateSchemaManagementTool tool = new HibernateSchemaManagementTool();
145145
tool.injectServices(serviceRegistry);
146146

147-
final GenerationTargetToDatabase frontEndSchemaGenerator = new GenerationTargetToDatabase(
148-
new DdlTransactionIsolatorTestingImpl(
149-
serviceRegistry,
150-
connectionProviderMap.get(FRONT_END_TENANT)
151-
)
152-
);
153-
final GenerationTargetToDatabase backEndSchemaGenerator = new GenerationTargetToDatabase(
154-
new DdlTransactionIsolatorTestingImpl(
155-
serviceRegistry,
156-
connectionProviderMap.get(BACK_END_TENANT)
157-
)
158-
);
159-
160-
new SchemaDropperImpl(serviceRegistry).doDrop(
147+
new SchemaDropperImpl( serviceRegistry ).doDrop(
161148
metadata,
162149
serviceRegistry,
163150
settings,
164151
true,
165-
frontEndSchemaGenerator,
166-
backEndSchemaGenerator
167-
);
168-
169-
new SchemaCreatorImpl(serviceRegistry).doCreation(
152+
new GenerationTargetToDatabase(
153+
new DdlTransactionIsolatorTestingImpl(
154+
serviceRegistry,
155+
connectionProviderMap.get( FRONT_END_TENANT )
156+
)
157+
),
158+
new GenerationTargetToDatabase(
159+
new DdlTransactionIsolatorTestingImpl(
160+
serviceRegistry,
161+
connectionProviderMap.get( BACK_END_TENANT )
162+
)
163+
)
164+
);
165+
166+
new SchemaCreatorImpl( serviceRegistry ).doCreation(
170167
metadata,
171168
serviceRegistry,
172169
settings,
173170
true,
174-
frontEndSchemaGenerator,
175-
backEndSchemaGenerator
176-
);
171+
new GenerationTargetToDatabase(
172+
new DdlTransactionIsolatorTestingImpl(
173+
serviceRegistry,
174+
connectionProviderMap.get( FRONT_END_TENANT )
175+
)
176+
),
177+
new GenerationTargetToDatabase(
178+
new DdlTransactionIsolatorTestingImpl(
179+
serviceRegistry,
180+
connectionProviderMap.get( BACK_END_TENANT )
181+
)
182+
)
183+
);
177184

178185
final SessionFactoryBuilder sessionFactoryBuilder = metadata.getSessionFactoryBuilder();
179186
return sessionFactoryBuilder.build();

documentation/src/test/java/org/hibernate/userguide/multitenancy/DatabaseTimeZoneMultiTenancyTest.java

+29-22
Original file line numberDiff line numberDiff line change
@@ -232,36 +232,43 @@ protected SessionFactory sessionFactory(Map<String, Object> settings) {
232232
HibernateSchemaManagementTool tool = new HibernateSchemaManagementTool();
233233
tool.injectServices(serviceRegistry);
234234

235-
final GenerationTargetToDatabase frontEndSchemaGenerator = new GenerationTargetToDatabase(
236-
new DdlTransactionIsolatorTestingImpl(
237-
serviceRegistry,
238-
connectionProviderMap.get(FRONT_END_TENANT)
239-
)
240-
);
241-
final GenerationTargetToDatabase backEndSchemaGenerator = new GenerationTargetToDatabase(
242-
new DdlTransactionIsolatorTestingImpl(
243-
serviceRegistry,
244-
connectionProviderMap.get(BACK_END_TENANT)
245-
)
246-
);
247-
248-
new SchemaDropperImpl(serviceRegistry).doDrop(
235+
new SchemaDropperImpl( serviceRegistry ).doDrop(
249236
metadata,
250237
serviceRegistry,
251238
settings,
252239
true,
253-
frontEndSchemaGenerator,
254-
backEndSchemaGenerator
255-
);
256-
257-
new SchemaCreatorImpl(serviceRegistry).doCreation(
240+
new GenerationTargetToDatabase(
241+
new DdlTransactionIsolatorTestingImpl(
242+
serviceRegistry,
243+
connectionProviderMap.get( FRONT_END_TENANT )
244+
)
245+
),
246+
new GenerationTargetToDatabase(
247+
new DdlTransactionIsolatorTestingImpl(
248+
serviceRegistry,
249+
connectionProviderMap.get( BACK_END_TENANT )
250+
)
251+
)
252+
);
253+
254+
new SchemaCreatorImpl( serviceRegistry ).doCreation(
258255
metadata,
259256
serviceRegistry,
260257
settings,
261258
true,
262-
frontEndSchemaGenerator,
263-
backEndSchemaGenerator
264-
);
259+
new GenerationTargetToDatabase(
260+
new DdlTransactionIsolatorTestingImpl(
261+
serviceRegistry,
262+
connectionProviderMap.get( FRONT_END_TENANT )
263+
)
264+
),
265+
new GenerationTargetToDatabase(
266+
new DdlTransactionIsolatorTestingImpl(
267+
serviceRegistry,
268+
connectionProviderMap.get( BACK_END_TENANT )
269+
)
270+
)
271+
);
265272

266273
final SessionFactoryBuilder sessionFactoryBuilder = metadata.getSessionFactoryBuilder();
267274
return sessionFactoryBuilder.build();

0 commit comments

Comments
 (0)