From 5b74ea0978bfdcebd996042b2ef6af0819829aca Mon Sep 17 00:00:00 2001 From: Ralph Gasser Date: Wed, 17 Jan 2024 12:53:07 +0100 Subject: [PATCH] Adds safety measure in test preparation. --- .../AbstractSerializationTest.kt | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/cottontaildb-dbms/src/test/kotlin/org/vitrivr/cottontail/dbms/entity/serialization/AbstractSerializationTest.kt b/cottontaildb-dbms/src/test/kotlin/org/vitrivr/cottontail/dbms/entity/serialization/AbstractSerializationTest.kt index 095854458..d2b3aca9a 100644 --- a/cottontaildb-dbms/src/test/kotlin/org/vitrivr/cottontail/dbms/entity/serialization/AbstractSerializationTest.kt +++ b/cottontaildb-dbms/src/test/kotlin/org/vitrivr/cottontail/dbms/entity/serialization/AbstractSerializationTest.kt @@ -18,7 +18,7 @@ import java.nio.file.Files * An abstract class for test cases that test for correctness of serialization * * @author Ralph Gasser - * @version 1.5.0 + * @version 1.5.1 */ abstract class AbstractSerializationTest: AbstractEntityTest() { @@ -93,18 +93,23 @@ abstract class AbstractSerializationTest: AbstractEntityTest() { /* Start inserting. */ val txn = this.manager.startTransaction(TransactionType.SYSTEM_EXCLUSIVE) - val ctx = DefaultQueryContext("serialization-populate", this.catalogue, txn) - val catalogueTx = this.catalogue.newTx(ctx) - val schema = catalogueTx.schemaForName(this.schemaName) - val schemaTx = schema.newTx(ctx) - val entity = schemaTx.entityForName(this.entityName) - val entityTx = entity.newTx(ctx) - - /* Insert data and track how many entries have been stored for the test later. */ - repeat(TestConstants.TEST_COLLECTION_SIZE) { - entityTx.insert(nextRecord(it)) + try { + val ctx = DefaultQueryContext("serialization-populate", this.catalogue, txn) + val catalogueTx = this.catalogue.newTx(ctx) + val schema = catalogueTx.schemaForName(this.schemaName) + val schemaTx = schema.newTx(ctx) + val entity = schemaTx.entityForName(this.entityName) + val entityTx = entity.newTx(ctx) + + /* Insert data and track how many entries have been stored for the test later. */ + repeat(TestConstants.TEST_COLLECTION_SIZE) { + entityTx.insert(nextRecord(it)) + } + txn.commit() + } catch (e: Throwable) { + txn.rollback() + throw e } - txn.commit() } /**