Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update integration test to create catalog
Browse files Browse the repository at this point in the history
JCZuurmond committed Sep 23, 2024

Verified

This commit was signed with the committer’s verified signature.
1 parent 1523ad3 commit 1cc2a2c
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions tests/integration/hive_metastore/test_catalog_schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
from datetime import timedelta
from collections.abc import Iterator

import pytest
from databricks.labs.blueprint.tui import MockPrompts
@@ -17,34 +16,19 @@
_SPARK_CONF = get_azure_spark_conf()


@pytest.fixture
def catalog_name(ws, make_random) -> Iterator[str]:
name = f"test-catalog-{make_random(5)}"
yield name
try:
ws.catalogs.delete(name, force=True)
logger.info(f"Deleted test catalog: {name}")
except NotFound:
pass


@retried(on=[NotFound], timeout=timedelta(minutes=2))
def test_create_ucx_catalog_creates_catalog(
ws,
runtime_ctx,
watchdog_remove_after,
catalog_name,
) -> None:
prompts = MockPrompts({f"Please provide storage location url for catalog: {catalog_name}": "metastore"})
runtime_ctx.catalog_schema._ucx_catalog = catalog_name
def test_create_ucx_catalog_creates_catalog(ws, runtime_ctx, watchdog_remove_after) -> None:
# Delete catalog created for testing to test the creation of a new catalog
runtime_ctx.workspace_client.catalogs.delete(runtime_ctx.ucx_catalog, force=True)
prompts = MockPrompts({f"Please provide storage location url for catalog: {runtime_ctx.ucx_catalog}": "metastore"})

runtime_ctx.catalog_schema.create_ucx_catalog(prompts, properties={"RemoveAfter": watchdog_remove_after})

@retried(on=[KeyError], timeout=timedelta(seconds=20))
@retried(on=[NotFound], timeout=timedelta(seconds=20))
def get_catalog(name: str) -> CatalogInfo:
return ws.catalogs.get(name)

assert get_catalog(catalog_name)
assert get_catalog(runtime_ctx.ucx_catalog)


@retried(on=[NotFound], timeout=timedelta(minutes=2))

0 comments on commit 1cc2a2c

Please sign in to comment.