I'm running a @QuarkusTest using @QuarkusTestResource(H2DatabaseTestResource.class) with a load script. If the load script fails (bad sql or otherwise), the test is still run. It doesn't make any sense to run the test if the test data wasn't properly created. How do I get the test to abort/fail if the load fails? Here's the exception the load throws:
Hibernate: insert into task (id, task_type, status, options, created_by) values (9, 'DELETE', 'NEW', '{}' format json, 'h2 quarkus test')
18:14:45 INFO [o.h.t.s.i.e.Generation] (JPA Startup Thread: <default>) HHH000476: Executing script 'file:/Users/me/git/myservice/target/test-classes/import.sql'
Hibernate: insert into task (id, task_type, status, created_by) values (1, 42, 'DELETE', 'NEW', '{}' format json, null, '')
Hibernate: insert into event (id, task_id, created_at, event_type, message) values (777, 888, now(), '', '')
18:14:45 WARN [o.h.t.s.i.ExceptionHan] (JPA Startup Thread: <default>) GenerationTarget encountered exception accepting command : Error executing DDL "insert into task (id, task_type, status, created_by) values (8, 42, 'DEL', 'NEW', '{}' format json, '')" via JDBC [Constraint violation: "CONSTRAINT_272: "
Check constraint violation: "CONSTRAINT_272: ";]: org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "insert into task (id, task_type, status, subsystems, created_by) values (88, 42, 'DEL', 'NEW', '{}' format json, '')" via JDBC [Constraint violation: "CONSTRAINT_272: "
Check constraint violation: "CONSTRAINT_272: ";]
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:92)
at org.hibernate.tool.schema.internal.Helper.applySqlString(Helper.java:235)
at org.hibernate.tool.schema.internal.Helper.applyScript(Helper.java:257)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applyImportFiles(SchemaCreatorImpl.java:650)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applyImportSources(SchemaCreatorImpl.java:569)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:184)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:142)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:118)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:254)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.lambda$process$5(SchemaManagementToolCoordinator.java:143)
at java.base/java.util.HashMap.forEach(HashMap.java:1421)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:140)
at io.quarkus.hibernate.orm.runtime.observers.SessionFactoryObserverForSchemaExport.sessionFactoryCreated(SessionFactoryObserverForSchemaExport.java:21)
at org.hibernate.internal.SessionFactoryObserverChain.sessionFactoryCreated(SessionFactoryObserverChain.java:35)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:291)
at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:84)
at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:74)
at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)
at jakarta.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig.java:156)
at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:64)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Constraint violation: "CONSTRAINT_272: "
Check constraint violation: "CONSTRAINT_272: "; SQL statement:
insert into task (id, task_type, status, created_by) values (8888, 42, 'DEL', 'NEW', '{}' format json, 'MyTest') [23513-214]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:508)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
at org.h2.message.DbException.get(DbException.java:223)
at org.h2.message.DbException.get(DbException.java:199)
at org.h2.constraint.ConstraintCheck.checkRow(ConstraintCheck.java:110)
at org.h2.table.Table.fireConstraints(Table.java:1172)
at org.h2.table.Table.fireBeforeRow(Table.java:1163)
at org.h2.command.dml.Insert.insertRows(Insert.java:171)
at org.h2.command.dml.Insert.update(Insert.java:135)
at org.h2.command.dml.DataChangeStatement.update(DataChangeStatement.java:74)
at org.h2.command.CommandContainer.update(CommandContainer.java:169)
at org.h2.command.Command.executeUpdate(Command.java:252)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:252)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:223)
at io.agroal.pool.wrapper.StatementWrapper.execute(StatementWrapper.java:235)
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:78)
... 21 more