Skip to content

[BUG]: runtime.crawl_permissions fails when called from pytest #1129

@ericvergnaud

Description

@ericvergnaud

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

calling crawl_permissions from pytest shows an exception

Expected Behavior

it should not throw an exception

Steps To Reproduce

In test_runtime.py, uncomment test test_runtime_crawl_permissions
run the test
when calling ws.api.client.do, assert isinstance(result, dict) fails

Cloud

AWS

Operating System

macOS

Version

latest via Databricks CLI

Relevant log output

tests/unit/test_runtime.py:118 (test_runtime_crawl_permissions)
mocker = <pytest_mock.plugin.MockerFixture object at 0x10f9b3f50>

    def test_runtime_crawl_permissions(mocker):
        with patch.dict(os.environ, {"DATABRICKS_RUNTIME_VERSION": "14.0"}):
            pyspark_sql_session = mocker.Mock()
            sys.modules["pyspark.sql.session"] = pyspark_sql_session
            cfg = azure_mock_config()
            ws = create_autospec(WorkspaceClient)
            sql_backend = MockBackend()
>           crawl_permissions(cfg, ws, sql_backend, mock_installation())

test_runtime.py:126: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../src/databricks/labs/ucx/framework/tasks.py:83: in wrapper
    result = func(*args, **kwargs)
../../src/databricks/labs/ucx/runtime.py:240: in crawl_permissions
    permission_manager.inventorize_permissions()
../../src/databricks/labs/ucx/workspace_access/manager.py:89: in inventorize_permissions
    crawler_tasks = list(self._get_crawler_tasks())
../../src/databricks/labs/ucx/workspace_access/manager.py:216: in _get_crawler_tasks
    yield from support.get_crawler_tasks()
../../src/databricks/labs/ucx/workspace_access/generic.py:74: in get_crawler_tasks
    for info in listing:
../../src/databricks/labs/ucx/workspace_access/generic.py:58: in __iter__
    for item in self._func():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    def inner() -> list[GenericPermissionsInfo]:
        feature_tables = []
        token = None
        while True:
            result = ws.api_client.do(
                "GET", "/api/2.0/feature-store/feature-tables/search", query={"page_token": token, "max_results": 200}
            )
>           assert isinstance(result, dict)
E           AssertionError

../../src/databricks/labs/ucx/workspace_access/generic.py:422: AssertionError

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions