From db49239a4cdcc0956b5601c50138d1f072ac113a Mon Sep 17 00:00:00 2001 From: DonHaul Date: Tue, 30 Jul 2024 10:09:16 +0200 Subject: [PATCH] user actions: make it independent from django --- .../backoffice/workflows/airflow_utils.py | 40 +++++++++------- backoffice/backoffice/workflows/api/views.py | 4 +- backoffice/backoffice/workflows/constants.py | 1 - ...AirflowUtils.test_delete_workflow_dag.yaml | 14 +++--- ...tAirflowUtils.test_find_executed_dags.yaml | 33 +++++++------ ...TestAirflowUtils.test_find_failed_dag.yaml | 30 ++++++------ ...irflowUtils.test_restart_failed_tasks.yaml | 48 +++++++++---------- ...rflowUtils.test_restart_workflow_dags.yaml | 38 +++++++-------- ...AirflowUtils.test_trigger_airflow_dag.yaml | 12 ++--- ...horWorkflowViewSet.test_accept_author.yaml | 26 +++++----- ...horWorkflowViewSet.test_create_author.yaml | 18 +++---- ...horWorkflowViewSet.test_reject_author.yaml | 26 +++++----- .../backoffice/workflows/tests/conftest.py | 7 --- .../workflows/tests/test_airflow_utils.py | 36 +++++++------- 14 files changed, 171 insertions(+), 162 deletions(-) diff --git a/backoffice/backoffice/workflows/airflow_utils.py b/backoffice/backoffice/workflows/airflow_utils.py index d97ef4b4..2e459800 100644 --- a/backoffice/backoffice/workflows/airflow_utils.py +++ b/backoffice/backoffice/workflows/airflow_utils.py @@ -49,25 +49,34 @@ def trigger_airflow_dag(dag_id, workflow_id, extra_data=None): return JsonResponse(data, status=status.HTTP_502_BAD_GATEWAY) -def restart_failed_tasks(workflow): +def restart_failed_tasks(workflow_id, workflow_type): """Restarts failed tasks of an airflow dag. :param workflow: workflow whooses tasks should be restarted :returns: request response """ - dag_id = find_failed_dag(workflow) + dag_id = find_failed_dag(workflow_id, workflow_type) # assumes current task is one of the failed tasks data = { "dry_run": False, - "dag_run_id": str(workflow.id), + "dag_run_id": str(workflow_id), "reset_dag_runs": False, "only_failed": True, } + url = f"{AIRFLOW_BASE_URL}/api/v1/dags/{dag_id}/clearTaskInstances" + try: + logger.info( + "Clearing Failed Tasks of DAG %s with data: %s and %s %s", + dag_id, + data, + AIRFLOW_HEADERS, + url, + ) response = requests.post( - f"{AIRFLOW_BASE_URL}/api/v1/dags/{dag_id}/clearTaskInstances", + url, json=data, headers=AIRFLOW_HEADERS, ) @@ -78,7 +87,7 @@ def restart_failed_tasks(workflow): return JsonResponse(data, status=status.HTTP_424_FAILED_DEPENDENCY) -def find_executed_dags(workflow): +def find_executed_dags(workflow_id, workflow_type): """For a given workflow find dags associated to it :param workflow: workflow to look dags for @@ -87,9 +96,9 @@ def find_executed_dags(workflow): executed_dags_for_workflow = {} # find dags that were executed - for dag_id in WORKFLOW_DAGS[workflow.workflow_type]: + for dag_id in WORKFLOW_DAGS[workflow_type]: response = requests.get( - f"{AIRFLOW_BASE_URL}/api/v1/dags/{dag_id}/dagRuns/{workflow.id}", + f"{AIRFLOW_BASE_URL}/api/v1/dags/{dag_id}/dagRuns/{workflow_id}", headers=AIRFLOW_HEADERS, ) if response.status_code == status.HTTP_200_OK: @@ -98,21 +107,21 @@ def find_executed_dags(workflow): return executed_dags_for_workflow -def find_failed_dag(workflow): +def find_failed_dag(workflow_id, workflow_type): """For a given workflow find failed dags :param workflow: workflow to get failed dags :returns: failed dag id or none """ - executed_dags_for_workflow = find_executed_dags(workflow) + executed_dags_for_workflow = find_executed_dags(workflow_id, workflow_type) for dag, dag_data in executed_dags_for_workflow.items(): if dag_data["state"] == "failed": return dag -def delete_workflow_dag(dag_id, workflow): +def delete_workflow_dag(dag_id, workflow_id): """Delete dag run :param dag_id: dag to be removed :param workflow: workflow with the dag execution to be deleted @@ -120,7 +129,7 @@ def delete_workflow_dag(dag_id, workflow): """ try: response = requests.delete( - f"{AIRFLOW_BASE_URL}/api/v1/dags/{dag_id}/dagRuns/{str(workflow.id)}", + f"{AIRFLOW_BASE_URL}/api/v1/dags/{dag_id}/dagRuns/{str(workflow_id)}", headers=AIRFLOW_HEADERS, ) response.raise_for_status() @@ -129,21 +138,20 @@ def delete_workflow_dag(dag_id, workflow): return HttpResponse(status=status.HTTP_424_FAILED_DEPENDENCY) -def restart_workflow_dags(workflow, params=None): +def restart_workflow_dags(workflow_id, workflow_type, params=None): """Restarts dags of a given workflow. :param workflow: workflow whoose dags should be restarted :param params: parameters of new dag execution :returns: request response """ - executed_dags_for_workflow = find_executed_dags(workflow) + executed_dags_for_workflow = find_executed_dags(workflow_id, workflow_type) for dag_id in executed_dags_for_workflow: - # delete all executions of workflow - delete_workflow_dag(dag_id, workflow) + delete_workflow_dag(dag_id, workflow_id) return trigger_airflow_dag( - WORKFLOW_DAGS[workflow.workflow_type][0], str(workflow.id), params + WORKFLOW_DAGS[workflow_type][0], str(workflow_id), params ) return JsonResponse( diff --git a/backoffice/backoffice/workflows/api/views.py b/backoffice/backoffice/workflows/api/views.py index 2e730b93..97b66cfc 100644 --- a/backoffice/backoffice/workflows/api/views.py +++ b/backoffice/backoffice/workflows/api/views.py @@ -134,7 +134,9 @@ def restart(self, request, pk=None): if request.data.get("restart_current_task"): return airflow_utils.restart_failed_tasks(workflow) - return airflow_utils.restart_workflow_dags(workflow, request.data.get("params")) + return airflow_utils.restart_workflow_dags( + workflow.id, workflow.workflow_type, request.data.get("params") + ) class WorkflowDocumentView(BaseDocumentViewSet): diff --git a/backoffice/backoffice/workflows/constants.py b/backoffice/backoffice/workflows/constants.py index a8a122b3..c6863a47 100644 --- a/backoffice/backoffice/workflows/constants.py +++ b/backoffice/backoffice/workflows/constants.py @@ -35,7 +35,6 @@ class ResolutionDags(models.TextChoices): reject = "reject", "author_create_rejected_dag" -# author dags for each workflow type WORKFLOW_DAGS = { WorkflowType.HEP_CREATE: "", WorkflowType.HEP_UPDATE: "", diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_delete_workflow_dag.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_delete_workflow_dag.yaml index b0f11bf3..dd1bf454 100644 --- a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_delete_workflow_dag.yaml +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_delete_workflow_dag.yaml @@ -19,10 +19,10 @@ interactions: body: string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-29T14:36:10.637820+00:00\",\n - \ \"data_interval_start\": \"2024-07-29T14:36:10.637820+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-29T14:36:10.637820+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-29T14:36:10.637820+00:00\",\n + \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:29:54.362977+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T08:29:54.362977+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T08:29:54.362977+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T08:29:54.362977+00:00\",\n \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \ \"state\": \"queued\"\n}\n" headers: @@ -33,7 +33,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:10 GMT + - Tue, 30 Jul 2024 08:29:54 GMT Server: - gunicorn X-Robots-Tag: @@ -65,7 +65,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:10 GMT + - Tue, 30 Jul 2024 08:29:54 GMT Server: - gunicorn X-Robots-Tag: @@ -101,7 +101,7 @@ interactions: Content-Type: - application/problem+json Date: - - Mon, 29 Jul 2024 14:36:10 GMT + - Tue, 30 Jul 2024 08:29:54 GMT Server: - gunicorn X-Robots-Tag: diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_find_executed_dags.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_find_executed_dags.yaml index 9d3f2352..84cb5ffc 100644 --- a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_find_executed_dags.yaml +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_find_executed_dags.yaml @@ -19,10 +19,10 @@ interactions: body: string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-29T14:36:10.935128+00:00\",\n - \ \"data_interval_start\": \"2024-07-29T14:36:10.935128+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-29T14:36:10.935128+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-29T14:36:10.935128+00:00\",\n + \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:29:54.646527+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T08:29:54.646527+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T08:29:54.646527+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T08:29:54.646527+00:00\",\n \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \ \"state\": \"queued\"\n}\n" headers: @@ -33,7 +33,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:10 GMT + - Tue, 30 Jul 2024 08:29:54 GMT Server: - gunicorn X-Robots-Tag: @@ -58,22 +58,21 @@ interactions: body: string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-29T14:36:10.935128+00:00\",\n - \ \"data_interval_start\": \"2024-07-29T14:36:10.935128+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-29T14:36:10.935128+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": \"2024-07-29T14:36:10.979214+00:00\",\n - \ \"logical_date\": \"2024-07-29T14:36:10.935128+00:00\",\n \"note\": null,\n - \ \"run_type\": \"manual\",\n \"start_date\": \"2024-07-29T14:36:10.977019+00:00\",\n - \ \"state\": \"running\"\n}\n" + \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:29:54.646527+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T08:29:54.646527+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T08:29:54.646527+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T08:29:54.646527+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" headers: Connection: - close Content-Length: - - '640' + - '579' Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:10 GMT + - Tue, 30 Jul 2024 08:29:54 GMT Server: - gunicorn X-Robots-Tag: @@ -107,7 +106,7 @@ interactions: Content-Type: - application/problem+json Date: - - Mon, 29 Jul 2024 14:36:11 GMT + - Tue, 30 Jul 2024 08:29:54 GMT Server: - gunicorn X-Robots-Tag: @@ -141,7 +140,7 @@ interactions: Content-Type: - application/problem+json Date: - - Mon, 29 Jul 2024 14:36:11 GMT + - Tue, 30 Jul 2024 08:29:54 GMT Server: - gunicorn X-Robots-Tag: @@ -173,7 +172,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:11 GMT + - Tue, 30 Jul 2024 08:29:54 GMT Server: - gunicorn X-Robots-Tag: diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_find_failed_dag.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_find_failed_dag.yaml index c40a3ced..f15c976a 100644 --- a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_find_failed_dag.yaml +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_find_failed_dag.yaml @@ -19,10 +19,10 @@ interactions: body: string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-29T14:36:11.363586+00:00\",\n - \ \"data_interval_start\": \"2024-07-29T14:36:11.363586+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-29T14:36:11.363586+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-29T14:36:11.363586+00:00\",\n + \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:29:55.039650+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T08:29:55.039650+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T08:29:55.039650+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T08:29:55.039650+00:00\",\n \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \ \"state\": \"queued\"\n}\n" headers: @@ -33,7 +33,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:11 GMT + - Tue, 30 Jul 2024 08:29:55 GMT Server: - gunicorn X-Robots-Tag: @@ -58,12 +58,12 @@ interactions: body: string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-29T14:36:11.363586+00:00\",\n - \ \"data_interval_start\": \"2024-07-29T14:36:11.363586+00:00\",\n \"end_date\": - \"2024-07-29T14:36:30.104727+00:00\",\n \"execution_date\": \"2024-07-29T14:36:11.363586+00:00\",\n - \ \"external_trigger\": true,\n \"last_scheduling_decision\": \"2024-07-29T14:36:30.102789+00:00\",\n - \ \"logical_date\": \"2024-07-29T14:36:11.363586+00:00\",\n \"note\": null,\n - \ \"run_type\": \"manual\",\n \"start_date\": \"2024-07-29T14:36:12.040608+00:00\",\n + \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:29:55.039650+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T08:29:55.039650+00:00\",\n \"end_date\": + \"2024-07-30T08:30:12.831165+00:00\",\n \"execution_date\": \"2024-07-30T08:29:55.039650+00:00\",\n + \ \"external_trigger\": true,\n \"last_scheduling_decision\": \"2024-07-30T08:30:12.828982+00:00\",\n + \ \"logical_date\": \"2024-07-30T08:29:55.039650+00:00\",\n \"note\": null,\n + \ \"run_type\": \"manual\",\n \"start_date\": \"2024-07-30T08:29:55.206573+00:00\",\n \ \"state\": \"failed\"\n}\n" headers: Connection: @@ -73,7 +73,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:31 GMT + - Tue, 30 Jul 2024 08:30:15 GMT Server: - gunicorn X-Robots-Tag: @@ -107,7 +107,7 @@ interactions: Content-Type: - application/problem+json Date: - - Mon, 29 Jul 2024 14:36:31 GMT + - Tue, 30 Jul 2024 08:30:15 GMT Server: - gunicorn X-Robots-Tag: @@ -141,7 +141,7 @@ interactions: Content-Type: - application/problem+json Date: - - Mon, 29 Jul 2024 14:36:31 GMT + - Tue, 30 Jul 2024 08:30:15 GMT Server: - gunicorn X-Robots-Tag: @@ -173,7 +173,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:31 GMT + - Tue, 30 Jul 2024 08:30:15 GMT Server: - gunicorn X-Robots-Tag: diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_failed_tasks.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_failed_tasks.yaml index 39530b5c..f0a4ec20 100644 --- a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_failed_tasks.yaml +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_failed_tasks.yaml @@ -19,10 +19,10 @@ interactions: body: string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-29T14:36:31.803583+00:00\",\n - \ \"data_interval_start\": \"2024-07-29T14:36:31.803583+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-29T14:36:31.803583+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-29T14:36:31.803583+00:00\",\n + \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:30:15.450284+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T08:30:15.450284+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T08:30:15.450284+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T08:30:15.450284+00:00\",\n \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \ \"state\": \"queued\"\n}\n" headers: @@ -33,7 +33,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:31 GMT + - Tue, 30 Jul 2024 08:30:15 GMT Server: - gunicorn X-Robots-Tag: @@ -58,12 +58,12 @@ interactions: body: string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-29T14:36:31.803583+00:00\",\n - \ \"data_interval_start\": \"2024-07-29T14:36:31.803583+00:00\",\n \"end_date\": - \"2024-07-29T14:36:50.179957+00:00\",\n \"execution_date\": \"2024-07-29T14:36:31.803583+00:00\",\n - \ \"external_trigger\": true,\n \"last_scheduling_decision\": \"2024-07-29T14:36:50.177539+00:00\",\n - \ \"logical_date\": \"2024-07-29T14:36:31.803583+00:00\",\n \"note\": null,\n - \ \"run_type\": \"manual\",\n \"start_date\": \"2024-07-29T14:36:32.173357+00:00\",\n + \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:30:15.450284+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T08:30:15.450284+00:00\",\n \"end_date\": + \"2024-07-30T08:30:33.523185+00:00\",\n \"execution_date\": \"2024-07-30T08:30:15.450284+00:00\",\n + \ \"external_trigger\": true,\n \"last_scheduling_decision\": \"2024-07-30T08:30:33.521865+00:00\",\n + \ \"logical_date\": \"2024-07-30T08:30:15.450284+00:00\",\n \"note\": null,\n + \ \"run_type\": \"manual\",\n \"start_date\": \"2024-07-30T08:30:15.499846+00:00\",\n \ \"state\": \"failed\"\n}\n" headers: Connection: @@ -73,7 +73,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:51 GMT + - Tue, 30 Jul 2024 08:30:35 GMT Server: - gunicorn X-Robots-Tag: @@ -107,7 +107,7 @@ interactions: Content-Type: - application/problem+json Date: - - Mon, 29 Jul 2024 14:36:51 GMT + - Tue, 30 Jul 2024 08:30:35 GMT Server: - gunicorn X-Robots-Tag: @@ -141,7 +141,7 @@ interactions: Content-Type: - application/problem+json Date: - - Mon, 29 Jul 2024 14:36:52 GMT + - Tue, 30 Jul 2024 08:30:35 GMT Server: - gunicorn X-Robots-Tag: @@ -169,16 +169,16 @@ interactions: body: string: "{\n \"task_instances\": [\n {\n \"dag_id\": \"author_create_initialization_dag\",\n \ \"dag_run_id\": \"00000000-0000-0000-0000-000000000001\",\n \"execution_date\": - \"2024-07-29T14:36:31.803583+00:00\",\n \"task_id\": \"set_author_create_workflow_status_to_approval\"\n + \"2024-07-30T08:30:15.450284+00:00\",\n \"task_id\": \"set_workflow_status_to_running\"\n \ },\n {\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000001\",\n \"execution_date\": \"2024-07-29T14:36:31.803583+00:00\",\n - \ \"task_id\": \"create_author_create_user_ticket\"\n },\n {\n \"dag_id\": - \"author_create_initialization_dag\",\n \"dag_run_id\": \"00000000-0000-0000-0000-000000000001\",\n - \ \"execution_date\": \"2024-07-29T14:36:31.803583+00:00\",\n \"task_id\": - \"set_workflow_status_to_running\"\n },\n {\n \"dag_id\": \"author_create_initialization_dag\",\n + \"00000000-0000-0000-0000-000000000001\",\n \"execution_date\": \"2024-07-30T08:30:15.450284+00:00\",\n + \ \"task_id\": \"set_schema\"\n },\n {\n \"dag_id\": \"author_create_initialization_dag\",\n \ \"dag_run_id\": \"00000000-0000-0000-0000-000000000001\",\n \"execution_date\": - \"2024-07-29T14:36:31.803583+00:00\",\n \"task_id\": \"set_schema\"\n - \ }\n ]\n}\n" + \"2024-07-30T08:30:15.450284+00:00\",\n \"task_id\": \"create_author_create_user_ticket\"\n + \ },\n {\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": + \"00000000-0000-0000-0000-000000000001\",\n \"execution_date\": \"2024-07-30T08:30:15.450284+00:00\",\n + \ \"task_id\": \"set_author_create_workflow_status_to_approval\"\n }\n + \ ]\n}\n" headers: Connection: - close @@ -187,7 +187,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:52 GMT + - Tue, 30 Jul 2024 08:30:35 GMT Server: - gunicorn X-Robots-Tag: @@ -219,7 +219,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:52 GMT + - Tue, 30 Jul 2024 08:30:35 GMT Server: - gunicorn X-Robots-Tag: diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_workflow_dags.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_workflow_dags.yaml index d481c456..9b65560f 100644 --- a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_workflow_dags.yaml +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_workflow_dags.yaml @@ -19,10 +19,10 @@ interactions: body: string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-29T14:36:52.319818+00:00\",\n - \ \"data_interval_start\": \"2024-07-29T14:36:52.319818+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-29T14:36:52.319818+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-29T14:36:52.319818+00:00\",\n + \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:30:35.963602+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T08:30:35.963602+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T08:30:35.963602+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T08:30:35.963602+00:00\",\n \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \ \"state\": \"queued\"\n}\n" headers: @@ -33,7 +33,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:52 GMT + - Tue, 30 Jul 2024 08:30:35 GMT Server: - gunicorn X-Robots-Tag: @@ -58,10 +58,10 @@ interactions: body: string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-29T14:36:52.319818+00:00\",\n - \ \"data_interval_start\": \"2024-07-29T14:36:52.319818+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-29T14:36:52.319818+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-29T14:36:52.319818+00:00\",\n + \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:30:35.963602+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T08:30:35.963602+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T08:30:35.963602+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T08:30:35.963602+00:00\",\n \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \ \"state\": \"queued\"\n}\n" headers: @@ -72,7 +72,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:52 GMT + - Tue, 30 Jul 2024 08:30:36 GMT Server: - gunicorn X-Robots-Tag: @@ -106,7 +106,7 @@ interactions: Content-Type: - application/problem+json Date: - - Mon, 29 Jul 2024 14:36:52 GMT + - Tue, 30 Jul 2024 08:30:36 GMT Server: - gunicorn X-Robots-Tag: @@ -140,7 +140,7 @@ interactions: Content-Type: - application/problem+json Date: - - Mon, 29 Jul 2024 14:36:52 GMT + - Tue, 30 Jul 2024 08:30:36 GMT Server: - gunicorn X-Robots-Tag: @@ -172,7 +172,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:52 GMT + - Tue, 30 Jul 2024 08:30:36 GMT Server: - gunicorn X-Robots-Tag: @@ -200,10 +200,10 @@ interactions: body: string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-29T14:36:52.619341+00:00\",\n - \ \"data_interval_start\": \"2024-07-29T14:36:52.619341+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-29T14:36:52.619341+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-29T14:36:52.619341+00:00\",\n + \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:30:36.274685+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T08:30:36.274685+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T08:30:36.274685+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T08:30:36.274685+00:00\",\n \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \ \"state\": \"queued\"\n}\n" headers: @@ -214,7 +214,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:52 GMT + - Tue, 30 Jul 2024 08:30:36 GMT Server: - gunicorn X-Robots-Tag: @@ -246,7 +246,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:52 GMT + - Tue, 30 Jul 2024 08:30:36 GMT Server: - gunicorn X-Robots-Tag: diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_trigger_airflow_dag.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_trigger_airflow_dag.yaml index 04305f15..b5f17101 100644 --- a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_trigger_airflow_dag.yaml +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_trigger_airflow_dag.yaml @@ -19,10 +19,10 @@ interactions: body: string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000001\"\n \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-29T14:36:52.855224+00:00\",\n - \ \"data_interval_start\": \"2024-07-29T14:36:52.855224+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-29T14:36:52.855224+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-29T14:36:52.855224+00:00\",\n + \"00000000-0000-0000-0000-000000000001\",\n \"data_interval_end\": \"2024-07-30T08:30:36.501705+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T08:30:36.501705+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T08:30:36.501705+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T08:30:36.501705+00:00\",\n \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \ \"state\": \"queued\"\n}\n" headers: @@ -33,7 +33,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:52 GMT + - Tue, 30 Jul 2024 08:30:36 GMT Server: - gunicorn X-Robots-Tag: @@ -65,7 +65,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:52 GMT + - Tue, 30 Jul 2024 08:30:36 GMT Server: - gunicorn X-Robots-Tag: diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_accept_author.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_accept_author.yaml index 0495c1ec..0292d427 100644 --- a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_accept_author.yaml +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_accept_author.yaml @@ -28,7 +28,7 @@ interactions: Content-Type: - application/problem+json Date: - - Mon, 29 Jul 2024 14:36:55 GMT + - Tue, 30 Jul 2024 08:37:55 GMT Server: - gunicorn X-Robots-Tag: @@ -57,10 +57,10 @@ interactions: string: "{\n \"conf\": {\n \"create_ticket\": true,\n \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n },\n \"dag_id\": \"author_create_approved_dag\",\n \ \"dag_run_id\": \"00000000-0000-0000-0000-000000000000\",\n \"data_interval_end\": - \"2024-07-29T14:36:55.293331+00:00\",\n \"data_interval_start\": \"2024-07-29T14:36:55.293331+00:00\",\n - \ \"end_date\": null,\n \"execution_date\": \"2024-07-29T14:36:55.293331+00:00\",\n + \"2024-07-30T08:37:55.067410+00:00\",\n \"data_interval_start\": \"2024-07-30T08:37:55.067410+00:00\",\n + \ \"end_date\": null,\n \"execution_date\": \"2024-07-30T08:37:55.067410+00:00\",\n \ \"external_trigger\": true,\n \"last_scheduling_decision\": null,\n \"logical_date\": - \"2024-07-29T14:36:55.293331+00:00\",\n \"note\": null,\n \"run_type\": + \"2024-07-30T08:37:55.067410+00:00\",\n \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \"state\": \"queued\"\n}\n" headers: Connection: @@ -70,7 +70,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:55 GMT + - Tue, 30 Jul 2024 08:37:55 GMT Server: - gunicorn X-Robots-Tag: @@ -92,22 +92,26 @@ interactions: Content-Type: - application/json method: DELETE - uri: http://airflow-webserver:8080/api/v1/dags/author_create_approved_dag/dagRuns/00000000-0000-0000-0000-000000000000 + uri: http://airflow-webserver:8080/api/v1/dags/author_create_approved_dag/dagRuns/Workflow%20object%20(00000000-0000-0000-0000-000000000000) response: body: - string: '' + string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_approved_dag' + and DagRun ID: 'Workflow object (00000000-0000-0000-0000-000000000000)' not + found\",\n \"status\": 404,\n \"title\": \"Not Found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.8.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" headers: Connection: - close + Content-Length: + - '305' Content-Type: - - application/json + - application/problem+json Date: - - Mon, 29 Jul 2024 14:36:55 GMT + - Tue, 30 Jul 2024 08:37:55 GMT Server: - gunicorn X-Robots-Tag: - noindex, nofollow status: - code: 204 - message: NO CONTENT + code: 404 + message: NOT FOUND version: 1 diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_create_author.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_create_author.yaml index cd9a07a5..ee26b056 100644 --- a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_create_author.yaml +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_create_author.yaml @@ -28,7 +28,7 @@ interactions: Content-Type: - application/problem+json Date: - - Mon, 29 Jul 2024 14:36:55 GMT + - Tue, 30 Jul 2024 08:37:55 GMT Server: - gunicorn X-Robots-Tag: @@ -37,8 +37,8 @@ interactions: code: 409 message: CONFLICT - request: - body: '{"dag_run_id": "05b58433-bc6f-4fd8-914f-7107877646ec", "conf": {"workflow_id": - "05b58433-bc6f-4fd8-914f-7107877646ec", "native_name": "NATIVE_NAME", "alternate_name": + body: '{"dag_run_id": "cd4a73f3-7927-45b4-8a09-0c7187ac9b9b", "conf": {"workflow_id": + "cd4a73f3-7927-45b4-8a09-0c7187ac9b9b", "native_name": "NATIVE_NAME", "alternate_name": "NAME", "display_name": "FIRST_NAME", "family_name": "LAST_NAME", "given_name": "GIVEN_NAME"}}' headers: @@ -59,12 +59,12 @@ interactions: string: "{\n \"conf\": {\n \"alternate_name\": \"NAME\",\n \"display_name\": \"FIRST_NAME\",\n \"family_name\": \"LAST_NAME\",\n \"given_name\": \"GIVEN_NAME\",\n \"native_name\": \"NATIVE_NAME\",\n \"workflow_id\": - \"05b58433-bc6f-4fd8-914f-7107877646ec\"\n },\n \"dag_id\": \"author_create_initialization_dag\",\n - \ \"dag_run_id\": \"05b58433-bc6f-4fd8-914f-7107877646ec\",\n \"data_interval_end\": - \"2024-07-29T14:36:55.641389+00:00\",\n \"data_interval_start\": \"2024-07-29T14:36:55.641389+00:00\",\n - \ \"end_date\": null,\n \"execution_date\": \"2024-07-29T14:36:55.641389+00:00\",\n + \"cd4a73f3-7927-45b4-8a09-0c7187ac9b9b\"\n },\n \"dag_id\": \"author_create_initialization_dag\",\n + \ \"dag_run_id\": \"cd4a73f3-7927-45b4-8a09-0c7187ac9b9b\",\n \"data_interval_end\": + \"2024-07-30T08:37:55.637380+00:00\",\n \"data_interval_start\": \"2024-07-30T08:37:55.637380+00:00\",\n + \ \"end_date\": null,\n \"execution_date\": \"2024-07-30T08:37:55.637380+00:00\",\n \ \"external_trigger\": true,\n \"last_scheduling_decision\": null,\n \"logical_date\": - \"2024-07-29T14:36:55.641389+00:00\",\n \"note\": null,\n \"run_type\": + \"2024-07-30T08:37:55.637380+00:00\",\n \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \"state\": \"queued\"\n}\n" headers: Connection: @@ -74,7 +74,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:55 GMT + - Tue, 30 Jul 2024 08:37:55 GMT Server: - gunicorn X-Robots-Tag: diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_reject_author.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_reject_author.yaml index a8ce6531..31f0454d 100644 --- a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_reject_author.yaml +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_reject_author.yaml @@ -28,7 +28,7 @@ interactions: Content-Type: - application/problem+json Date: - - Mon, 29 Jul 2024 14:36:55 GMT + - Tue, 30 Jul 2024 08:37:55 GMT Server: - gunicorn X-Robots-Tag: @@ -57,10 +57,10 @@ interactions: string: "{\n \"conf\": {\n \"create_ticket\": true,\n \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n },\n \"dag_id\": \"author_create_rejected_dag\",\n \ \"dag_run_id\": \"00000000-0000-0000-0000-000000000000\",\n \"data_interval_end\": - \"2024-07-29T14:36:55.985031+00:00\",\n \"data_interval_start\": \"2024-07-29T14:36:55.985031+00:00\",\n - \ \"end_date\": null,\n \"execution_date\": \"2024-07-29T14:36:55.985031+00:00\",\n + \"2024-07-30T08:37:55.930803+00:00\",\n \"data_interval_start\": \"2024-07-30T08:37:55.930803+00:00\",\n + \ \"end_date\": null,\n \"execution_date\": \"2024-07-30T08:37:55.930803+00:00\",\n \ \"external_trigger\": true,\n \"last_scheduling_decision\": null,\n \"logical_date\": - \"2024-07-29T14:36:55.985031+00:00\",\n \"note\": null,\n \"run_type\": + \"2024-07-30T08:37:55.930803+00:00\",\n \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \"state\": \"queued\"\n}\n" headers: Connection: @@ -70,7 +70,7 @@ interactions: Content-Type: - application/json Date: - - Mon, 29 Jul 2024 14:36:55 GMT + - Tue, 30 Jul 2024 08:37:55 GMT Server: - gunicorn X-Robots-Tag: @@ -92,22 +92,26 @@ interactions: Content-Type: - application/json method: DELETE - uri: http://airflow-webserver:8080/api/v1/dags/author_create_rejected_dag/dagRuns/00000000-0000-0000-0000-000000000000 + uri: http://airflow-webserver:8080/api/v1/dags/author_create_rejected_dag/dagRuns/Workflow%20object%20(00000000-0000-0000-0000-000000000000) response: body: - string: '' + string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_rejected_dag' + and DagRun ID: 'Workflow object (00000000-0000-0000-0000-000000000000)' not + found\",\n \"status\": 404,\n \"title\": \"Not Found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.8.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" headers: Connection: - close + Content-Length: + - '305' Content-Type: - - application/json + - application/problem+json Date: - - Mon, 29 Jul 2024 14:36:56 GMT + - Tue, 30 Jul 2024 08:37:56 GMT Server: - gunicorn X-Robots-Tag: - noindex, nofollow status: - code: 204 - message: NO CONTENT + code: 404 + message: NOT FOUND version: 1 diff --git a/backoffice/backoffice/workflows/tests/conftest.py b/backoffice/backoffice/workflows/tests/conftest.py index edbf437b..1d96abf6 100644 --- a/backoffice/backoffice/workflows/tests/conftest.py +++ b/backoffice/backoffice/workflows/tests/conftest.py @@ -1,9 +1,3 @@ -# -# Copyright (C) 2019 CERN. -# -# inspirehep is free software; you can redistribute it and/or modify it under -# the terms of the MIT License; see LICENSE file for more details. - import pytest @@ -19,7 +13,6 @@ def vcr_config(): "mq", "postgres-backoffice", "redis", - "localhost", ), "record_mode": "once", } diff --git a/backoffice/backoffice/workflows/tests/test_airflow_utils.py b/backoffice/backoffice/workflows/tests/test_airflow_utils.py index c568ccbb..60c928fd 100644 --- a/backoffice/backoffice/workflows/tests/test_airflow_utils.py +++ b/backoffice/backoffice/workflows/tests/test_airflow_utils.py @@ -6,28 +6,22 @@ from django.test import TransactionTestCase from backoffice.workflows import airflow_utils -from backoffice.workflows.constants import WORKFLOW_DAGS, StatusChoices, WorkflowType +from backoffice.workflows.constants import WORKFLOW_DAGS, WorkflowType Workflow = apps.get_model(app_label="workflows", model_name="Workflow") class TestAirflowUtils(TransactionTestCase): def setUp(self): - self.dag_id = WORKFLOW_DAGS[WorkflowType.AUTHOR_CREATE][0] - self.workflow = Workflow.objects.create( - data={}, - status=StatusChoices.APPROVAL, - core=True, - is_update=False, - workflow_type=WorkflowType.AUTHOR_CREATE, - id=uuid.UUID(int=1), - ) + self.workflow_id = uuid.UUID(int=1) + self.workflow_type = WorkflowType.AUTHOR_CREATE + self.dag_id = WORKFLOW_DAGS[self.workflow_type][0] self.response = airflow_utils.trigger_airflow_dag( - self.dag_id, str(self.workflow.id) + self.dag_id, str(self.workflow_id) ) - def tearDown(self) -> None: - airflow_utils.delete_workflow_dag(self.dag_id, self.workflow) + def tearDown(self): + airflow_utils.delete_workflow_dag(self.dag_id, self.workflow_id) @pytest.mark.vcr() def test_trigger_airflow_dag(self): @@ -36,27 +30,33 @@ def test_trigger_airflow_dag(self): @pytest.mark.vcr() def test_restart_failed_tasks(self): time.sleep(20) # wait for dag to fail - response = airflow_utils.restart_failed_tasks(self.workflow) + response = airflow_utils.restart_failed_tasks( + self.workflow_id, self.workflow_type + ) self.assertEqual(response.status_code, 200) @pytest.mark.vcr() def test_find_executed_dags(self): - executed_dags_for_workflow = airflow_utils.find_executed_dags(self.workflow) + executed_dags_for_workflow = airflow_utils.find_executed_dags( + self.workflow_id, self.workflow_type + ) self.assertIn(self.dag_id, executed_dags_for_workflow) @pytest.mark.vcr() def test_find_failed_dag(self): time.sleep(20) # wait for dag to fail - failed_dag = airflow_utils.find_failed_dag(self.workflow) + failed_dag = airflow_utils.find_failed_dag(self.workflow_id, self.workflow_type) self.assertEqual(self.dag_id, failed_dag) @pytest.mark.vcr() def test_delete_workflow_dag(self): - response = airflow_utils.delete_workflow_dag(self.dag_id, self.workflow) + response = airflow_utils.delete_workflow_dag(self.dag_id, self.workflow_id) self.assertEqual(response.status_code, 200) @pytest.mark.vcr() def test_restart_workflow_dags(self): - response = airflow_utils.restart_workflow_dags(self.workflow) + response = airflow_utils.restart_workflow_dags( + self.workflow_id, self.workflow_type + ) self.assertEqual(response.status_code, 200)