Skip to content

Commit

Permalink
Let migration status test have one assert (#1651)
Browse files Browse the repository at this point in the history
## Changes
Reqwrite migration status test to have one assert in an attempt to
better understand when it fails.

### Linked issues
Hopefully provides more information for #1615

### Functionality 

- [ ] added relevant user documentation
- [ ] added new CLI command
- [ ] modified existing command: `databricks labs ucx ...`
- [ ] added a new workflow
- [ ] modified existing workflow: `...`
- [ ] 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
- [ ] added integration tests
- [ ] verified on staging environment (screenshot attached)
  • Loading branch information
JCZuurmond authored May 7, 2024
1 parent c7298d4 commit c79c9aa
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions tests/integration/hive_metastore/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,23 @@ def test_table_migration_job_refreshes_migration_status(ws, installation_ctx, pr
ctx.workspace_installation.run()
ctx.deployed_workflows.run_workflow(workflow)

asserts = []
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" + 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
if len(migration_status) == 0:
asserts.append("No migration status" + assert_message_postfix)
elif len(migration_status) > 1:
asserts.append("Multiple migration statuses" + assert_message_postfix)
elif migration_status[0].dst_schema is None:
asserts.append("No destination schema" + assert_message_postfix)
elif migration_status[0].dst_table is None:
asserts.append("No destination table" + assert_message_postfix)

assert len(asserts) == 0, "\n".join(asserts)

0 comments on commit c79c9aa

Please sign in to comment.