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 d4aca43755 Migrate Influx example DAGs to new design #22449 (#24136)
d4aca43755 is described below
commit d4aca43755ece282f9488581a8052c2b92b01f73
Author: chethanuk-plutoflume <[email protected]>
AuthorDate: Fri Jun 3 17:10:42 2022 +0100
Migrate Influx example DAGs to new design #22449 (#24136)
* Migrate Influx example DAGs to new design #22449
* Fix static checks
---
.../providers/influxdb/example_dags/__init__.py | 16 -----------
docs/apache-airflow-providers-influxdb/index.rst | 2 +-
.../operators/index.rst | 2 +-
.../system/providers/influxdb}/example_influxdb.py | 17 +++++++++++-
.../providers/influxdb}/example_influxdb_query.py | 31 ++++++++++++++--------
5 files changed, 38 insertions(+), 30 deletions(-)
diff --git a/airflow/providers/influxdb/example_dags/__init__.py
b/airflow/providers/influxdb/example_dags/__init__.py
deleted file mode 100644
index 13a83393a9..0000000000
--- a/airflow/providers/influxdb/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-influxdb/index.rst
b/docs/apache-airflow-providers-influxdb/index.rst
index 120b0a1368..fcb348da12 100644
--- a/docs/apache-airflow-providers-influxdb/index.rst
+++ b/docs/apache-airflow-providers-influxdb/index.rst
@@ -39,7 +39,7 @@ Content
:maxdepth: 1
:caption: Resources
- Example DAGs
<https://github.com/apache/airflow/tree/main/airflow/providers/influxdb/example_dags>
+ Example DAGs
<https://github.com/apache/airflow/tree/main/tests/system/providers/influxdb>
.. toctree::
:maxdepth: 1
diff --git a/docs/apache-airflow-providers-influxdb/operators/index.rst
b/docs/apache-airflow-providers-influxdb/operators/index.rst
index 03427b1a1e..95bccce128 100644
--- a/docs/apache-airflow-providers-influxdb/operators/index.rst
+++ b/docs/apache-airflow-providers-influxdb/operators/index.rst
@@ -27,7 +27,7 @@ SQL commands in a `InfluxDB <https://www.influxdata.com/>`__
database.
An example of running the query using the operator:
-.. exampleinclude::
/../../airflow/providers/influxdb/example_dags/example_influxdb_query.py
+.. exampleinclude::
/../../tests/system/providers/influxdb/example_influxdb_query.py
:language: python
:start-after: [START howto_operator_influxdb]
:end-before: [END howto_operator_influxdb]
diff --git a/airflow/providers/influxdb/example_dags/example_influxdb.py
b/tests/system/providers/influxdb/example_influxdb.py
similarity index 79%
rename from airflow/providers/influxdb/example_dags/example_influxdb.py
rename to tests/system/providers/influxdb/example_influxdb.py
index a6c160ea2f..f6f89553df 100644
--- a/airflow/providers/influxdb/example_dags/example_influxdb.py
+++ b/tests/system/providers/influxdb/example_influxdb.py
@@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.
+import os
from datetime import datetime
from airflow.decorators import task
@@ -47,11 +48,25 @@ def test_influxdb_hook():
influxdb_hook.delete_bucket(bucket_name)
+ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
+DAG_ID = "influxdb_example_dag"
+
with DAG(
- dag_id='influxdb_example_dag',
+ dag_id=DAG_ID,
schedule_interval=None,
start_date=datetime(2021, 1, 1),
max_active_runs=1,
tags=['example'],
) as dag:
test_influxdb_hook()
+
+ 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)
diff --git a/airflow/providers/influxdb/example_dags/example_influxdb_query.py
b/tests/system/providers/influxdb/example_influxdb_query.py
similarity index 62%
rename from airflow/providers/influxdb/example_dags/example_influxdb_query.py
rename to tests/system/providers/influxdb/example_influxdb_query.py
index 21b6e8fbf5..5db470af5a 100644
--- a/airflow/providers/influxdb/example_dags/example_influxdb_query.py
+++ b/tests/system/providers/influxdb/example_influxdb_query.py
@@ -15,25 +15,34 @@
# specific language governing permissions and limitations
# under the License.
+import os
from datetime import datetime
from airflow.models.dag import DAG
from airflow.providers.influxdb.operators.influxdb import InfluxDBOperator
-dag = DAG(
- 'example_influxdb_operator',
+ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
+DAG_ID = "example_influxdb_operator"
+
+with DAG(
+ DAG_ID,
start_date=datetime(2021, 1, 1),
tags=['example'],
catchup=False,
-)
+) as dag:
+
+ # [START howto_operator_influxdb]
+
+ query_influxdb_task = InfluxDBOperator(
+ influxdb_conn_id='influxdb_conn_id',
+ task_id='query_influxdb',
+ sql='from(bucket:"test-influx") |> range(start: -10m, stop: {{ds}})',
+ dag=dag,
+ )
-# [START howto_operator_influxdb]
+ # [END howto_operator_influxdb]
-query_influxdb_task = InfluxDBOperator(
- influxdb_conn_id='influxdb_conn_id',
- task_id='query_influxdb',
- sql='from(bucket:"test-influx") |> range(start: -10m, stop: {{ds}})',
- dag=dag,
-)
+from tests.system.utils import get_test_run # noqa: E402
-# [END howto_operator_influxdb]
+# Needed to run the example DAG with pytest (see:
tests/system/README.md#run_via_pytest)
+test_run = get_test_run(dag)