-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refresh migration status at the end of the
migrate_tables
workflows (…
…#1599) ## Changes Refresh migration status at the end of the `migrate_tables` task ### Linked issues Resolves #1597 ### Functionality - [ ] added relevant user documentation - [ ] added new CLI command - [ ] modified existing command: `databricks labs ucx ...` - [ ] added a new workflow - [x] modified existing workflow: `migrate-*-tables*` - [ ] added a new table - [ ] modified existing table: `...` ### Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [x] manually tested - [ ] added unit tests - [x] added integration tests - [ ] verified on staging environment (screenshot attached)
- Loading branch information
1 parent
da71371
commit f3c8cb0
Showing
3 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from datetime import timedelta | ||
|
||
import pytest | ||
from databricks.sdk.errors import NotFound | ||
from databricks.sdk.retries import retried | ||
|
||
|
||
@retried(on=[NotFound], timeout=timedelta(minutes=5)) | ||
@pytest.mark.parametrize( | ||
"prepare_tables_for_migration,workflow", | ||
[ | ||
("regular", "migrate-tables"), | ||
("hiveserde", "migrate-external-hiveserde-tables-in-place-experimental"), | ||
("hiveserde", "migrate-external-tables-ctas"), | ||
], | ||
indirect=("prepare_tables_for_migration",), | ||
) | ||
def test_table_migration_job_refreshes_migration_status(ws, installation_ctx, prepare_tables_for_migration, workflow): | ||
"""The migration status should be refreshed after the migration job.""" | ||
tables, _ = prepare_tables_for_migration | ||
ctx = installation_ctx.replace( | ||
extend_prompts={ | ||
r".*Do you want to update the existing installation?.*": 'yes', | ||
}, | ||
) | ||
|
||
ctx.workspace_installation.run() | ||
ctx.deployed_workflows.run_workflow(workflow) | ||
|
||
for table in tables.values(): | ||
# Avoiding MigrationStatusRefresh as it will refresh the status before fetching | ||
query_migration_status = ( | ||
f"SELECT * FROM {ctx.config.inventory_database}.migration_status " | ||
f"WHERE src_schema = '{table.schema_name}' AND src_table = '{table.name}'" | ||
) | ||
migration_status = list(ctx.sql_backend.fetch(query_migration_status)) | ||
assert_message_postfix = f" found for {table.table_type} {table.full_name}" | ||
assert len(migration_status) == 1, "No migration status found" + assert_message_postfix | ||
assert migration_status[0].dst_schema is not None, "No destination schema" + assert_message_postfix | ||
assert migration_status[0].dst_table is not None, "No destination table" + assert_message_postfix |