From a7f1d9f794017e63647317c6208e24331a73c6db Mon Sep 17 00:00:00 2001 From: Chethan UK Date: Sun, 5 Jun 2022 01:11:10 +0100 Subject: [PATCH] AIP-47 - Migrate cassandra DAGs to new design #22439 --- .../apache/cassandra/example_dags/__init__.py | 16 ---------------- .../index.rst | 2 +- .../operators.rst | 2 +- .../apache/cassandra}/example_cassandra_dag.py | 11 ++++++++++- 4 files changed, 12 insertions(+), 19 deletions(-) delete mode 100644 airflow/providers/apache/cassandra/example_dags/__init__.py rename {airflow/providers/apache/cassandra/example_dags => tests/system/providers/apache/cassandra}/example_cassandra_dag.py (85%) diff --git a/airflow/providers/apache/cassandra/example_dags/__init__.py b/airflow/providers/apache/cassandra/example_dags/__init__.py deleted file mode 100644 index 13a83393a9124..0000000000000 --- a/airflow/providers/apache/cassandra/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-apache-cassandra/index.rst b/docs/apache-airflow-providers-apache-cassandra/index.rst index 4f207a2e3f1d5..b23fd6351bd5d 100644 --- a/docs/apache-airflow-providers-apache-cassandra/index.rst +++ b/docs/apache-airflow-providers-apache-cassandra/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-apache-cassandra/operators.rst b/docs/apache-airflow-providers-apache-cassandra/operators.rst index 3b359eff00d23..e0a1e10b559a7 100644 --- a/docs/apache-airflow-providers-apache-cassandra/operators.rst +++ b/docs/apache-airflow-providers-apache-cassandra/operators.rst @@ -50,7 +50,7 @@ Use the ``keys`` parameter to poke until the provided record is found. The exist Example use of these sensors ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. exampleinclude:: /../../airflow/providers/apache/cassandra/example_dags/example_cassandra_dag.py +.. exampleinclude:: /../../tests/system/providers/apache/cassandra/example_cassandra_dag.py :language: python :start-after: [START howto_operator_cassandra_sensors] :end-before: [END howto_operator_cassandra_sensors] diff --git a/airflow/providers/apache/cassandra/example_dags/example_cassandra_dag.py b/tests/system/providers/apache/cassandra/example_cassandra_dag.py similarity index 85% rename from airflow/providers/apache/cassandra/example_dags/example_cassandra_dag.py rename to tests/system/providers/apache/cassandra/example_cassandra_dag.py index bf4067eba083e..d68b5fbe03b7d 100644 --- a/airflow/providers/apache/cassandra/example_dags/example_cassandra_dag.py +++ b/tests/system/providers/apache/cassandra/example_cassandra_dag.py @@ -23,15 +23,19 @@ Example Airflow DAG to check if a Cassandra Table and a Records exists or not using `CassandraTableSensor` and `CassandraRecordSensor`. """ + +import os from datetime import datetime from airflow.models import DAG from airflow.providers.apache.cassandra.sensors.record import CassandraRecordSensor from airflow.providers.apache.cassandra.sensors.table import CassandraTableSensor +ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID") +DAG_ID = "example_cassandra_operator" # [START howto_operator_cassandra_sensors] with DAG( - dag_id='example_cassandra_operator', + dag_id=DAG_ID, schedule_interval=None, start_date=datetime(2021, 1, 1), default_args={'table': 'keyspace_name.table_name'}, @@ -42,3 +46,8 @@ record_sensor = CassandraRecordSensor(task_id="cassandra_record_sensor", keys={"p1": "v1", "p2": "v2"}) # [END howto_operator_cassandra_sensors] + +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)