Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace warehouse fixture with the new one #170

Merged
merged 6 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 0 additions & 40 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
NotebookLibrary,
PipelineLibrary,
)
from databricks.sdk.service.sql import (
CreateWarehouseRequestWarehouseType,
GetWarehouseResponse,
)
from databricks.sdk.service.workspace import ObjectInfo, ObjectType

from databricks.labs.ucx.config import InventoryTable
Expand Down Expand Up @@ -53,7 +49,6 @@
NUM_TEST_JOBS = int(os.environ.get("NUM_TEST_JOBS", 3))
NUM_TEST_EXPERIMENTS = int(os.environ.get("NUM_TEST_EXPERIMENTS", 3))
NUM_TEST_MODELS = int(os.environ.get("NUM_TEST_MODELS", 3))
NUM_TEST_WAREHOUSES = int(os.environ.get("NUM_TEST_WAREHOUSES", 3))
NUM_TEST_TOKENS = int(os.environ.get("NUM_TEST_TOKENS", 3))

NUM_THREADS = int(os.environ.get("NUM_TEST_THREADS", 20))
Expand Down Expand Up @@ -420,41 +415,6 @@ def models(ws: WorkspaceClient, env: EnvironmentInfo) -> list[ModelDatabricks]:
logger.debug("Test models deleted")


@pytest.fixture
def warehouses(ws: WorkspaceClient, env: EnvironmentInfo) -> list[GetWarehouseResponse]:
logger.debug("Creating warehouses")

creators = [
partial(
ws.warehouses.create,
name=f"{env.test_uid}-test-{i}",
cluster_size="2X-Small",
warehouse_type=CreateWarehouseRequestWarehouseType.PRO,
max_num_clusters=1,
enable_serverless_compute=False,
)
for i in range(NUM_TEST_WAREHOUSES)
]

test_warehouses: list[GetWarehouseResponse] = Threader(creators).run()

_set_random_permissions(
test_warehouses,
"id",
RequestObjectType.SQL_WAREHOUSES,
env,
ws,
permission_levels=[PermissionLevel.CAN_USE, PermissionLevel.CAN_MANAGE],
)

yield test_warehouses

logger.debug("Deleting test warehouses")
executables = [partial(ws.warehouses.delete, w.id) for w in test_warehouses]
Threader(executables).run()
logger.debug("Test warehouses deleted")


@pytest.fixture
def tokens(ws: WorkspaceClient, env: EnvironmentInfo) -> list[AccessControlRequest]:
logger.debug("Adding token-level permissions to groups")
Expand Down
12 changes: 12 additions & 0 deletions tests/integration/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def test_e2e(
make_cluster_permissions,
make_secret_scope,
make_secret_scope_acl,
make_warehouse,
make_warehouse_permissions,
):
logger.debug(f"Test environment: {env.test_uid}")
ws_group = env.groups[0][0]
Expand Down Expand Up @@ -164,6 +166,16 @@ def test_e2e(
make_secret_scope_acl(scope=scope, principal=ws_group.display_name, permission=workspace.AclPermission.WRITE)
verifiable_objects.append(([scope], "secret_scopes", None))

warehouse = make_warehouse()
make_warehouse_permissions(
object_id=warehouse.warehouse_id,
permission_level=random.choice([PermissionLevel.CAN_USE, PermissionLevel.CAN_MANAGE]),
group_name=ws_group.display_name,
)
verifiable_objects.append(
([warehouse], "warehouse_id", RequestObjectType.SQL_WAREHOUSES),
)

config = MigrationConfig(
connect=ConnectConfig.from_databricks_config(ws.config),
inventory=InventoryConfig(table=inventory_table),
Expand Down