You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2022/06/03 10:33:13 UTC
[airflow] branch main updated: Migrate JDBC example DAGs to new design #22450 (#24137)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 9f7ab0dd0a Migrate JDBC example DAGs to new design #22450 (#24137)
9f7ab0dd0a is described below
commit 9f7ab0dd0a074831448b33a3cbc0de1cd6c3d997
Author: chethanuk-plutoflume <ch...@tessian.com>
AuthorDate: Fri Jun 3 11:33:03 2022 +0100
Migrate JDBC example DAGs to new design #22450 (#24137)
---
airflow/providers/jdbc/example_dags/__init__.py | 16 ----------------
docs/apache-airflow-providers-jdbc/index.rst | 2 +-
docs/apache-airflow-providers-jdbc/operators.rst | 4 ++--
.../system/providers/jdbc}/example_jdbc_queries.py | 17 ++++++++++++++++-
4 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/airflow/providers/jdbc/example_dags/__init__.py b/airflow/providers/jdbc/example_dags/__init__.py
deleted file mode 100644
index 13a83393a9..0000000000
--- a/airflow/providers/jdbc/example_dags/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
diff --git a/docs/apache-airflow-providers-jdbc/index.rst b/docs/apache-airflow-providers-jdbc/index.rst
index c46fc1e43a..2fd17d9d5e 100644
--- a/docs/apache-airflow-providers-jdbc/index.rst
+++ b/docs/apache-airflow-providers-jdbc/index.rst
@@ -39,7 +39,7 @@ Content
:maxdepth: 1
:caption: Resources
- Example DAGs <https://github.com/apache/airflow/tree/main/airflow/providers/jdbc/example_dags>
+ Example DAGs <https://github.com/apache/airflow/tree/main/tests/system/providers/jdbc>
PyPI Repository <https://pypi.org/project/apache-airflow-providers-jdbc/>
Installing from sources <installing-providers-from-sources>
diff --git a/docs/apache-airflow-providers-jdbc/operators.rst b/docs/apache-airflow-providers-jdbc/operators.rst
index f725a3996d..3045f8cb35 100644
--- a/docs/apache-airflow-providers-jdbc/operators.rst
+++ b/docs/apache-airflow-providers-jdbc/operators.rst
@@ -69,7 +69,7 @@ commands against a database (or data storage) accessible via a JDBC driver.
The :doc:`JDBC Connection <connections/jdbc>` must be passed as
``jdbc_conn_id``.
-.. exampleinclude:: /../../airflow/providers/jdbc/example_dags/example_jdbc_queries.py
+.. exampleinclude:: /../../tests/system/providers/jdbc/example_jdbc_queries.py
:language: python
:start-after: [START howto_operator_jdbc]
:end-before: [END howto_operator_jdbc]
@@ -87,7 +87,7 @@ Templating
You can use :ref:`Jinja templates <concepts:jinja-templating>` to parameterize
``sql``.
-.. exampleinclude:: /../../airflow/providers/jdbc/example_dags/example_jdbc_queries.py
+.. exampleinclude:: /../../tests/system/providers/jdbc/example_jdbc_queries.py
:language: python
:start-after: [START howto_operator_jdbc_template]
:end-before: [END howto_operator_jdbc_template]
diff --git a/airflow/providers/jdbc/example_dags/example_jdbc_queries.py b/tests/system/providers/jdbc/example_jdbc_queries.py
similarity index 79%
rename from airflow/providers/jdbc/example_dags/example_jdbc_queries.py
rename to tests/system/providers/jdbc/example_jdbc_queries.py
index 5be0598c4c..2bb5e088db 100644
--- a/airflow/providers/jdbc/example_dags/example_jdbc_queries.py
+++ b/tests/system/providers/jdbc/example_jdbc_queries.py
@@ -18,6 +18,7 @@
"""Example DAG demonstrating the usage of the JdbcOperator."""
+import os
from datetime import datetime, timedelta
from airflow import DAG
@@ -28,8 +29,11 @@ except ModuleNotFoundError:
from airflow.operators.dummy import DummyOperator as EmptyOperator # type: ignore
from airflow.providers.jdbc.operators.jdbc import JdbcOperator
+ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
+DAG_ID = "example_jdbc_operator"
+
with DAG(
- dag_id='example_jdbc_operator',
+ dag_id=DAG_ID,
schedule_interval='0 0 * * *',
start_date=datetime(2021, 1, 1),
dagrun_timeout=timedelta(minutes=60),
@@ -58,3 +62,14 @@ with DAG(
# [END howto_operator_jdbc]
delete_data >> insert_data >> run_this_last
+
+ from tests.system.utils.watcher import watcher
+
+ # This test needs watcher in order to properly mark success/failure
+ # when "tearDown" task with trigger rule is part of the DAG
+ list(dag.tasks) >> watcher()
+
+from tests.system.utils import get_test_run # noqa: E402
+
+# Needed to run the example DAG with pytest (see: tests/system/README.md#run_via_pytest)
+test_run = get_test_run(dag)