|
4 | 4 |
|
5 | 5 | from databricks.labs.lsql.backends import MockBackend
|
6 | 6 | from databricks.sdk.service.jobs import BaseJob, JobSettings, Task, PipelineTask
|
| 7 | +from databricks.sdk.errors import NotFound |
7 | 8 |
|
8 | 9 | from databricks.labs.ucx.assessment.jobs import JobsCrawler
|
9 | 10 | from databricks.labs.ucx.assessment.pipelines import PipelinesCrawler
|
@@ -91,14 +92,30 @@ def test_migrate_pipelines(ws, mock_installation, pipeline_spec, include_flag, e
|
91 | 92 | ws.api_client.do.assert_has_calls([api_calls])
|
92 | 93 |
|
93 | 94 |
|
94 |
| -def test_migrate_pipelines_no_pipelines( |
95 |
| - ws, |
96 |
| -): |
97 |
| - errors = {} |
98 |
| - rows = {} |
99 |
| - sql_backend = MockBackend(fails_on_first=errors, rows=rows) |
| 95 | +def test_migrate_pipelines_no_pipelines(ws) -> None: |
| 96 | + sql_backend = MockBackend() |
100 | 97 | pipelines_crawler = PipelinesCrawler(ws, sql_backend, "inventory_database")
|
101 | 98 | jobs_crawler = JobsCrawler(ws, sql_backend, "inventory_database")
|
102 | 99 | pipelines_migrator = PipelinesMigrator(ws, pipelines_crawler, jobs_crawler, "catalog_name")
|
103 | 100 | ws.jobs.list.return_value = [BaseJob(job_id=536591785949415), BaseJob(), BaseJob(job_id=536591785949417)]
|
104 | 101 | pipelines_migrator.migrate_pipelines()
|
| 102 | + |
| 103 | + |
| 104 | +def test_migrate_pipelines_skips_not_found_job(caplog, ws) -> None: |
| 105 | + job_columns = MockBackend.rows("job_id", "success", "failures", "job_name", "creator") |
| 106 | + sql_backend = MockBackend( |
| 107 | + rows={ |
| 108 | + "`hive_metastore`.`inventory_database`.`jobs`": job_columns[ |
| 109 | + ("536591785949415", 1, [], "single-job", "anonymous@databricks.com") |
| 110 | + ] |
| 111 | + } |
| 112 | + ) |
| 113 | + pipelines_crawler = PipelinesCrawler(ws, sql_backend, "inventory_database") |
| 114 | + jobs_crawler = JobsCrawler(ws, sql_backend, "inventory_database") |
| 115 | + pipelines_migrator = PipelinesMigrator(ws, pipelines_crawler, jobs_crawler, "catalog_name") |
| 116 | + |
| 117 | + ws.jobs.get.side_effect = NotFound |
| 118 | + |
| 119 | + with caplog.at_level(logging.WARNING, logger="databricks.labs.ucx.hive_metastore.pipelines_migrate"): |
| 120 | + pipelines_migrator.migrate_pipelines() |
| 121 | + assert "Skipping non-existing job: 536591785949415" in caplog.messages |
0 commit comments