fbertos commented on a change in pull request #20485:
URL: https://github.com/apache/airflow/pull/20485#discussion_r777939436
##########
File path: tests/api_connexion/endpoints/test_dag_run_endpoint.py
##########
@@ -163,6 +163,35 @@ def _create_test_dag_run(self, state='running',
extra_dag=False, commit=True):
session.add_all(dags)
return dag_runs
+ def _create_test_dag_run_with_queued(self, commit=True):
+ dag_runs = []
+ dags = [DagModel(dag_id="TEST_DAG_ID")]
+ dagrun_model_1 = DagRun(
+ dag_id="TEST_DAG_ID",
+ run_id="TEST_DAG_RUN_ID_1",
+ run_type=DagRunType.MANUAL,
+ execution_date=timezone.parse(self.default_time),
+ start_date=timezone.parse(self.default_time),
+ external_trigger=True,
+ state='running',
+ )
+ dag_runs.append(dagrun_model_1)
+ dagrun_model_2 = DagRun(
+ dag_id="TEST_DAG_ID",
+ run_id="TEST_DAG_RUN_ID_2",
+ run_type=DagRunType.MANUAL,
+ execution_date=timezone.parse(self.default_time_2),
+ start_date=timezone.parse(self.default_time),
+ external_trigger=True,
+ state='queued',
+ )
+ dag_runs.append(dagrun_model_2)
+ if commit:
+ with create_session() as session:
+ session.add_all(dag_runs)
+ session.add_all(dags)
+ return dag_runs
Review comment:
Hi @ephraimbuddy , If we follow that approach we get these errors:
`E MySQLdb._exceptions.IntegrityError: (1062, "Duplicate entry
'TEST_DAG_ID-2020-06-11 18:00:00.000000' for key
'dag_run_dag_id_execution_date_key'")`
The problem is that the method _create_test_dag_run uses the
self.default_time and self.default_time_2 as execution time statically. So when
we call the method twice, we have a violation of unique index.
To make this dinamically we should change also the way of assigning the
execution dates...
How do you advice to proceed?
Thanks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]