From f9ac4c74c6bffdadc9081260803f13acc3fe0d2b Mon Sep 17 00:00:00 2001 From: Piotr Skrydalewicz Date: Fri, 15 Nov 2024 18:13:44 +0100 Subject: [PATCH] Added handling of exceptions when listing tables --- metadata-ingestion/tests/unit/test_iceberg.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/metadata-ingestion/tests/unit/test_iceberg.py b/metadata-ingestion/tests/unit/test_iceberg.py index ab24e9897a3f4..b8a136586a2bf 100644 --- a/metadata-ingestion/tests/unit/test_iceberg.py +++ b/metadata-ingestion/tests/unit/test_iceberg.py @@ -561,6 +561,21 @@ def list_tables(self, namespace: str) -> Iterable[Tuple[str, str]]: return super().list_tables(namespace) +class MockCatalogExceptionListingNamespaces(MockCatalog): + def list_namespaces(self) -> Iterable[str]: + raise Exception() + + +def test_exception_while_listing_namespaces() -> None: + source = with_iceberg_source(processing_threads=2) + mock_catalog = MockCatalogExceptionListingNamespaces({}) + with patch( + "datahub.ingestion.source.iceberg.iceberg.IcebergSourceConfig.get_catalog" + ) as get_catalog, pytest.raises(Exception): + get_catalog.return_value = mock_catalog + [*source.get_workunits_internal()] + + def test_known_exception_while_listing_tables() -> None: source = with_iceberg_source(processing_threads=2) mock_catalog = MockCatalogExceptionListingTables(