예제 #1
0
    def test_execute(self, mock_hook):
        op = CloudDataFusionCreateInstanceOperator(
            task_id="test_taks",
            instance_name=INSTANCE_NAME,
            instance=INSTANCE,
            location=LOCATION,
            project_id=PROJECT_ID,
        )
        op.execute({})

        mock_hook.return_value.create_instance.assert_called_once_with(
            instance_name=INSTANCE_NAME, instance=INSTANCE, location=LOCATION, project_id=PROJECT_ID,
        )
        assert mock_hook.return_value.wait_for_operation.call_count == 1
예제 #2
0
        100,
        "maxConcurrentRuns":
        1,
    },
}
# [END howto_data_fusion_env_variables]

with models.DAG(
        "example_data_fusion",
        schedule_interval='@once',  # Override to match your needs
        start_date=dates.days_ago(1),
) as dag:
    # [START howto_cloud_data_fusion_create_instance_operator]
    create_instance = CloudDataFusionCreateInstanceOperator(
        location=LOCATION,
        instance_name=INSTANCE_NAME,
        instance=INSTANCE,
        task_id="create_instance",
    )
    # [END howto_cloud_data_fusion_create_instance_operator]

    # [START howto_cloud_data_fusion_get_instance_operator]
    get_instance = CloudDataFusionGetInstanceOperator(
        location=LOCATION, instance_name=INSTANCE_NAME, task_id="get_instance")
    # [END howto_cloud_data_fusion_get_instance_operator]

    # [START howto_cloud_data_fusion_restart_instance_operator]
    restart_instance = CloudDataFusionRestartInstanceOperator(
        location=LOCATION,
        instance_name=INSTANCE_NAME,
        task_id="restart_instance")
    # [END howto_cloud_data_fusion_restart_instance_operator]