diff --git a/docs/apache-airflow-providers-apache-hive/index.rst b/docs/apache-airflow-providers-apache-hive/index.rst index b33295d44d931..be62eca2136bb 100644 --- a/docs/apache-airflow-providers-apache-hive/index.rst +++ b/docs/apache-airflow-providers-apache-hive/index.rst @@ -39,7 +39,7 @@ Content :maxdepth: 1 :caption: Resources - Example DAGs + Example DAGs PyPI Repository Installing from sources diff --git a/docs/apache-airflow-providers-apache-hive/operators.rst b/docs/apache-airflow-providers-apache-hive/operators.rst index 4952c8092c027..7a92cba9f2dd1 100644 --- a/docs/apache-airflow-providers-apache-hive/operators.rst +++ b/docs/apache-airflow-providers-apache-hive/operators.rst @@ -27,8 +27,9 @@ HiveOperator This operator executes hql code or hive script in a specific Hive database. -.. exampleinclude:: /../../airflow/providers/apache/hive/example_dags/example_twitter_dag.py +.. exampleinclude:: /../../tests/system/providers/apache/hive/example_twitter_dag.py :language: python + :dedent: 4 :start-after: [START create_hive] :end-before: [END create_hive] diff --git a/airflow/providers/apache/hive/example_dags/__init__.py b/tests/system/providers/apache/__init__.py similarity index 100% rename from airflow/providers/apache/hive/example_dags/__init__.py rename to tests/system/providers/apache/__init__.py diff --git a/tests/system/providers/apache/hive/__init__.py b/tests/system/providers/apache/hive/__init__.py new file mode 100644 index 0000000000000..217e5db960782 --- /dev/null +++ b/tests/system/providers/apache/hive/__init__.py @@ -0,0 +1,17 @@ +# +# 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/airflow/providers/apache/hive/example_dags/example_twitter_README.md b/tests/system/providers/apache/hive/example_twitter_README.md similarity index 100% rename from airflow/providers/apache/hive/example_dags/example_twitter_README.md rename to tests/system/providers/apache/hive/example_twitter_README.md diff --git a/airflow/providers/apache/hive/example_dags/example_twitter_dag.py b/tests/system/providers/apache/hive/example_twitter_dag.py similarity index 91% rename from airflow/providers/apache/hive/example_dags/example_twitter_dag.py rename to tests/system/providers/apache/hive/example_twitter_dag.py index 1110803089800..9e36d3a7c1402 100644 --- a/airflow/providers/apache/hive/example_dags/example_twitter_dag.py +++ b/tests/system/providers/apache/hive/example_twitter_dag.py @@ -26,6 +26,8 @@ """ This is an example dag for managing twitter data. """ + +import os from datetime import date, datetime, timedelta from airflow import DAG @@ -33,6 +35,9 @@ from airflow.operators.bash import BashOperator from airflow.providers.apache.hive.operators.hive import HiveOperator +ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID") +DAG_ID = "example_twitter_dag" + @task def fetch_tweets(): @@ -68,7 +73,7 @@ def transfer_to_db(): with DAG( - dag_id='example_twitter_dag', + dag_id=DAG_ID, default_args={ 'owner': 'Ekhtiar', 'retries': 1, @@ -145,3 +150,14 @@ def transfer_to_db(): ) analyze >> load_to_hdfs >> load_to_hive >> hive_to_mysql + + 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)