From ab17d264f9c1cf5a8ee6c2b03217cc6e6e0a760f Mon Sep 17 00:00:00 2001 From: Chethan UK Date: Fri, 3 Jun 2022 00:46:23 +0100 Subject: [PATCH] Migrate Microsoft example DAGs to new design #22452 - winrm --- .../microsoft/winrm/example_dags/__init__.py | 17 ----------------- .../index.rst | 2 +- .../operators.rst | 4 ++-- .../microsoft/winrm}/example_winrm.py | 18 +++++++++++++++++- 4 files changed, 20 insertions(+), 21 deletions(-) delete mode 100644 airflow/providers/microsoft/winrm/example_dags/__init__.py rename {airflow/providers/microsoft/winrm/example_dags => tests/system/providers/microsoft/winrm}/example_winrm.py (82%) diff --git a/airflow/providers/microsoft/winrm/example_dags/__init__.py b/airflow/providers/microsoft/winrm/example_dags/__init__.py deleted file mode 100644 index 217e5db960782..0000000000000 --- a/airflow/providers/microsoft/winrm/example_dags/__init__.py +++ /dev/null @@ -1,17 +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-microsoft-winrm/index.rst b/docs/apache-airflow-providers-microsoft-winrm/index.rst index 5f3d5d148a16e..b33595de7ce64 100644 --- a/docs/apache-airflow-providers-microsoft-winrm/index.rst +++ b/docs/apache-airflow-providers-microsoft-winrm/index.rst @@ -38,7 +38,7 @@ Content :maxdepth: 1 :caption: Resources - Example DAGs + Example DAGs PyPI Repository Installing from sources diff --git a/docs/apache-airflow-providers-microsoft-winrm/operators.rst b/docs/apache-airflow-providers-microsoft-winrm/operators.rst index d35783ec6f8f1..e70d124f6262c 100644 --- a/docs/apache-airflow-providers-microsoft-winrm/operators.rst +++ b/docs/apache-airflow-providers-microsoft-winrm/operators.rst @@ -22,7 +22,7 @@ use the WinRMOperator to execute commands on a given remote host using the winrm create a hook -.. exampleinclude:: /../../airflow/providers/microsoft/winrm/example_dags/example_winrm.py +.. exampleinclude:: /../../tests/system/providers/microsoft/winrm/example_winrm.py :language: python :dedent: 4 :start-after: [START create_hook] @@ -30,7 +30,7 @@ create a hook Run the operator, pass the hook, and pass a command to do something -.. exampleinclude:: /../../airflow/providers/microsoft/winrm/example_dags/example_winrm.py +.. exampleinclude:: /../../tests/system/providers/microsoft/winrm/example_winrm.py :language: python :dedent: 4 :start-after: [START run_operator] diff --git a/airflow/providers/microsoft/winrm/example_dags/example_winrm.py b/tests/system/providers/microsoft/winrm/example_winrm.py similarity index 82% rename from airflow/providers/microsoft/winrm/example_dags/example_winrm.py rename to tests/system/providers/microsoft/winrm/example_winrm.py index f95472989991f..664dfaeda3321 100644 --- a/airflow/providers/microsoft/winrm/example_dags/example_winrm.py +++ b/tests/system/providers/microsoft/winrm/example_winrm.py @@ -26,6 +26,7 @@ """ This is an example dag for using the WinRMOperator. """ +import os from datetime import datetime, timedelta from airflow import DAG @@ -37,8 +38,12 @@ from airflow.providers.microsoft.winrm.hooks.winrm import WinRMHook from airflow.providers.microsoft.winrm.operators.winrm import WinRMOperator + +ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID") +DAG_ID = "POC_winrm_parallel" + with DAG( - dag_id='POC_winrm_parallel', + dag_id=DAG_ID, schedule_interval='0 0 * * *', start_date=datetime(2021, 1, 1), dagrun_timeout=timedelta(minutes=60), @@ -61,3 +66,14 @@ # [END run_operator] [t1, t2, t3] >> 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)