Skip to content

Commit c3a9ef1

Browse files
authored
AIP-47 - Migrate google leveldb DAGs to new design ##22447 (#24233)
1 parent c238269 commit c3a9ef1

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

β€Ždocs/apache-airflow-providers-google/operators/leveldb/leveldb.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Put key
3636
Get, put, delete key or write_batch, create database with comparator or different options in LevelDB is performed with the
3737
:class:`~airflow.providers.google.leveldb.operators.leveldb.LevelDBOperator` operator.
3838

39-
.. exampleinclude:: /../../airflow/providers/google/leveldb/example_dags/example_leveldb.py
39+
.. exampleinclude:: /../../tests/system/providers/google/leveldb/example_leveldb.py
4040
:language: python
4141
:dedent: 4
4242
:start-after: [START howto_operator_leveldb_put_key]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.

β€Žairflow/providers/google/leveldb/example_dags/example_leveldb.py renamed to β€Žtests/system/providers/google/leveldb/example_leveldb.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@
1919
Example use of LevelDB operators.
2020
"""
2121

22+
import os
2223
from datetime import datetime
2324

2425
from airflow import models
2526
from airflow.providers.google.leveldb.operators.leveldb import LevelDBOperator
27+
from airflow.utils.trigger_rule import TriggerRule
28+
29+
ENV_ID = os.environ.get("SYSTEM_TESTS_ENV_ID")
30+
DAG_ID = "example_leveldb"
2631

2732
with models.DAG(
28-
'example_leveldb',
33+
DAG_ID,
2934
start_date=datetime(2021, 1, 1),
3035
schedule_interval='@once',
3136
catchup=False,
@@ -40,6 +45,19 @@
4045
command='put',
4146
key=b'another_key',
4247
value=b'another_value',
48+
trigger_rule=TriggerRule.ALL_DONE,
4349
)
4450
# [END howto_operator_leveldb_put_key]
4551
get_key_leveldb_task >> put_key_leveldb_task
52+
53+
from tests.system.utils.watcher import watcher
54+
55+
# This test needs watcher in order to properly mark success/failure
56+
# when "tearDown" task with trigger rule is part of the DAG
57+
list(dag.tasks) >> watcher()
58+
59+
60+
from tests.system.utils import get_test_run # noqa: E402
61+
62+
# Needed to run the example DAG with pytest (see: tests/system/README.md#run_via_pytest)
63+
test_run = get_test_run(dag)

0 commit comments

Comments
 (0)