Skip to content

Commit d9a7d86

Browse files
gmcjygmcjy
authored andcommitted
Added Pytest airflow
1 parent ef7c87d commit d9a7d86

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

dags/Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM python:3.8-slim-buster
2+
3+
WORKDIR /app
4+
5+
# COPY requirements.txt requirements.txt
6+
# RUN pip3 install -r requirements.txt
7+
8+
COPY . .
9+
10+
CMD [ "python3", "-m" , "test.py"]

dags/example_pod.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,23 @@
4444
get_logs=True
4545
)
4646

47+
48+
pytest = KubernetesPodOperator(
49+
namespace='default',
50+
image="python-docker:test",
51+
image_pull_policy="IfNotPresent",
52+
name="Pytest_Abc",
53+
task_id="Python_test",
54+
dag=dag,
55+
is_delete_operator_pod=False,
56+
in_cluster=True,
57+
startup_timeout_seconds=600,
58+
get_logs=True
59+
)
60+
4761
end = DummyOperator(task_id='end', dag=dag, trigger_rule='all_success')
4862

49-
start >> test >> end
63+
start >> test
64+
start >> pytest
65+
pytest >> end
5066

dags/python_print.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: abc-python-cli
5+
spec:
6+
containers:
7+
- name: abc-python-cli
8+
image: python-docker:test
9+
command: ["python3","-m","test"]
10+
imagePullPolicy: IfNotPresent
11+
restartPolicy: Always

dags/test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
if __name__ == '__main__':
3+
print("ABC")
4+
print("*"*100)

0 commit comments

Comments
 (0)