mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-05 15:13:07 +00:00
FIX - try-catch test suite migrations (#16160)
* FIX - try-catch test suite migrations * format --------- Co-authored-by: Sriharsha Chintalapani <harshach@users.noreply.github.com>
This commit is contained in:
parent
96417452a9
commit
5181c79bbc
@ -495,61 +495,65 @@ public class MigrationUtil {
|
|||||||
*/
|
*/
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public static void testSuitesMigration(CollectionDAO collectionDAO) {
|
public static void testSuitesMigration(CollectionDAO collectionDAO) {
|
||||||
// Update existing test suites as logical test suites and delete any ingestion pipeline
|
try {
|
||||||
// associated with the existing test suite
|
// Update existing test suites as logical test suites and delete any ingestion pipeline
|
||||||
migrateExistingTestSuitesToLogical(collectionDAO);
|
// associated with the existing test suite
|
||||||
|
migrateExistingTestSuitesToLogical(collectionDAO);
|
||||||
|
|
||||||
// create native test suites
|
// create native test suites
|
||||||
TestSuiteRepository testSuiteRepository =
|
TestSuiteRepository testSuiteRepository =
|
||||||
(TestSuiteRepository) Entity.getEntityRepository(TEST_SUITE);
|
(TestSuiteRepository) Entity.getEntityRepository(TEST_SUITE);
|
||||||
Map<String, ArrayList<TestCase>> testCasesByTable = groupTestCasesByTable();
|
Map<String, ArrayList<TestCase>> testCasesByTable = groupTestCasesByTable();
|
||||||
for (Entry<String, ArrayList<TestCase>> entry : testCasesByTable.entrySet()) {
|
for (Entry<String, ArrayList<TestCase>> entry : testCasesByTable.entrySet()) {
|
||||||
String tableFQN = entry.getKey();
|
String tableFQN = entry.getKey();
|
||||||
String nativeTestSuiteFqn = tableFQN + ".testSuite";
|
String nativeTestSuiteFqn = tableFQN + ".testSuite";
|
||||||
List<TestCase> testCases = entry.getValue();
|
List<TestCase> testCases = entry.getValue();
|
||||||
if (testCases != null && !testCases.isEmpty()) {
|
if (testCases != null && !testCases.isEmpty()) {
|
||||||
MessageParser.EntityLink entityLink =
|
MessageParser.EntityLink entityLink =
|
||||||
MessageParser.EntityLink.parse(testCases.stream().findFirst().get().getEntityLink());
|
MessageParser.EntityLink.parse(testCases.stream().findFirst().get().getEntityLink());
|
||||||
TestSuite newExecutableTestSuite =
|
TestSuite newExecutableTestSuite =
|
||||||
getTestSuite(
|
getTestSuite(
|
||||||
collectionDAO,
|
collectionDAO,
|
||||||
new CreateTestSuite()
|
new CreateTestSuite()
|
||||||
.withName(FullyQualifiedName.buildHash(nativeTestSuiteFqn))
|
.withName(FullyQualifiedName.buildHash(nativeTestSuiteFqn))
|
||||||
.withDisplayName(nativeTestSuiteFqn)
|
.withDisplayName(nativeTestSuiteFqn)
|
||||||
.withExecutableEntityReference(entityLink.getEntityFQN()),
|
.withExecutableEntityReference(entityLink.getEntityFQN()),
|
||||||
"ingestion-bot")
|
"ingestion-bot")
|
||||||
.withExecutable(true)
|
.withExecutable(true)
|
||||||
.withFullyQualifiedName(nativeTestSuiteFqn);
|
.withFullyQualifiedName(nativeTestSuiteFqn);
|
||||||
testSuiteRepository.prepareInternal(newExecutableTestSuite, false);
|
testSuiteRepository.prepareInternal(newExecutableTestSuite, false);
|
||||||
try {
|
try {
|
||||||
testSuiteRepository
|
testSuiteRepository
|
||||||
.getDao()
|
.getDao()
|
||||||
.insert(
|
.insert(
|
||||||
"nameHash",
|
"nameHash",
|
||||||
newExecutableTestSuite,
|
newExecutableTestSuite,
|
||||||
newExecutableTestSuite.getFullyQualifiedName());
|
newExecutableTestSuite.getFullyQualifiedName());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOG.warn(String.format("TestSuite %s exists", nativeTestSuiteFqn));
|
LOG.warn(String.format("TestSuite %s exists", nativeTestSuiteFqn));
|
||||||
}
|
}
|
||||||
// add relationship between executable TestSuite with Table
|
// add relationship between executable TestSuite with Table
|
||||||
testSuiteRepository.addRelationship(
|
|
||||||
newExecutableTestSuite.getExecutableEntityReference().getId(),
|
|
||||||
newExecutableTestSuite.getId(),
|
|
||||||
Entity.TABLE,
|
|
||||||
TEST_SUITE,
|
|
||||||
Relationship.CONTAINS);
|
|
||||||
|
|
||||||
// add relationship between all the testCases that are created against a table with native
|
|
||||||
// test suite.
|
|
||||||
for (TestCase testCase : testCases) {
|
|
||||||
testSuiteRepository.addRelationship(
|
testSuiteRepository.addRelationship(
|
||||||
|
newExecutableTestSuite.getExecutableEntityReference().getId(),
|
||||||
newExecutableTestSuite.getId(),
|
newExecutableTestSuite.getId(),
|
||||||
testCase.getId(),
|
Entity.TABLE,
|
||||||
TEST_SUITE,
|
TEST_SUITE,
|
||||||
TEST_CASE,
|
|
||||||
Relationship.CONTAINS);
|
Relationship.CONTAINS);
|
||||||
|
|
||||||
|
// add relationship between all the testCases that are created against a table with native
|
||||||
|
// test suite.
|
||||||
|
for (TestCase testCase : testCases) {
|
||||||
|
testSuiteRepository.addRelationship(
|
||||||
|
newExecutableTestSuite.getId(),
|
||||||
|
testCase.getId(),
|
||||||
|
TEST_SUITE,
|
||||||
|
TEST_CASE,
|
||||||
|
Relationship.CONTAINS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOG.error("Failed to migrate test suites", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user