|
9 | 9 | import pytest |
10 | 10 | from databricks.sdk import AccountClient, WorkspaceClient |
11 | 11 | from databricks.sdk.core import Config |
12 | | -from databricks.sdk.service.compute import CreatePolicyResponse |
13 | 12 | from databricks.sdk.service.iam import AccessControlRequest, PermissionLevel |
14 | 13 | from databricks.sdk.service.workspace import ObjectInfo, ObjectType |
15 | 14 |
|
|
19 | 18 | from databricks.labs.ucx.providers.mixins.sql import StatementExecutionExt |
20 | 19 | from databricks.labs.ucx.utils import ThreadedExecution |
21 | 20 |
|
22 | | -from .utils import ( |
23 | | - EnvironmentInfo, |
24 | | - InstanceProfile, |
25 | | - WorkspaceObjects, |
26 | | - _set_random_permissions, |
27 | | -) |
| 21 | +from .utils import EnvironmentInfo, InstanceProfile, WorkspaceObjects |
28 | 22 |
|
29 | 23 | logging.getLogger("tests").setLevel("DEBUG") |
30 | 24 | logging.getLogger("databricks.labs.ucx").setLevel("DEBUG") |
31 | 25 |
|
32 | 26 | logger = logging.getLogger(__name__) |
33 | 27 |
|
34 | | -NUM_TEST_GROUPS = int(os.environ.get("NUM_TEST_GROUPS", 5)) |
35 | 28 | NUM_TEST_INSTANCE_PROFILES = int(os.environ.get("NUM_TEST_INSTANCE_PROFILES", 3)) |
36 | | -NUM_TEST_CLUSTER_POLICIES = int(os.environ.get("NUM_TEST_CLUSTER_POLICIES", 3)) |
37 | 29 | NUM_TEST_TOKENS = int(os.environ.get("NUM_TEST_TOKENS", 3)) |
38 | 30 |
|
39 | 31 | NUM_THREADS = int(os.environ.get("NUM_TEST_THREADS", 20)) |
@@ -242,41 +234,6 @@ def instance_profiles(env: EnvironmentInfo, ws: WorkspaceClient) -> list[Instanc |
242 | 234 | logger.debug("Test instance profiles deleted") |
243 | 235 |
|
244 | 236 |
|
245 | | -@pytest.fixture |
246 | | -def cluster_policies(env: EnvironmentInfo, ws: WorkspaceClient) -> list[CreatePolicyResponse]: |
247 | | - logger.debug("Creating test cluster policies") |
248 | | - |
249 | | - test_cluster_policies: list[CreatePolicyResponse] = [ |
250 | | - ws.cluster_policies.create( |
251 | | - name=f"{env.test_uid}-test-{i}", |
252 | | - definition=""" |
253 | | - { |
254 | | - "spark_version": { |
255 | | - "type": "unlimited", |
256 | | - "defaultValue": "auto:latest-lts" |
257 | | - } |
258 | | - } |
259 | | - """, |
260 | | - ) |
261 | | - for i in range(NUM_TEST_CLUSTER_POLICIES) |
262 | | - ] |
263 | | - |
264 | | - _set_random_permissions( |
265 | | - test_cluster_policies, |
266 | | - "policy_id", |
267 | | - RequestObjectType.CLUSTER_POLICIES, |
268 | | - env, |
269 | | - ws, |
270 | | - permission_levels=[PermissionLevel.CAN_USE], |
271 | | - ) |
272 | | - |
273 | | - yield test_cluster_policies |
274 | | - |
275 | | - logger.debug("Deleting test instance pools") |
276 | | - executables = [partial(ws.cluster_policies.delete, p.policy_id) for p in test_cluster_policies] |
277 | | - Threader(executables).run() |
278 | | - |
279 | | - |
280 | 237 | @pytest.fixture |
281 | 238 | def tokens(ws: WorkspaceClient, env: EnvironmentInfo) -> list[AccessControlRequest]: |
282 | 239 | logger.debug("Adding token-level permissions to groups") |
@@ -352,14 +309,12 @@ def workspace_objects(ws: WorkspaceClient, env: EnvironmentInfo) -> WorkspaceObj |
352 | 309 |
|
353 | 310 | @pytest.fixture |
354 | 311 | def verifiable_objects( |
355 | | - cluster_policies, |
356 | 312 | tokens, |
357 | 313 | workspace_objects, |
358 | 314 | ) -> list[tuple[list, str, RequestObjectType | None]]: |
359 | 315 | _verifiable_objects = [ |
360 | 316 | (workspace_objects, "workspace_objects", None), |
361 | 317 | (tokens, "tokens", RequestObjectType.AUTHORIZATION), |
362 | | - (cluster_policies, "policy_id", RequestObjectType.CLUSTER_POLICIES), |
363 | 318 | ] |
364 | 319 | yield _verifiable_objects |
365 | 320 |
|
|
0 commit comments