From 346f1c1bc35dd5a1b2d9a27185525ef655b0df91 Mon Sep 17 00:00:00 2001 From: DonHaul Date: Tue, 27 Aug 2024 10:46:12 +0200 Subject: [PATCH] backoffice: fix restart with params * ref: cern-sis/issues-inspire/issues/545 --- .../backoffice/workflows/airflow_utils.py | 22 +- backoffice/backoffice/workflows/api/views.py | 1 + ...lowUtils.test_fetch_data_workflow_dag.yaml | 188 ++++++++++++++++ ...rflowUtils.test_restart_workflow_dags.yaml | 213 ++++++++++++++---- ...kflowViewSet.test_restart_full_dagrun.yaml | 213 ++++++++++++++---- ...kflowViewSet.test_restart_with_params.yaml | 211 +++++++++++++---- .../workflows/tests/test_airflow_utils.py | 11 +- .../backoffice/workflows/tests/test_views.py | 9 +- 8 files changed, 711 insertions(+), 157 deletions(-) create mode 100644 backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_fetch_data_workflow_dag.yaml diff --git a/backoffice/backoffice/workflows/airflow_utils.py b/backoffice/backoffice/workflows/airflow_utils.py index 5f88b9e7..3683f651 100644 --- a/backoffice/backoffice/workflows/airflow_utils.py +++ b/backoffice/backoffice/workflows/airflow_utils.py @@ -156,10 +156,12 @@ def restart_workflow_dags(workflow_id, workflow_type, params=None): :param params: parameters of new dag execution :returns: request response """ + + data = fetch_data_workflow_dag(workflow_id, workflow_type) delete_workflow_dag_runs(workflow_id, workflow_type) return trigger_airflow_dag( - WORKFLOW_DAGS[workflow_type].initialize, str(workflow_id), params + WORKFLOW_DAGS[workflow_type].initialize, str(workflow_id), params or data ) @@ -171,9 +173,19 @@ def delete_workflow_dag_runs(workflow_id, workflow_type): """ executed_dags_for_workflow = find_executed_dags(workflow_id, workflow_type) - for dag_id in executed_dags_for_workflow: + for dag_id, _ in executed_dags_for_workflow.items(): delete_workflow_dag(dag_id, str(workflow_id)) - return JsonResponse( - data={"message": f"Dag runs for worfklow {workflow_id} have been deleted"} - ) + +def fetch_data_workflow_dag(workflow_id, workflow_type): + """Fetches Data that the workflow ran with + + :param workflow_id: workflow_id for dag to get data of + :param workflow_type: type of workflow + :returns: data workflow dags used + """ + + executed_dags_for_workflow = find_executed_dags(workflow_id, workflow_type) + + _, dag = next(iter(executed_dags_for_workflow.items())) + return dag["conf"].get("data") diff --git a/backoffice/backoffice/workflows/api/views.py b/backoffice/backoffice/workflows/api/views.py index 0fe41ca5..3bef7cf7 100644 --- a/backoffice/backoffice/workflows/api/views.py +++ b/backoffice/backoffice/workflows/api/views.py @@ -206,6 +206,7 @@ def restart(self, request, pk=None): workflow.id, workflow.workflow_type ) + Decision.objects.filter(workflow=workflow).delete() return airflow_utils.restart_workflow_dags( workflow.id, workflow.workflow_type, request.data.get("params") ) diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_fetch_data_workflow_dag.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_fetch_data_workflow_dag.yaml new file mode 100644 index 00000000..d1ab5baf --- /dev/null +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_fetch_data_workflow_dag.yaml @@ -0,0 +1,188 @@ +interactions: +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000001", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000001", "data": {"test": "test"}}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '145' + Content-Type: + - application/json + method: POST + uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns + response: + body: + string: "{\n \"conf\": {\n \"data\": {\n \"test\": \"test\"\n },\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-08-30T11:26:33.983555+00:00\",\n \"data_interval_start\": + \"2024-08-30T11:26:33.983555+00:00\",\n \"end_date\": null,\n \"execution_date\": + \"2024-08-30T11:26:33.983555+00:00\",\n \"external_trigger\": true,\n \"last_scheduling_decision\": + null,\n \"logical_date\": \"2024-08-30T11:26:33.983555+00:00\",\n \"note\": + null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \"state\": + \"queued\"\n}\n" + headers: + Cache-Control: + - no-store + Connection: + - close + Content-Length: + - '621' + Content-Type: + - application/json + Date: + - Fri, 30 Aug 2024 11:26:34 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + method: GET + uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000001 + response: + body: + string: "{\n \"conf\": {\n \"data\": {\n \"test\": \"test\"\n },\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-08-30T11:26:33.983555+00:00\",\n \"data_interval_start\": + \"2024-08-30T11:26:33.983555+00:00\",\n \"end_date\": \"2024-08-30T11:26:51.968680+00:00\",\n + \ \"execution_date\": \"2024-08-30T11:26:33.983555+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": \"2024-08-30T11:26:51.966580+00:00\",\n + \ \"logical_date\": \"2024-08-30T11:26:33.983555+00:00\",\n \"note\": null,\n + \ \"run_type\": \"manual\",\n \"start_date\": \"2024-08-30T11:26:34.088225+00:00\",\n + \ \"state\": \"failed\"\n}\n" + headers: + Cache-Control: + - no-store + Connection: + - close + Content-Length: + - '711' + Content-Type: + - application/json + Date: + - Fri, 30 Aug 2024 11:27:03 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + method: GET + uri: http://airflow-webserver:8080/api/v1/dags/author_create_approved_dag/dagRuns/00000000-0000-0000-0000-000000000001 + response: + body: + string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_approved_dag' + and DagRun ID: '00000000-0000-0000-0000-000000000001' not found\",\n \"status\": + 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.9.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" + headers: + Cache-Control: + - no-store + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Fri, 30 Aug 2024 11:27:03 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 404 + message: NOT FOUND +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + method: GET + uri: http://airflow-webserver:8080/api/v1/dags/author_create_rejected_dag/dagRuns/00000000-0000-0000-0000-000000000001 + response: + body: + string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_rejected_dag' + and DagRun ID: '00000000-0000-0000-0000-000000000001' not found\",\n \"status\": + 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.9.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" + headers: + Cache-Control: + - no-store + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Fri, 30 Aug 2024 11:27:03 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 404 + message: NOT FOUND +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + method: DELETE + uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000001 + response: + body: + string: '' + headers: + Cache-Control: + - no-store + Connection: + - close + Content-Type: + - application/json + Date: + - Fri, 30 Aug 2024 11:27:45 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 204 + message: NO CONTENT +version: 1 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 c1a5c53c..51996914 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 @@ -1,7 +1,7 @@ interactions: - request: body: '{"dag_run_id": "00000000-0000-0000-0000-000000000001", "conf": {"workflow_id": - "00000000-0000-0000-0000-000000000001"}}' + "00000000-0000-0000-0000-000000000001", "data": {"test": "test"}}}' headers: Accept: - '*/*' @@ -10,30 +10,33 @@ interactions: Connection: - keep-alive Content-Length: - - '119' + - '145' Content-Type: - application/json method: POST uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns response: 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-30T12:14:23.238128+00:00\",\n - \ \"data_interval_start\": \"2024-07-30T12:14:23.238128+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-30T12:14:23.238128+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:14:23.238128+00:00\",\n - \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n - \ \"state\": \"queued\"\n}\n" + string: "{\n \"conf\": {\n \"data\": {\n \"test\": \"test\"\n },\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-08-30T11:32:15.498239+00:00\",\n \"data_interval_start\": + \"2024-08-30T11:32:15.498239+00:00\",\n \"end_date\": null,\n \"execution_date\": + \"2024-08-30T11:32:15.498239+00:00\",\n \"external_trigger\": true,\n \"last_scheduling_decision\": + null,\n \"logical_date\": \"2024-08-30T11:32:15.498239+00:00\",\n \"note\": + null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \"state\": + \"queued\"\n}\n" headers: + Cache-Control: + - no-store Connection: - close Content-Length: - - '579' + - '621' Content-Type: - application/json Date: - - Tue, 30 Jul 2024 12:14:23 GMT + - Fri, 30 Aug 2024 11:32:15 GMT Server: - gunicorn X-Robots-Tag: @@ -50,29 +53,31 @@ interactions: - gzip, deflate Connection: - keep-alive - Content-Type: - - application/json method: GET uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000001 response: 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-30T12:14:23.238128+00:00\",\n - \ \"data_interval_start\": \"2024-07-30T12:14:23.238128+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-30T12:14:23.238128+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:14:23.238128+00:00\",\n - \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n - \ \"state\": \"queued\"\n}\n" + string: "{\n \"conf\": {\n \"data\": {\n \"test\": \"test\"\n },\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-08-30T11:32:15.498239+00:00\",\n \"data_interval_start\": + \"2024-08-30T11:32:15.498239+00:00\",\n \"end_date\": \"2024-08-30T11:32:33.069744+00:00\",\n + \ \"execution_date\": \"2024-08-30T11:32:15.498239+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": \"2024-08-30T11:32:33.062289+00:00\",\n + \ \"logical_date\": \"2024-08-30T11:32:15.498239+00:00\",\n \"note\": null,\n + \ \"run_type\": \"manual\",\n \"start_date\": \"2024-08-30T11:32:15.679527+00:00\",\n + \ \"state\": \"failed\"\n}\n" headers: + Cache-Control: + - no-store Connection: - close Content-Length: - - '579' + - '711' Content-Type: - application/json Date: - - Tue, 30 Jul 2024 12:14:23 GMT + - Fri, 30 Aug 2024 11:32:48 GMT Server: - gunicorn X-Robots-Tag: @@ -89,16 +94,16 @@ interactions: - gzip, deflate Connection: - keep-alive - Content-Type: - - application/json method: GET uri: http://airflow-webserver:8080/api/v1/dags/author_create_approved_dag/dagRuns/00000000-0000-0000-0000-000000000001 response: body: string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_approved_dag' and DagRun ID: '00000000-0000-0000-0000-000000000001' not found\",\n \"status\": - 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.8.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" + 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.9.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" headers: + Cache-Control: + - no-store Connection: - close Content-Length: @@ -106,7 +111,7 @@ interactions: Content-Type: - application/problem+json Date: - - Tue, 30 Jul 2024 12:14:23 GMT + - Fri, 30 Aug 2024 11:32:48 GMT Server: - gunicorn X-Robots-Tag: @@ -123,16 +128,125 @@ interactions: - gzip, deflate Connection: - keep-alive + method: GET + uri: http://airflow-webserver:8080/api/v1/dags/author_create_rejected_dag/dagRuns/00000000-0000-0000-0000-000000000001 + response: + body: + string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_rejected_dag' + and DagRun ID: '00000000-0000-0000-0000-000000000001' not found\",\n \"status\": + 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.9.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" + headers: + Cache-Control: + - no-store + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Fri, 30 Aug 2024 11:32:48 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 404 + message: NOT FOUND +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + method: GET + uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000001 + response: + body: + string: "{\n \"conf\": {\n \"data\": {\n \"test\": \"test\"\n },\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-08-30T11:32:15.498239+00:00\",\n \"data_interval_start\": + \"2024-08-30T11:32:15.498239+00:00\",\n \"end_date\": \"2024-08-30T11:32:33.069744+00:00\",\n + \ \"execution_date\": \"2024-08-30T11:32:15.498239+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": \"2024-08-30T11:32:33.062289+00:00\",\n + \ \"logical_date\": \"2024-08-30T11:32:15.498239+00:00\",\n \"note\": null,\n + \ \"run_type\": \"manual\",\n \"start_date\": \"2024-08-30T11:32:15.679527+00:00\",\n + \ \"state\": \"failed\"\n}\n" + headers: + Cache-Control: + - no-store + Connection: + - close + Content-Length: + - '711' Content-Type: - application/json + Date: + - Fri, 30 Aug 2024 11:32:48 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + method: GET + uri: http://airflow-webserver:8080/api/v1/dags/author_create_approved_dag/dagRuns/00000000-0000-0000-0000-000000000001 + response: + body: + string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_approved_dag' + and DagRun ID: '00000000-0000-0000-0000-000000000001' not found\",\n \"status\": + 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.9.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" + headers: + Cache-Control: + - no-store + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Fri, 30 Aug 2024 11:32:48 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 404 + message: NOT FOUND +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive method: GET uri: http://airflow-webserver:8080/api/v1/dags/author_create_rejected_dag/dagRuns/00000000-0000-0000-0000-000000000001 response: body: string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_rejected_dag' and DagRun ID: '00000000-0000-0000-0000-000000000001' not found\",\n \"status\": - 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.8.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" + 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.9.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" headers: + Cache-Control: + - no-store Connection: - close Content-Length: @@ -140,7 +254,7 @@ interactions: Content-Type: - application/problem+json Date: - - Tue, 30 Jul 2024 12:14:23 GMT + - Fri, 30 Aug 2024 11:32:48 GMT Server: - gunicorn X-Robots-Tag: @@ -159,20 +273,20 @@ interactions: - keep-alive Content-Length: - '0' - Content-Type: - - application/json method: DELETE uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000001 response: body: string: '' headers: + Cache-Control: + - no-store Connection: - close Content-Type: - application/json Date: - - Tue, 30 Jul 2024 12:14:23 GMT + - Fri, 30 Aug 2024 11:32:48 GMT Server: - gunicorn X-Robots-Tag: @@ -182,7 +296,7 @@ interactions: message: NO CONTENT - request: body: '{"dag_run_id": "00000000-0000-0000-0000-000000000001", "conf": {"workflow_id": - "00000000-0000-0000-0000-000000000001"}}' + "00000000-0000-0000-0000-000000000001", "data": {"test": "test"}}}' headers: Accept: - '*/*' @@ -191,30 +305,33 @@ interactions: Connection: - keep-alive Content-Length: - - '119' + - '145' Content-Type: - application/json method: POST uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns response: 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-30T12:14:23.534233+00:00\",\n - \ \"data_interval_start\": \"2024-07-30T12:14:23.534233+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-30T12:14:23.534233+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:14:23.534233+00:00\",\n - \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n - \ \"state\": \"queued\"\n}\n" + string: "{\n \"conf\": {\n \"data\": {\n \"test\": \"test\"\n },\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-08-30T11:32:48.880207+00:00\",\n \"data_interval_start\": + \"2024-08-30T11:32:48.880207+00:00\",\n \"end_date\": null,\n \"execution_date\": + \"2024-08-30T11:32:48.880207+00:00\",\n \"external_trigger\": true,\n \"last_scheduling_decision\": + null,\n \"logical_date\": \"2024-08-30T11:32:48.880207+00:00\",\n \"note\": + null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \"state\": + \"queued\"\n}\n" headers: + Cache-Control: + - no-store Connection: - close Content-Length: - - '579' + - '621' Content-Type: - application/json Date: - - Tue, 30 Jul 2024 12:14:23 GMT + - Fri, 30 Aug 2024 11:32:48 GMT Server: - gunicorn X-Robots-Tag: @@ -233,20 +350,20 @@ interactions: - keep-alive Content-Length: - '0' - Content-Type: - - application/json method: DELETE uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000001 response: body: string: '' headers: + Cache-Control: + - no-store Connection: - close Content-Type: - application/json Date: - - Tue, 30 Jul 2024 12:14:23 GMT + - Fri, 30 Aug 2024 11:32:48 GMT Server: - gunicorn X-Robots-Tag: diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_full_dagrun.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_full_dagrun.yaml index 9cfc7cdc..f871d9af 100644 --- a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_full_dagrun.yaml +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_full_dagrun.yaml @@ -1,7 +1,7 @@ interactions: - request: body: '{"dag_run_id": "00000000-0000-0000-0000-000000000000", "conf": {"workflow_id": - "00000000-0000-0000-0000-000000000000"}}' + "00000000-0000-0000-0000-000000000000", "data": {"test": "test"}}}' headers: Accept: - '*/*' @@ -10,30 +10,33 @@ interactions: Connection: - keep-alive Content-Length: - - '119' + - '145' Content-Type: - application/json method: POST uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns response: body: - string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n - \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000000\",\n \"data_interval_end\": \"2024-07-30T12:14:28.743346+00:00\",\n - \ \"data_interval_start\": \"2024-07-30T12:14:28.743346+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-30T12:14:28.743346+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:14:28.743346+00:00\",\n - \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n - \ \"state\": \"queued\"\n}\n" + string: "{\n \"conf\": {\n \"data\": {\n \"test\": \"test\"\n },\n + \ \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n },\n \"dag_id\": + \"author_create_initialization_dag\",\n \"dag_run_id\": \"00000000-0000-0000-0000-000000000000\",\n + \ \"data_interval_end\": \"2024-08-30T11:39:47.001972+00:00\",\n \"data_interval_start\": + \"2024-08-30T11:39:47.001972+00:00\",\n \"end_date\": null,\n \"execution_date\": + \"2024-08-30T11:39:47.001972+00:00\",\n \"external_trigger\": true,\n \"last_scheduling_decision\": + null,\n \"logical_date\": \"2024-08-30T11:39:47.001972+00:00\",\n \"note\": + null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \"state\": + \"queued\"\n}\n" headers: + Cache-Control: + - no-store Connection: - close Content-Length: - - '579' + - '621' Content-Type: - application/json Date: - - Tue, 30 Jul 2024 12:14:28 GMT + - Fri, 30 Aug 2024 11:39:47 GMT Server: - gunicorn X-Robots-Tag: @@ -50,29 +53,31 @@ interactions: - gzip, deflate Connection: - keep-alive - Content-Type: - - application/json method: GET uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 response: body: - string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n - \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000000\",\n \"data_interval_end\": \"2024-07-30T12:14:28.743346+00:00\",\n - \ \"data_interval_start\": \"2024-07-30T12:14:28.743346+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-30T12:14:28.743346+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:14:28.743346+00:00\",\n - \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n - \ \"state\": \"queued\"\n}\n" + string: "{\n \"conf\": {\n \"data\": {\n \"test\": \"test\"\n },\n + \ \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n },\n \"dag_id\": + \"author_create_initialization_dag\",\n \"dag_run_id\": \"00000000-0000-0000-0000-000000000000\",\n + \ \"data_interval_end\": \"2024-08-30T11:39:47.001972+00:00\",\n \"data_interval_start\": + \"2024-08-30T11:39:47.001972+00:00\",\n \"end_date\": \"2024-08-30T11:40:05.186207+00:00\",\n + \ \"execution_date\": \"2024-08-30T11:39:47.001972+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": \"2024-08-30T11:40:05.185145+00:00\",\n + \ \"logical_date\": \"2024-08-30T11:39:47.001972+00:00\",\n \"note\": null,\n + \ \"run_type\": \"manual\",\n \"start_date\": \"2024-08-30T11:39:47.180195+00:00\",\n + \ \"state\": \"failed\"\n}\n" headers: + Cache-Control: + - no-store Connection: - close Content-Length: - - '579' + - '711' Content-Type: - application/json Date: - - Tue, 30 Jul 2024 12:14:28 GMT + - Fri, 30 Aug 2024 11:40:08 GMT Server: - gunicorn X-Robots-Tag: @@ -89,16 +94,16 @@ interactions: - gzip, deflate Connection: - keep-alive - Content-Type: - - application/json method: GET uri: http://airflow-webserver:8080/api/v1/dags/author_create_approved_dag/dagRuns/00000000-0000-0000-0000-000000000000 response: body: string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_approved_dag' and DagRun ID: '00000000-0000-0000-0000-000000000000' not found\",\n \"status\": - 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.8.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" + 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.9.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" headers: + Cache-Control: + - no-store Connection: - close Content-Length: @@ -106,7 +111,7 @@ interactions: Content-Type: - application/problem+json Date: - - Tue, 30 Jul 2024 12:14:28 GMT + - Fri, 30 Aug 2024 11:40:08 GMT Server: - gunicorn X-Robots-Tag: @@ -123,16 +128,125 @@ interactions: - gzip, deflate Connection: - keep-alive + method: GET + uri: http://airflow-webserver:8080/api/v1/dags/author_create_rejected_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_rejected_dag' + and DagRun ID: '00000000-0000-0000-0000-000000000000' not found\",\n \"status\": + 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.9.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" + headers: + Cache-Control: + - no-store + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Fri, 30 Aug 2024 11:40:08 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 404 + message: NOT FOUND +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + method: GET + uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: "{\n \"conf\": {\n \"data\": {\n \"test\": \"test\"\n },\n + \ \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n },\n \"dag_id\": + \"author_create_initialization_dag\",\n \"dag_run_id\": \"00000000-0000-0000-0000-000000000000\",\n + \ \"data_interval_end\": \"2024-08-30T11:39:47.001972+00:00\",\n \"data_interval_start\": + \"2024-08-30T11:39:47.001972+00:00\",\n \"end_date\": \"2024-08-30T11:40:05.186207+00:00\",\n + \ \"execution_date\": \"2024-08-30T11:39:47.001972+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": \"2024-08-30T11:40:05.185145+00:00\",\n + \ \"logical_date\": \"2024-08-30T11:39:47.001972+00:00\",\n \"note\": null,\n + \ \"run_type\": \"manual\",\n \"start_date\": \"2024-08-30T11:39:47.180195+00:00\",\n + \ \"state\": \"failed\"\n}\n" + headers: + Cache-Control: + - no-store + Connection: + - close + Content-Length: + - '711' Content-Type: - application/json + Date: + - Fri, 30 Aug 2024 11:40:08 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + method: GET + uri: http://airflow-webserver:8080/api/v1/dags/author_create_approved_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_approved_dag' + and DagRun ID: '00000000-0000-0000-0000-000000000000' not found\",\n \"status\": + 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.9.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" + headers: + Cache-Control: + - no-store + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Fri, 30 Aug 2024 11:40:08 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 404 + message: NOT FOUND +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive method: GET uri: http://airflow-webserver:8080/api/v1/dags/author_create_rejected_dag/dagRuns/00000000-0000-0000-0000-000000000000 response: body: string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_rejected_dag' and DagRun ID: '00000000-0000-0000-0000-000000000000' not found\",\n \"status\": - 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.8.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" + 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.9.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" headers: + Cache-Control: + - no-store Connection: - close Content-Length: @@ -140,7 +254,7 @@ interactions: Content-Type: - application/problem+json Date: - - Tue, 30 Jul 2024 12:14:28 GMT + - Fri, 30 Aug 2024 11:40:08 GMT Server: - gunicorn X-Robots-Tag: @@ -159,20 +273,20 @@ interactions: - keep-alive Content-Length: - '0' - Content-Type: - - application/json method: DELETE uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 response: body: string: '' headers: + Cache-Control: + - no-store Connection: - close Content-Type: - application/json Date: - - Tue, 30 Jul 2024 12:14:28 GMT + - Fri, 30 Aug 2024 11:40:08 GMT Server: - gunicorn X-Robots-Tag: @@ -182,7 +296,7 @@ interactions: message: NO CONTENT - request: body: '{"dag_run_id": "00000000-0000-0000-0000-000000000000", "conf": {"workflow_id": - "00000000-0000-0000-0000-000000000000"}}' + "00000000-0000-0000-0000-000000000000", "data": {"test": "test"}}}' headers: Accept: - '*/*' @@ -191,30 +305,33 @@ interactions: Connection: - keep-alive Content-Length: - - '119' + - '145' Content-Type: - application/json method: POST uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns response: body: - string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n - \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000000\",\n \"data_interval_end\": \"2024-07-30T12:14:29.037550+00:00\",\n - \ \"data_interval_start\": \"2024-07-30T12:14:29.037550+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-30T12:14:29.037550+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:14:29.037550+00:00\",\n - \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n - \ \"state\": \"queued\"\n}\n" + string: "{\n \"conf\": {\n \"data\": {\n \"test\": \"test\"\n },\n + \ \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n },\n \"dag_id\": + \"author_create_initialization_dag\",\n \"dag_run_id\": \"00000000-0000-0000-0000-000000000000\",\n + \ \"data_interval_end\": \"2024-08-30T11:40:08.630073+00:00\",\n \"data_interval_start\": + \"2024-08-30T11:40:08.630073+00:00\",\n \"end_date\": null,\n \"execution_date\": + \"2024-08-30T11:40:08.630073+00:00\",\n \"external_trigger\": true,\n \"last_scheduling_decision\": + null,\n \"logical_date\": \"2024-08-30T11:40:08.630073+00:00\",\n \"note\": + null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \"state\": + \"queued\"\n}\n" headers: + Cache-Control: + - no-store Connection: - close Content-Length: - - '579' + - '621' Content-Type: - application/json Date: - - Tue, 30 Jul 2024 12:14:29 GMT + - Fri, 30 Aug 2024 11:40:08 GMT Server: - gunicorn X-Robots-Tag: @@ -233,20 +350,20 @@ interactions: - keep-alive Content-Length: - '0' - Content-Type: - - application/json method: DELETE uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 response: body: string: '' headers: + Cache-Control: + - no-store Connection: - close Content-Type: - application/json Date: - - Tue, 30 Jul 2024 12:14:29 GMT + - Fri, 30 Aug 2024 11:40:08 GMT Server: - gunicorn X-Robots-Tag: diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_with_params.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_with_params.yaml index ca6dbd45..6bbd8613 100644 --- a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_with_params.yaml +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_with_params.yaml @@ -1,7 +1,7 @@ interactions: - request: body: '{"dag_run_id": "00000000-0000-0000-0000-000000000000", "conf": {"workflow_id": - "00000000-0000-0000-0000-000000000000"}}' + "00000000-0000-0000-0000-000000000000", "data": {"test": "test"}}}' headers: Accept: - '*/*' @@ -10,30 +10,33 @@ interactions: Connection: - keep-alive Content-Length: - - '119' + - '145' Content-Type: - application/json method: POST uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns response: body: - string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n - \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000000\",\n \"data_interval_end\": \"2024-07-30T12:14:29.280024+00:00\",\n - \ \"data_interval_start\": \"2024-07-30T12:14:29.280024+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-30T12:14:29.280024+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:14:29.280024+00:00\",\n - \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n - \ \"state\": \"queued\"\n}\n" + string: "{\n \"conf\": {\n \"data\": {\n \"test\": \"test\"\n },\n + \ \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n },\n \"dag_id\": + \"author_create_initialization_dag\",\n \"dag_run_id\": \"00000000-0000-0000-0000-000000000000\",\n + \ \"data_interval_end\": \"2024-08-30T11:37:31.181709+00:00\",\n \"data_interval_start\": + \"2024-08-30T11:37:31.181709+00:00\",\n \"end_date\": null,\n \"execution_date\": + \"2024-08-30T11:37:31.181709+00:00\",\n \"external_trigger\": true,\n \"last_scheduling_decision\": + null,\n \"logical_date\": \"2024-08-30T11:37:31.181709+00:00\",\n \"note\": + null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \"state\": + \"queued\"\n}\n" headers: + Cache-Control: + - no-store Connection: - close Content-Length: - - '579' + - '621' Content-Type: - application/json Date: - - Tue, 30 Jul 2024 12:14:29 GMT + - Fri, 30 Aug 2024 11:37:31 GMT Server: - gunicorn X-Robots-Tag: @@ -50,29 +53,30 @@ interactions: - gzip, deflate Connection: - keep-alive - Content-Type: - - application/json method: GET uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 response: body: - string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n - \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000000\",\n \"data_interval_end\": \"2024-07-30T12:14:29.280024+00:00\",\n - \ \"data_interval_start\": \"2024-07-30T12:14:29.280024+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-30T12:14:29.280024+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:14:29.280024+00:00\",\n - \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n - \ \"state\": \"queued\"\n}\n" + string: "{\n \"conf\": {\n \"data\": {\n \"test\": \"test\"\n },\n + \ \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n },\n \"dag_id\": + \"author_create_initialization_dag\",\n \"dag_run_id\": \"00000000-0000-0000-0000-000000000000\",\n + \ \"data_interval_end\": \"2024-08-30T11:37:31.181709+00:00\",\n \"data_interval_start\": + \"2024-08-30T11:37:31.181709+00:00\",\n \"end_date\": null,\n \"execution_date\": + \"2024-08-30T11:37:31.181709+00:00\",\n \"external_trigger\": true,\n \"last_scheduling_decision\": + null,\n \"logical_date\": \"2024-08-30T11:37:31.181709+00:00\",\n \"note\": + null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \"state\": + \"queued\"\n}\n" headers: + Cache-Control: + - no-store Connection: - close Content-Length: - - '579' + - '621' Content-Type: - application/json Date: - - Tue, 30 Jul 2024 12:14:29 GMT + - Fri, 30 Aug 2024 11:37:31 GMT Server: - gunicorn X-Robots-Tag: @@ -89,16 +93,16 @@ interactions: - gzip, deflate Connection: - keep-alive - Content-Type: - - application/json method: GET uri: http://airflow-webserver:8080/api/v1/dags/author_create_approved_dag/dagRuns/00000000-0000-0000-0000-000000000000 response: body: string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_approved_dag' and DagRun ID: '00000000-0000-0000-0000-000000000000' not found\",\n \"status\": - 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.8.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" + 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.9.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" headers: + Cache-Control: + - no-store Connection: - close Content-Length: @@ -106,7 +110,7 @@ interactions: Content-Type: - application/problem+json Date: - - Tue, 30 Jul 2024 12:14:29 GMT + - Fri, 30 Aug 2024 11:37:31 GMT Server: - gunicorn X-Robots-Tag: @@ -123,16 +127,124 @@ interactions: - gzip, deflate Connection: - keep-alive + method: GET + uri: http://airflow-webserver:8080/api/v1/dags/author_create_rejected_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_rejected_dag' + and DagRun ID: '00000000-0000-0000-0000-000000000000' not found\",\n \"status\": + 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.9.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" + headers: + Cache-Control: + - no-store + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Fri, 30 Aug 2024 11:37:31 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 404 + message: NOT FOUND +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + method: GET + uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: "{\n \"conf\": {\n \"data\": {\n \"test\": \"test\"\n },\n + \ \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n },\n \"dag_id\": + \"author_create_initialization_dag\",\n \"dag_run_id\": \"00000000-0000-0000-0000-000000000000\",\n + \ \"data_interval_end\": \"2024-08-30T11:37:31.181709+00:00\",\n \"data_interval_start\": + \"2024-08-30T11:37:31.181709+00:00\",\n \"end_date\": null,\n \"execution_date\": + \"2024-08-30T11:37:31.181709+00:00\",\n \"external_trigger\": true,\n \"last_scheduling_decision\": + null,\n \"logical_date\": \"2024-08-30T11:37:31.181709+00:00\",\n \"note\": + null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \"state\": + \"queued\"\n}\n" + headers: + Cache-Control: + - no-store + Connection: + - close + Content-Length: + - '621' Content-Type: - application/json + Date: + - Fri, 30 Aug 2024 11:37:31 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + method: GET + uri: http://airflow-webserver:8080/api/v1/dags/author_create_approved_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_approved_dag' + and DagRun ID: '00000000-0000-0000-0000-000000000000' not found\",\n \"status\": + 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.9.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" + headers: + Cache-Control: + - no-store + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Fri, 30 Aug 2024 11:37:31 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 404 + message: NOT FOUND +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive method: GET uri: http://airflow-webserver:8080/api/v1/dags/author_create_rejected_dag/dagRuns/00000000-0000-0000-0000-000000000000 response: body: string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_rejected_dag' and DagRun ID: '00000000-0000-0000-0000-000000000000' not found\",\n \"status\": - 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.8.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" + 404,\n \"title\": \"DAGRun not found\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.9.3/stable-rest-api-ref.html#section/Errors/NotFound\"\n}\n" headers: + Cache-Control: + - no-store Connection: - close Content-Length: @@ -140,7 +252,7 @@ interactions: Content-Type: - application/problem+json Date: - - Tue, 30 Jul 2024 12:14:29 GMT + - Fri, 30 Aug 2024 11:37:31 GMT Server: - gunicorn X-Robots-Tag: @@ -159,20 +271,20 @@ interactions: - keep-alive Content-Length: - '0' - Content-Type: - - application/json method: DELETE uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 response: body: string: '' headers: + Cache-Control: + - no-store Connection: - close Content-Type: - application/json Date: - - Tue, 30 Jul 2024 12:14:29 GMT + - Fri, 30 Aug 2024 11:37:31 GMT Server: - gunicorn X-Robots-Tag: @@ -182,7 +294,7 @@ interactions: message: NO CONTENT - request: body: '{"dag_run_id": "00000000-0000-0000-0000-000000000000", "conf": {"workflow_id": - "00000000-0000-0000-0000-000000000000"}}' + "00000000-0000-0000-0000-000000000000", "data": {"workflow_id": "00000000-0000-0000-0000-000000000000"}}}' headers: Accept: - '*/*' @@ -191,30 +303,33 @@ interactions: Connection: - keep-alive Content-Length: - - '119' + - '184' Content-Type: - application/json method: POST uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns response: body: - string: "{\n \"conf\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n - \ },\n \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": - \"00000000-0000-0000-0000-000000000000\",\n \"data_interval_end\": \"2024-07-30T12:14:29.570410+00:00\",\n - \ \"data_interval_start\": \"2024-07-30T12:14:29.570410+00:00\",\n \"end_date\": - null,\n \"execution_date\": \"2024-07-30T12:14:29.570410+00:00\",\n \"external_trigger\": - true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:14:29.570410+00:00\",\n - \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n - \ \"state\": \"queued\"\n}\n" + string: "{\n \"conf\": {\n \"data\": {\n \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n + \ },\n \"workflow_id\": \"00000000-0000-0000-0000-000000000000\"\n },\n + \ \"dag_id\": \"author_create_initialization_dag\",\n \"dag_run_id\": \"00000000-0000-0000-0000-000000000000\",\n + \ \"data_interval_end\": \"2024-08-30T11:37:31.727158+00:00\",\n \"data_interval_start\": + \"2024-08-30T11:37:31.727158+00:00\",\n \"end_date\": null,\n \"execution_date\": + \"2024-08-30T11:37:31.727158+00:00\",\n \"external_trigger\": true,\n \"last_scheduling_decision\": + null,\n \"logical_date\": \"2024-08-30T11:37:31.727158+00:00\",\n \"note\": + null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n \"state\": + \"queued\"\n}\n" headers: + Cache-Control: + - no-store Connection: - close Content-Length: - - '579' + - '660' Content-Type: - application/json Date: - - Tue, 30 Jul 2024 12:14:29 GMT + - Fri, 30 Aug 2024 11:37:31 GMT Server: - gunicorn X-Robots-Tag: @@ -233,20 +348,20 @@ interactions: - keep-alive Content-Length: - '0' - Content-Type: - - application/json method: DELETE uri: http://airflow-webserver:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 response: body: string: '' headers: + Cache-Control: + - no-store Connection: - close Content-Type: - application/json Date: - - Tue, 30 Jul 2024 12:14:29 GMT + - Fri, 30 Aug 2024 11:37:31 GMT Server: - gunicorn X-Robots-Tag: diff --git a/backoffice/backoffice/workflows/tests/test_airflow_utils.py b/backoffice/backoffice/workflows/tests/test_airflow_utils.py index eb64b541..9b11d1ab 100644 --- a/backoffice/backoffice/workflows/tests/test_airflow_utils.py +++ b/backoffice/backoffice/workflows/tests/test_airflow_utils.py @@ -16,7 +16,7 @@ def setUp(self): self.workflow_type = WorkflowType.AUTHOR_CREATE self.dag_id = WORKFLOW_DAGS[self.workflow_type].initialize self.response = airflow_utils.trigger_airflow_dag( - self.dag_id, str(self.workflow_id) + self.dag_id, str(self.workflow_id), {"test": "test"} ) def tearDown(self): @@ -67,7 +67,12 @@ def test_restart_workflow_dags(self): @pytest.mark.vcr() def test_delete_workflow_dag_runs(self): - response = airflow_utils.delete_workflow_dag_runs( + airflow_utils.delete_workflow_dag_runs(self.workflow_id, self.workflow_type) + + @pytest.mark.vcr() + def test_fetch_data_workflow_dag(self): + result = airflow_utils.fetch_data_workflow_dag( self.workflow_id, self.workflow_type ) - self.assertEqual(response.status_code, 200) + + self.assertEqual(result, {"test": "test"}) diff --git a/backoffice/backoffice/workflows/tests/test_views.py b/backoffice/backoffice/workflows/tests/test_views.py index a9df1599..acb3ccc6 100644 --- a/backoffice/backoffice/workflows/tests/test_views.py +++ b/backoffice/backoffice/workflows/tests/test_views.py @@ -325,7 +325,7 @@ def setUp(self): super().setUp() self.workflow = Workflow.objects.create( - data={}, + data={"test": "test"}, status="running", core=True, is_update=False, @@ -419,8 +419,8 @@ def test_restart_full_dagrun(self): kwargs={"pk": self.workflow.id}, ) response = self.api_client.post(url) - self.assertEqual(response.status_code, 200) + self.assertIn("test", response.json()["conf"]["data"]) @pytest.mark.vcr() def test_restart_a_task(self): @@ -430,7 +430,7 @@ def test_restart_a_task(self): kwargs={"pk": self.workflow.id}, ) response = self.api_client.post( - url, json={"task_ids": ["set_workflow_status_to_running"]} + url, format="json", data={"restart_current_task": True} ) self.assertEqual(response.status_code, 200) @@ -441,9 +441,8 @@ def test_restart_with_params(self): "api:workflows-authors-restart", kwargs={"pk": self.workflow.id}, ) - response = self.api_client.post( - url, json={"params": {"workflow_id": self.workflow.id}} + url, format="json", data={"params": {"workflow_id": self.workflow.id}} ) self.assertEqual(response.status_code, 200)