|
33 | 33 | )
|
34 | 34 | from airflow.models import DAG, DagBag
|
35 | 35 | from airflow.providers.google.cloud.links.dataproc import (
|
36 |
| - DATAPROC_CLUSTER_LINK_DEPRECATED, |
37 |
| - DATAPROC_JOB_LINK_DEPRECATED, |
38 | 36 | DataprocClusterLink,
|
39 | 37 | DataprocJobLink,
|
40 | 38 | DataprocWorkflowLink,
|
|
49 | 47 | DataprocGetBatchOperator,
|
50 | 48 | DataprocInstantiateInlineWorkflowTemplateOperator,
|
51 | 49 | DataprocInstantiateWorkflowTemplateOperator,
|
52 |
| - DataprocLink, |
53 | 50 | DataprocListBatchesOperator,
|
54 | 51 | DataprocScaleClusterOperator,
|
55 | 52 | DataprocSubmitHadoopJobOperator,
|
|
242 | 239 | f"project={GCP_PROJECT}"
|
243 | 240 | )
|
244 | 241 | DATAPROC_JOB_CONF_EXPECTED = {
|
245 |
| - "resource": TEST_JOB_ID, |
| 242 | + "job_id": TEST_JOB_ID, |
246 | 243 | "region": GCP_REGION,
|
247 | 244 | "project_id": GCP_PROJECT,
|
248 |
| - "url": DATAPROC_JOB_LINK_DEPRECATED, |
249 | 245 | }
|
250 | 246 | DATAPROC_JOB_EXPECTED = {
|
251 | 247 | "job_id": TEST_JOB_ID,
|
252 | 248 | "region": GCP_REGION,
|
253 | 249 | "project_id": GCP_PROJECT,
|
254 | 250 | }
|
255 | 251 | DATAPROC_CLUSTER_CONF_EXPECTED = {
|
256 |
| - "resource": CLUSTER_NAME, |
| 252 | + "cluster_id": CLUSTER_NAME, |
257 | 253 | "region": GCP_REGION,
|
258 | 254 | "project_id": GCP_PROJECT,
|
259 |
| - "url": DATAPROC_CLUSTER_LINK_DEPRECATED, |
260 | 255 | }
|
261 | 256 | DATAPROC_CLUSTER_EXPECTED = {
|
262 | 257 | "cluster_id": CLUSTER_NAME,
|
@@ -781,7 +776,9 @@ class TestDataprocClusterScaleOperator(DataprocClusterTestBase):
|
781 | 776 | def setup_class(cls):
|
782 | 777 | super().setup_class()
|
783 | 778 | cls.extra_links_expected_calls_base = [
|
784 |
| - call.ti.xcom_push(execution_date=None, key="conf", value=DATAPROC_CLUSTER_CONF_EXPECTED) |
| 779 | + call.ti.xcom_push( |
| 780 | + execution_date=None, key="dataproc_cluster", value=DATAPROC_CLUSTER_CONF_EXPECTED |
| 781 | + ) |
785 | 782 | ]
|
786 | 783 |
|
787 | 784 | def test_deprecation_warning(self):
|
@@ -827,7 +824,7 @@ def test_execute(self, mock_hook):
|
827 | 824 | self.extra_links_manager_mock.assert_has_calls(expected_calls, any_order=False)
|
828 | 825 |
|
829 | 826 | self.mock_ti.xcom_push.assert_called_once_with(
|
830 |
| - key="conf", |
| 827 | + key="dataproc_cluster", |
831 | 828 | value=DATAPROC_CLUSTER_CONF_EXPECTED,
|
832 | 829 | execution_date=None,
|
833 | 830 | )
|
@@ -855,28 +852,28 @@ def test_scale_cluster_operator_extra_links(dag_maker, create_task_instance_of_o
|
855 | 852 |
|
856 | 853 | # Assert operator links for serialized DAG
|
857 | 854 | assert serialized_dag["dag"]["tasks"][0]["_operator_extra_links"] == [
|
858 |
| - {"airflow.providers.google.cloud.links.dataproc.DataprocLink": {}} |
| 855 | + {"airflow.providers.google.cloud.links.dataproc.DataprocClusterLink": {}} |
859 | 856 | ]
|
860 | 857 |
|
861 | 858 | # Assert operator link types are preserved during deserialization
|
862 |
| - assert isinstance(deserialized_task.operator_extra_links[0], DataprocLink) |
| 859 | + assert isinstance(deserialized_task.operator_extra_links[0], DataprocClusterLink) |
863 | 860 |
|
864 | 861 | # Assert operator link is empty when no XCom push occurred
|
865 |
| - assert ti.task.get_extra_links(ti, DataprocLink.name) == "" |
| 862 | + assert ti.task.get_extra_links(ti, DataprocClusterLink.name) == "" |
866 | 863 |
|
867 | 864 | # Assert operator link is empty for deserialized task when no XCom push occurred
|
868 |
| - assert deserialized_task.get_extra_links(ti, DataprocLink.name) == "" |
| 865 | + assert deserialized_task.get_extra_links(ti, DataprocClusterLink.name) == "" |
869 | 866 |
|
870 | 867 | ti.xcom_push(
|
871 | 868 | key="conf",
|
872 | 869 | value=DATAPROC_CLUSTER_CONF_EXPECTED,
|
873 | 870 | )
|
874 | 871 |
|
875 | 872 | # Assert operator links are preserved in deserialized tasks after execution
|
876 |
| - assert deserialized_task.get_extra_links(ti, DataprocLink.name) == DATAPROC_CLUSTER_LINK_EXPECTED |
| 873 | + assert deserialized_task.get_extra_links(ti, DataprocClusterLink.name) == DATAPROC_CLUSTER_LINK_EXPECTED |
877 | 874 |
|
878 | 875 | # Assert operator links after execution
|
879 |
| - assert ti.task.get_extra_links(ti, DataprocLink.name) == DATAPROC_CLUSTER_LINK_EXPECTED |
| 876 | + assert ti.task.get_extra_links(ti, DataprocClusterLink.name) == DATAPROC_CLUSTER_LINK_EXPECTED |
880 | 877 |
|
881 | 878 |
|
882 | 879 | class TestDataprocClusterDeleteOperator:
|
@@ -1817,7 +1814,7 @@ class TestDataProcSparkOperator(DataprocJobTestBase):
|
1817 | 1814 | @classmethod
|
1818 | 1815 | def setup_class(cls):
|
1819 | 1816 | cls.extra_links_expected_calls = [
|
1820 |
| - call.ti.xcom_push(execution_date=None, key="conf", value=DATAPROC_JOB_CONF_EXPECTED), |
| 1817 | + call.ti.xcom_push(execution_date=None, key="dataproc_job", value=DATAPROC_JOB_CONF_EXPECTED), |
1821 | 1818 | call.hook().wait_for_job(job_id=TEST_JOB_ID, region=GCP_REGION, project_id=GCP_PROJECT),
|
1822 | 1819 | ]
|
1823 | 1820 |
|
@@ -1864,7 +1861,7 @@ def test_execute(self, mock_hook, mock_uuid):
|
1864 | 1861 |
|
1865 | 1862 | op.execute(context=self.mock_context)
|
1866 | 1863 | self.mock_ti.xcom_push.assert_called_once_with(
|
1867 |
| - key="conf", value=DATAPROC_JOB_CONF_EXPECTED, execution_date=None |
| 1864 | + key="dataproc_job", value=DATAPROC_JOB_CONF_EXPECTED, execution_date=None |
1868 | 1865 | )
|
1869 | 1866 |
|
1870 | 1867 | # Test whether xcom push occurs before polling for job
|
@@ -1893,25 +1890,25 @@ def test_submit_spark_job_operator_extra_links(mock_hook, dag_maker, create_task
|
1893 | 1890 |
|
1894 | 1891 | # Assert operator links for serialized DAG
|
1895 | 1892 | assert serialized_dag["dag"]["tasks"][0]["_operator_extra_links"] == [
|
1896 |
| - {"airflow.providers.google.cloud.links.dataproc.DataprocLink": {}} |
| 1893 | + {"airflow.providers.google.cloud.links.dataproc.DataprocJobLink": {}} |
1897 | 1894 | ]
|
1898 | 1895 |
|
1899 | 1896 | # Assert operator link types are preserved during deserialization
|
1900 |
| - assert isinstance(deserialized_task.operator_extra_links[0], DataprocLink) |
| 1897 | + assert isinstance(deserialized_task.operator_extra_links[0], DataprocJobLink) |
1901 | 1898 |
|
1902 | 1899 | # Assert operator link is empty when no XCom push occurred
|
1903 |
| - assert ti.task.get_extra_links(ti, DataprocLink.name) == "" |
| 1900 | + assert ti.task.get_extra_links(ti, DataprocJobLink.name) == "" |
1904 | 1901 |
|
1905 | 1902 | # Assert operator link is empty for deserialized task when no XCom push occurred
|
1906 |
| - assert deserialized_task.get_extra_links(ti, DataprocLink.name) == "" |
| 1903 | + assert deserialized_task.get_extra_links(ti, DataprocJobLink.name) == "" |
1907 | 1904 |
|
1908 | 1905 | ti.xcom_push(key="conf", value=DATAPROC_JOB_CONF_EXPECTED)
|
1909 | 1906 |
|
1910 | 1907 | # Assert operator links after task execution
|
1911 |
| - assert ti.task.get_extra_links(ti, DataprocLink.name) == DATAPROC_JOB_LINK_EXPECTED |
| 1908 | + assert ti.task.get_extra_links(ti, DataprocJobLink.name) == DATAPROC_JOB_LINK_EXPECTED |
1912 | 1909 |
|
1913 | 1910 | # Assert operator links are preserved in deserialized tasks
|
1914 |
| - link = deserialized_task.get_extra_links(ti, DataprocLink.name) |
| 1911 | + link = deserialized_task.get_extra_links(ti, DataprocJobLink.name) |
1915 | 1912 | assert link == DATAPROC_JOB_LINK_EXPECTED
|
1916 | 1913 |
|
1917 | 1914 |
|
|
0 commit comments