Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIRFLOW-6957] Make retrieving Paused Dag ids a separate method #7587

Merged
merged 1 commit into from
Feb 28, 2020

Conversation

kaxil
Copy link
Member

@kaxil kaxil commented Feb 28, 2020

Separating it out to a method makes it easy to test "just that" functionality.


Issue link: AIRFLOW-6957

Make sure to mark the boxes below before creating PR: [x]

  • Description above provides context of the change
  • Commit message/PR title starts with [AIRFLOW-NNNN]. AIRFLOW-NNNN = JIRA ID*
  • Unit tests coverage for changes (not needed for documentation changes)
  • Commits follow "How to write a good git commit message"
  • Relevant documentation is updated including usage instructions.
  • I will engage committers as explained in Contribution Workflow Example.

* For document-only changes commit message can start with [AIRFLOW-XXXX].


In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.
Read the Pull Request Guidelines for more information.

@kaxil kaxil requested a review from mik-laj February 28, 2020 13:08
@boring-cyborg boring-cyborg bot added the area:Scheduler including HA (high availability) scheduler label Feb 28, 2020
@mik-laj
Copy link
Member

mik-laj commented Feb 28, 2020

Can you also add a test that checks if the DagFileProcessor ignores these DAGs? This is the core, and it's worth one more test than not having it.

@kaxil
Copy link
Member Author

kaxil commented Feb 28, 2020

Can you also add a test that checks if the DagFileProcessor ignores these DAGs? This is the core, and it's worth one more test than not having it.

We already have other cases covered:

def test_find_dags_to_run_skip_paused_dags(self):
dagbag = DagBag(include_examples=False)
dag = dagbag.get_dag('test_subdag_operator')
dag_file_processor = DagFileProcessor(dag_ids=[], log=mock.MagicMock())
dags = dag_file_processor._find_dags_to_process(dagbag.dags.values(), paused_dag_ids=[dag.dag_id])
self.assertNotIn(dag, dags)

and

def test_execute_task_instances_is_paused_wont_execute(self):
dag_id = 'SchedulerJobTest.test_execute_task_instances_is_paused_wont_execute'
task_id_1 = 'dummy_task'
dag = DAG(dag_id=dag_id, start_date=DEFAULT_DATE)
task1 = DummyOperator(dag=dag, task_id=task_id_1)
dagbag = self._make_simple_dag_bag([dag])
dag_file_processor = DagFileProcessor(dag_ids=[], log=mock.MagicMock())
scheduler = SchedulerJob()
session = settings.Session()
dr1 = dag_file_processor.create_dag_run(dag)
ti1 = TaskInstance(task1, DEFAULT_DATE)
ti1.state = State.SCHEDULED
dr1.state = State.RUNNING
dagmodel = DagModel()
dagmodel.dag_id = dag_id
dagmodel.is_paused = True
session.merge(ti1)
session.merge(dr1)
session.add(dagmodel)
session.commit()
scheduler._execute_task_instances(dagbag)
ti1.refresh_from_db()
self.assertEqual(State.SCHEDULED, ti1.state)

The bug in the last PR was we were not checking how the results were returned from the query which this PR adds.

@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@847cb40). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #7587   +/-   ##
=========================================
  Coverage          ?   86.58%           
=========================================
  Files             ?      896           
  Lines             ?    42624           
  Branches          ?        0           
=========================================
  Hits              ?    36905           
  Misses            ?     5719           
  Partials          ?        0
Impacted Files Coverage Δ
airflow/jobs/scheduler_job.py 90.46% <100%> (ø)
airflow/models/dag.py 91.57% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 847cb40...f094e29. Read the comment docs.

@kaxil kaxil merged commit a887e0a into apache:master Feb 28, 2020
@kaxil kaxil deleted the AIRFLOW-6856]--bugfix branch February 28, 2020 14:23
galuszkak pushed a commit to FlyrInc/apache-airflow that referenced this pull request Mar 5, 2020
@potiuk potiuk added this to the Airflow 1.10.11 milestone Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Scheduler including HA (high availability) scheduler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants