Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nfx committed Sep 5, 2023
1 parent b831814 commit e0d3be2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/databricks/labs/ucx/providers/groups_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ def __init__(self):
def add(self, group: MigrationGroupInfo):
self.groups.append(group)

def is_in_scope(self, attr: str, group: Group) -> bool:
for info in self.groups:
if getattr(info, attr).id == group.id:
return True
return False

def get_by_workspace_group_name(self, workspace_group_name: str) -> MigrationGroupInfo | None:
found = [g for g in self.groups if g.workspace.display_name == workspace_group_name]
if len(found) == 0:
Expand Down
17 changes: 7 additions & 10 deletions tests/integration/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ def test_e2e(
toolkit = GroupMigrationToolkit(config)
toolkit.prepare_environment()

for _info in toolkit.group_manager.migration_groups_provider.groups:
group_migration_state = toolkit.group_manager.migration_groups_provider
for _info in group_migration_state.groups:
_ws = ws.groups.get(id=_info.workspace.id)
_backup = ws.groups.get(id=_info.backup.id)
_ws_members = sorted([m.value for m in _ws.members])
Expand All @@ -202,28 +203,24 @@ def test_e2e(
for _objects, id_attribute, request_object_type in verifiable_objects:
_verify_group_permissions(_objects, id_attribute, request_object_type, ws, toolkit, "backup")

_verify_roles_and_entitlements(toolkit.group_manager.migration_groups_provider, ws, "backup")
_verify_roles_and_entitlements(group_migration_state, ws, "backup")

toolkit.replace_workspace_groups_with_account_groups()

new_groups = list(ws.groups.list(filter=f"displayName sw '{env.test_uid}'", attributes="displayName,meta"))
assert len(new_groups) == len(toolkit.group_manager.migration_groups_provider.groups)
new_groups = [_ for _ in ws.groups.list(attributes="displayName,meta") if group_migration_state.is_in_scope('account', _)]
assert len(new_groups) == len(group_migration_state.groups)
assert all(g.meta.resource_type == "Group" for g in new_groups)

toolkit.apply_permissions_to_account_groups()

for _objects, id_attribute, request_object_type in verifiable_objects:
_verify_group_permissions(_objects, id_attribute, request_object_type, ws, toolkit, "account")

_verify_roles_and_entitlements(toolkit.group_manager.migration_groups_provider, ws, "account")
_verify_roles_and_entitlements(group_migration_state, ws, "account")

toolkit.delete_backup_groups()

backup_groups = list(
ws.groups.list(
filter=f"displayName sw '{config.groups.backup_group_prefix}{env.test_uid}'", attributes="displayName,meta"
)
)
backup_groups = [_ for _ in ws.groups.list(attributes="displayName,meta") if group_migration_state.is_in_scope('backup', _)]
assert len(backup_groups) == 0

toolkit.cleanup_inventory_table()

0 comments on commit e0d3be2

Please sign in to comment.