ci enhancement: complete tearDown to cleanup transactions and cmdb changes properly

This commit is contained in:
odain
2023-10-03 10:09:26 +02:00
parent bdf0b4daa9
commit 239c51bb53
2 changed files with 7 additions and 1 deletions

View File

@@ -136,6 +136,8 @@ class ItopDataTestCase extends ItopTestCase
} }
} }
CMDBObject::SetCurrentChange(null);
parent::tearDown(); parent::tearDown();
} }

View File

@@ -68,6 +68,10 @@ class ItopTestCase extends TestCase
if (CMDBSource::IsInsideTransaction()) { if (CMDBSource::IsInsideTransaction()) {
// Nested transactions were opened but not finished ! // Nested transactions were opened but not finished !
// Rollback to avoid side effects on next tests
while (CMDBSource::IsInsideTransaction()) {
CMDBSource::Query('ROLLBACK');
}
throw new MySQLTransactionNotClosedException('Some DB transactions were opened but not closed ! Fix the code by adding ROLLBACK or COMMIT statements !', []); throw new MySQLTransactionNotClosedException('Some DB transactions were opened but not closed ! Fix the code by adding ROLLBACK or COMMIT statements !', []);
} }
} }
@@ -312,4 +316,4 @@ class ItopTestCase extends TestCase
} }
closedir($dir); closedir($dir);
} }
} }