@@ -182,8 +182,9 @@ def get_workspace_client(workspace: Workspace) -> WorkspaceClient:
182
182
return acc_client
183
183
184
184
185
- def test_workflow (ws , caplog ):
186
- workflows (ws )
185
+ def test_workflow (ws , caplog ) -> None :
186
+ with caplog .at_level (logging .INFO , logger = 'databricks.labs.ucx' ):
187
+ workflows (ws )
187
188
assert "Fetching deployed jobs..." in caplog .messages
188
189
ws .jobs .list_runs .assert_called ()
189
190
@@ -419,7 +420,7 @@ def test_no_step_in_repair_run(ws, caplog):
419
420
assert '--step is a required parameter' in caplog .messages
420
421
421
422
422
- def test_revert_migrated_tables (ws , caplog ):
423
+ def test_revert_migrated_tables (ws , caplog ) -> None :
423
424
# test with no schema and no table, user confirm to not retry
424
425
prompts = MockPrompts ({'.*' : 'no' })
425
426
ctx = WorkspaceContext (ws ).replace (
@@ -432,7 +433,8 @@ def test_revert_migrated_tables(ws, caplog):
432
433
433
434
# test with no schema and no table, user confirm to retry, but no ucx installation found
434
435
prompts = MockPrompts ({'.*' : 'yes' })
435
- assert revert_migrated_tables (ws , prompts , schema = None , table = None , ctx = ctx ) is None
436
+ with caplog .at_level (logging .INFO , logger = 'databricks.labs.ucx.hive_metastore' ):
437
+ assert revert_migrated_tables (ws , prompts , schema = None , table = None , ctx = ctx ) is None
436
438
assert 'No migrated tables were found.' in caplog .messages
437
439
438
440
@@ -902,22 +904,24 @@ def test_create_catalogs_schemas_handles_existing(ws, caplog) -> None:
902
904
ws .schemas .get .assert_called ()
903
905
904
906
905
- def test_cluster_remap (ws , caplog ):
907
+ def test_cluster_remap (ws , caplog ) -> None :
906
908
prompts = MockPrompts ({"Please provide the cluster id's as comma separated value from the above list.*" : "1" })
907
909
ws .clusters .get .return_value = ClusterDetails (cluster_id = "123" , cluster_name = "test_cluster" )
908
910
ws .clusters .list .return_value = [
909
911
ClusterDetails (cluster_id = "123" , cluster_name = "test_cluster" , cluster_source = ClusterSource .UI ),
910
912
ClusterDetails (cluster_id = "1234" , cluster_name = "test_cluster1" , cluster_source = ClusterSource .JOB ),
911
913
]
912
- cluster_remap (ws , prompts )
914
+ with caplog .at_level (logging .INFO , logger = "databricks.labs.ucx" ):
915
+ cluster_remap (ws , prompts )
913
916
assert "Remapping the Clusters to UC" in caplog .messages
914
917
915
918
916
- def test_cluster_remap_error (ws , caplog ):
919
+ def test_cluster_remap_error (ws , caplog ) -> None :
917
920
prompts = MockPrompts ({"Please provide the cluster id's as comma separated value from the above list.*" : "1" })
918
921
ws .clusters .list .return_value = []
919
922
cluster_remap (ws , prompts )
920
- assert "No cluster information present in the workspace" in caplog .messages
923
+ with caplog .at_level (logging .INFO , logger = "databricks.labs.ucx" ):
924
+ assert "No cluster information present in the workspace" in caplog .messages
921
925
922
926
923
927
def test_revert_cluster_remap (caplog ):
@@ -929,9 +933,10 @@ def test_revert_cluster_remap(caplog):
929
933
revert_cluster_remap (workspace_client , prompts )
930
934
931
935
932
- def test_revert_cluster_remap_empty (ws , caplog ):
936
+ def test_revert_cluster_remap_empty (ws , caplog ) -> None :
933
937
prompts = MockPrompts ({"Please provide the cluster id's as comma separated value from the above list.*" : "1" })
934
- revert_cluster_remap (ws , prompts )
938
+ with caplog .at_level (logging .INFO , logger = "databricks.labs.ucx" ):
939
+ revert_cluster_remap (ws , prompts )
935
940
assert "There is no cluster files in the backup folder. Skipping the reverting process" in caplog .messages
936
941
ws .workspace .list .assert_called_once ()
937
942
@@ -945,7 +950,8 @@ def test_relay_logs(ws, caplog) -> None:
945
950
],
946
951
[ObjectInfo (path = '/Users/foo/.ucx/logs/run-123-1/foo.log-123' )],
947
952
]
948
- logs (ws )
953
+ with caplog .at_level (logging .INFO , logger = "databricks.labs.ucx" ):
954
+ logs (ws )
949
955
assert 'Something is logged' in caplog .messages
950
956
951
957
@@ -965,16 +971,17 @@ def test_migrate_local_code(ws) -> None:
965
971
mock_apply .assert_called_once_with (Path .cwd ())
966
972
967
973
968
- def test_show_all_metastores (acc_client , caplog ):
969
- show_all_metastores (acc_client )
974
+ def test_show_all_metastores (acc_client , caplog ) -> None :
975
+ with caplog .at_level (logging .INFO , logger = "databricks.labs.ucx.account" ):
976
+ show_all_metastores (acc_client )
970
977
assert 'Matching metastores are:' in caplog .messages
971
978
972
979
973
980
def test_assign_metastore_logs_account_id_and_assigns_metastore (caplog , acc_client ) -> None :
974
981
ctx = AccountContext (acc_client )
975
982
acc_client .metastores .list .return_value = [MetastoreInfo (name = "test" , metastore_id = "123" )]
976
983
977
- with caplog .at_level (logging .INFO , logger = "databricks.labs.ucx.cli " ):
984
+ with caplog .at_level (logging .INFO , logger = "databricks.labs.ucx" ):
978
985
assign_metastore (acc_client , "456" , ctx = ctx )
979
986
980
987
assert "Account ID: 123" in caplog .messages
0 commit comments