File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ import datetime as dt
2+
3+ from databricks .labs .ucx .progress .workflow_runs import WorkflowRunRecorder
4+
5+
6+ def test_workflow_run_record_records_workflow_run (mock_backend ) -> None :
7+ """Ensure that the workflow run recorder records a workflow run"""
8+ start_time = dt .datetime .now (tz = dt .timezone .utc ).replace (microsecond = 0 )
9+ workflow_run_recorder = WorkflowRunRecorder (
10+ mock_backend ,
11+ ucx_catalog = "ucx" ,
12+ workspace_id = 123456789 ,
13+ workflow_name = "workflow" ,
14+ workflow_id = 123 ,
15+ workflow_run_id = 456 ,
16+ workflow_run_attempt = 0 ,
17+ workflow_start_time = start_time .isoformat (),
18+ )
19+
20+ workflow_run_recorder .record ()
21+
22+ rows = mock_backend .rows_written_for ("ucx.multiworkspace.workflow_runs" , "append" )
23+ assert len (rows ) == 1
24+ assert rows [0 ].started_at == start_time
25+ assert start_time <= rows [0 ].finished_at <= dt .datetime .now (tz = dt .timezone .utc )
26+ assert rows [0 ].workspace_id == 123456789
27+ assert rows [0 ].workflow_name == "workflow"
28+ assert rows [0 ].workflow_id == 123
29+ assert rows [0 ].workflow_run_id == 456
30+ assert rows [0 ].workflow_run_attempt == 0
31+
You can’t perform that action at this time.
0 commit comments