Skip to content

Commit

Permalink
Merge pull request #94 from LamaAni/add_test_fast_logs
Browse files Browse the repository at this point in the history
Add test - logs
  • Loading branch information
LamaAni authored Nov 23, 2023
2 parents d821c97 + 6db038e commit 1afd48a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/dags/templates/test_job.fast_log.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: batch/v1
kind: Job
metadata: {}
spec:
template:
spec:
restartPolicy: Never
containers:
- name: job-executor
image: ubuntu
command:
- bash
- -c
- |
#/bin/bash
echo "Fast print in $SLEEP_INTERVAL seconds"
sleep $SLEEP_INTERVAL
for i in "$(seq 1 $LINE_COUNT)"; do
echo "$i"
done
sleep $SLEEP_INTERVAL
echo "Done"
env:
- name: LINE_COUNT
value: '10000'

- name: SLEEP_INTERVAL
value: '5'
backoffLimit: 0
37 changes: 37 additions & 0 deletions tests/dags/test_fast_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from utils import default_args, name_from_file
from airflow import DAG
from airflow_kubernetes_job_operator.kubernetes_job_operator import (
KubernetesJobOperator,
)

dag = DAG(
name_from_file(__file__),
default_args=default_args,
description="Test base job operator",
schedule_interval=None,
catchup=False,
)

namespace = None

envs = {
"PASS_ARG": "a test",
"JINJA_ENV": "{{ ds }}",
}

default_delete_policy = "IfSucceeded"

# Job
KubernetesJobOperator(
task_id="test-pod-success",
namespace=namespace,
body_filepath="./templates/test_job.fast_log.yaml",
envs=envs,
dag=dag,
delete_policy=default_delete_policy,
)

if __name__ == "__main__":
from tests.test_utils import test_dag

test_dag(dag)

0 comments on commit 1afd48a

Please sign in to comment.