Fix: Improved test suite logging (#20635)

* Fix: Improved test suite logging

* linting
This commit is contained in:
Suman Maharana 2025-04-04 16:51:21 +05:30 committed by GitHub
parent ed77fe1afa
commit 61e500253f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -96,13 +96,24 @@ class TestSuiteSource(Source):
""" """
# Logical test suites don't have associated tables # Logical test suites don't have associated tables
if self.source_config.entityFullyQualifiedName is None: if self.source_config.entityFullyQualifiedName is None:
logger.debug("No entity FQN provided, skipping table entity retrieval")
return None return None
logger.info(
f"Retrieving table entity for FQN: {self.source_config.entityFullyQualifiedName.root}"
)
table: Table = self.metadata.get_by_name( table: Table = self.metadata.get_by_name(
entity=Table, entity=Table,
fqn=self.source_config.entityFullyQualifiedName.root, fqn=self.source_config.entityFullyQualifiedName.root,
fields=["tableProfilerConfig", "testSuite", "serviceType"], fields=["tableProfilerConfig", "testSuite", "serviceType"],
) )
if not table:
logger.warning(
f"Table not found for FQN: {self.source_config.entityFullyQualifiedName.root}. "
"Please double check the entityFullyQualifiedName"
"by copying it directly from the entity URL in the OpenMetadata UI. "
"The FQN should be in the format: service_name.database_name.schema_name.table_name"
)
return table return table
def _get_table_service_connection(self, table: Table) -> DatabaseConnection: def _get_table_service_connection(self, table: Table) -> DatabaseConnection:
@ -196,6 +207,9 @@ class TestSuiteSource(Source):
# If there is no executable test suite yet for the table, we'll need to create one # If there is no executable test suite yet for the table, we'll need to create one
# Then, the suite won't have yet any tests # Then, the suite won't have yet any tests
if not table.testSuite or table.testSuite.id.root is None: if not table.testSuite or table.testSuite.id.root is None:
logger.info(
f"Creating new test suite for table {table.name.root} as no executable test suite exists"
)
executable_test_suite = CreateTestSuiteRequest( executable_test_suite = CreateTestSuiteRequest(
name=fqn.build( name=fqn.build(
None, None,
@ -218,6 +232,7 @@ class TestSuiteSource(Source):
# Otherwise, we pick the tests already registered in the suite # Otherwise, we pick the tests already registered in the suite
else: else:
logger.info(f"Using existing test suite for table {table.name.root}")
test_suite: Optional[TestSuite] = self.metadata.get_by_id( test_suite: Optional[TestSuite] = self.metadata.get_by_id(
entity=TestSuite, entity_id=table.testSuite.id.root entity=TestSuite, entity_id=table.testSuite.id.root
) )
@ -242,6 +257,9 @@ class TestSuiteSource(Source):
def _process_logical_suite(self): def _process_logical_suite(self):
"""Process logical test suite, collect all test cases and yield them in batches by table""" """Process logical test suite, collect all test cases and yield them in batches by table"""
logger.info(
f"Processing logical test suite for service name: {self.config.source.serviceName}"
)
test_suite = self.metadata.get_by_name( test_suite = self.metadata.get_by_name(
entity=TestSuite, fqn=self.config.source.serviceName entity=TestSuite, fqn=self.config.source.serviceName
) )
@ -252,6 +270,10 @@ class TestSuiteSource(Source):
error=f"Test Suite with name {self.config.source.serviceName} not found", error=f"Test Suite with name {self.config.source.serviceName} not found",
) )
) )
# Return early if test suite not found in TestSuiteSource
return
logger.info(f"Found test suite: {test_suite.name.root}")
test_cases: List[TestCase] = self._get_test_cases_from_test_suite(test_suite) test_cases: List[TestCase] = self._get_test_cases_from_test_suite(test_suite)
grouped_by_table = itertools.groupby( grouped_by_table = itertools.groupby(
test_cases, key=lambda t: entity_link.get_table_fqn(t.entityLink.root) test_cases, key=lambda t: entity_link.get_table_fqn(t.entityLink.root)