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

Remove try-except around verifying the migration progress prerequisites in the migrate-tables cli command #3439

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 1 addition & 10 deletions src/databricks/labs/ucx/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,16 +687,7 @@ def migrate_tables(
for workspace_context in workspace_contexts:
deployed_workflows = workspace_context.deployed_workflows

try:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FastLee : You added this in #2929. From the context of the PR and linked issue, I cannot determine why it is added in that PR. Do you remember why?

workspace_context.verify_progress_tracking.verify()
except RuntimeWarning:
logger.warning(
"We couldn't detect a successful run of the assessment workflow."
"The assessment workflow is a prerequisite for the migrate-tables workflow."
"It can be run by using the `ensure-assessment-run` command."
)
return

workspace_context.verify_progress_tracking.verify()
deployed_workflows.run_workflow("migrate-tables")

tables = list(workspace_context.tables_crawler.snapshot())
Expand Down
27 changes: 7 additions & 20 deletions tests/unit/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,28 +1028,15 @@ def test_migrate_tables_calls_migrate_table_job_run_now(
workspace_client.jobs.wait_get_run_job_terminated_or_skipped.assert_called_once()


@pytest.mark.parametrize("run_as_collection", [False, True])
def test_migrate_tables_errors_out_before_assessment(
run_as_collection,
workspace_clients,
acc_client,
) -> None:
if not run_as_collection:
workspace_clients = [workspace_clients[0]]
run = Run(
state=RunState(result_state=RunResultState.SUCCESS),
start_time=0,
end_time=1000,
run_duration=1000,
)
for workspace_client in workspace_clients:
workspace_client.jobs.wait_get_run_job_terminated_or_skipped.return_value = run
workspace_client.jobs.list_runs.return_value = [Run(state=RunState(result_state=RunResultState.FAILED))]
def test_migrate_tables_errors_out_before_assessment(ws, acc_client) -> None:
verify_progress_tracking = create_autospec(VerifyProgressTracking)
verify_progress_tracking.verify.side_effect = RuntimeWarning("Verification failed")
ctx = WorkspaceContext(ws).replace(verify_progress_tracking=verify_progress_tracking)

migrate_tables(workspace_clients[0], MockPrompts({}), run_as_collection=run_as_collection, a=acc_client)
with pytest.raises(RuntimeWarning, match="Verification failed"):
migrate_tables(ws, MockPrompts({}), ctx=ctx, a=acc_client)

for workspace_client in workspace_clients:
workspace_client.jobs.run_now.assert_not_called()
ws.jobs.run_now.assert_not_called()


def test_migrate_tables_calls_external_hiveserde_tables_job_run_now(ws) -> None:
Expand Down
Loading