Skip to content

Commit f0792cc

Browse files
committed
put a bigger wait into two tests on Informix
to compensate for the low resolution of the system clock with Informix running in podman on my Mac
1 parent 30fecce commit f0792cc

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/generated/GeneratedAnnotationBatchTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.hibernate.annotations.Generated;
1414
import org.hibernate.cfg.AvailableSettings;
1515

16+
import org.hibernate.community.dialect.InformixDialect;
1617
import org.hibernate.testing.orm.junit.DomainModel;
1718
import org.hibernate.testing.orm.junit.ServiceRegistry;
1819
import org.hibernate.testing.orm.junit.SessionFactory;
@@ -82,7 +83,7 @@ public void testUpdate(SessionFactoryScope scope) {
8283
entities.forEach( ge -> ge.setName( "updated" ) );
8384

8485
//We need to wait a little to make sure the timestamps produced are different
85-
waitALittle();
86+
waitALittle( scope );
8687
session.flush(); // force update and retrieval of generated values
8788

8889
entities.forEach( ge -> assertThat( ge.getName() ).isEqualTo( "updated" ) );
@@ -129,9 +130,13 @@ public Instant getUpdateTimestamp() {
129130
}
130131
}
131132

132-
private static void waitALittle() {
133+
private static void waitALittle(SessionFactoryScope scope) {
134+
boolean waitLonger =
135+
// informix clock has low resolution on Mac
136+
scope.getSessionFactory().getJdbcServices().getDialect()
137+
instanceof InformixDialect;
133138
try {
134-
Thread.sleep( 10 );
139+
Thread.sleep( waitLonger ? 1_200 : 10 );
135140
}
136141
catch (InterruptedException e) {
137142
throw new HibernateError( "Unexpected wakeup from test sleep" );

hibernate-core/src/test/java/org/hibernate/orm/test/mapping/generated/GeneratedNoOpUpdateTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
import java.util.List;
1010
import java.util.Locale;
1111

12+
import org.hibernate.HibernateError;
1213
import org.hibernate.annotations.CurrentTimestamp;
1314

15+
import org.hibernate.community.dialect.InformixDialect;
1416
import org.hibernate.testing.jdbc.SQLStatementInspector;
1517
import org.hibernate.testing.orm.junit.DomainModel;
1618
import org.hibernate.testing.orm.junit.Jira;
@@ -77,6 +79,8 @@ public void testUpdate(SessionFactoryScope scope) {
7779
assertThat( pizza.getLastUpdated() ).isEqualTo( updatedTime );
7880
} );
7981

82+
waitALittle( scope );
83+
8084
scope.inTransaction( session -> {
8185
final Pizza pizza = session.find( Pizza.class, 1L );
8286
assertThat( pizza.getToppings() ).hasSize( 3 )
@@ -177,4 +181,17 @@ public void setPizza(final Pizza pizza) {
177181
}
178182

179183
}
184+
185+
private static void waitALittle(SessionFactoryScope scope) {
186+
boolean waitLonger =
187+
// informix clock has low resolution on Mac
188+
scope.getSessionFactory().getJdbcServices().getDialect()
189+
instanceof InformixDialect;
190+
try {
191+
Thread.sleep( waitLonger ? 1_200 : 2 );
192+
}
193+
catch (InterruptedException e) {
194+
throw new HibernateError( "Unexpected wakeup from test sleep" );
195+
}
196+
}
180197
}

0 commit comments

Comments
 (0)