diff --git a/backoffice/backoffice/workflows/api/views.py b/backoffice/backoffice/workflows/api/views.py index c42b1e76..28521e24 100644 --- a/backoffice/backoffice/workflows/api/views.py +++ b/backoffice/backoffice/workflows/api/views.py @@ -163,16 +163,27 @@ def __init__(self, *args, **kwargs): faceted_search_fields = { "status": { - "field": "status", + "field": "status.keyword", "facet": TermsFacet, "options": { - "size": 15, + "size": 10, "order": { "_key": "asc", }, }, "enabled": True, - } + }, + "workflow_type": { + "field": "workflow_type.keyword", + "facet": TermsFacet, + "options": { + "size": 10, + "order": { + "_key": "asc", + }, + }, + "enabled": True, + }, } def get_serializer_class(self): 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 new file mode 100644 index 00000000..b01680d1 --- /dev/null +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_delete_workflow_dag.yaml @@ -0,0 +1,112 @@ +interactions: +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000001", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000001"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal: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:06:19.000776+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:06:19.000776+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:06:19.000776+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:06:19.000776+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:06:19 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 + Content-Length: + - '0' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000001 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:06:19 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 204 + message: NO CONTENT +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000001 + response: + body: + string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_initialization_dag' + and DagRun ID: '00000000-0000-0000-0000-000000000001' 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: + - '293' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:06:19 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 404 + message: NOT FOUND +version: 1 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 new file mode 100644 index 00000000..02718d65 --- /dev/null +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_find_executed_dags.yaml @@ -0,0 +1,183 @@ +interactions: +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000001", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000001"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal: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:06:19.276507+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:06:19.276507+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:06:19.276507+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:06:19.276507+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:06:19 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 + Content-Type: + - application/json + method: GET + uri: http://host.docker.internal: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:06:19.276507+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:06:19.276507+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:06:19.276507+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:06:19.276507+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:06:19 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 + Content-Type: + - application/json + method: GET + uri: http://host.docker.internal: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" + headers: + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:06:19 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-Type: + - application/json + method: GET + uri: http://host.docker.internal: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" + headers: + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:06:19 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' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000001 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:06:19 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_find_failed_dag.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_find_failed_dag.yaml new file mode 100644 index 00000000..91a7615f --- /dev/null +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_find_failed_dag.yaml @@ -0,0 +1,184 @@ +interactions: +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000001", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000001"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal: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:06:19.666679+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:06:19.666679+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:06:19.666679+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:06:19.666679+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:06:19 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 + Content-Type: + - application/json + method: GET + uri: http://host.docker.internal: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:06:19.666679+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:06:19.666679+00:00\",\n \"end_date\": + \"2024-07-30T12:06:38.042999+00:00\",\n \"execution_date\": \"2024-07-30T12:06:19.666679+00:00\",\n + \ \"external_trigger\": true,\n \"last_scheduling_decision\": \"2024-07-30T12:06:38.042015+00:00\",\n + \ \"logical_date\": \"2024-07-30T12:06:19.666679+00:00\",\n \"note\": null,\n + \ \"run_type\": \"manual\",\n \"start_date\": \"2024-07-30T12:06:19.747885+00:00\",\n + \ \"state\": \"failed\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '669' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:06:39 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 + Content-Type: + - application/json + method: GET + uri: http://host.docker.internal: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" + headers: + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:06:39 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-Type: + - application/json + method: GET + uri: http://host.docker.internal: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" + headers: + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:06:39 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' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000001 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:06:39 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_failed_tasks.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_failed_tasks.yaml new file mode 100644 index 00000000..e4ec2ada --- /dev/null +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_failed_tasks.yaml @@ -0,0 +1,230 @@ +interactions: +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000001", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000001"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal: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:06:40.068769+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:06:40.068769+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:06:40.068769+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:06:40.068769+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:06:40 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 + Content-Type: + - application/json + method: GET + uri: http://host.docker.internal: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:06:40.068769+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:06:40.068769+00:00\",\n \"end_date\": + \"2024-07-30T12:06:59.184556+00:00\",\n \"execution_date\": \"2024-07-30T12:06:40.068769+00:00\",\n + \ \"external_trigger\": true,\n \"last_scheduling_decision\": \"2024-07-30T12:06:59.183763+00:00\",\n + \ \"logical_date\": \"2024-07-30T12:06:40.068769+00:00\",\n \"note\": null,\n + \ \"run_type\": \"manual\",\n \"start_date\": \"2024-07-30T12:06:40.967084+00:00\",\n + \ \"state\": \"failed\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '669' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:00 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 + Content-Type: + - application/json + method: GET + uri: http://host.docker.internal: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" + headers: + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:07:00 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-Type: + - application/json + method: GET + uri: http://host.docker.internal: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" + headers: + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:07:00 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 404 + message: NOT FOUND +- request: + body: '{"dry_run": false, "dag_run_id": "00000000-0000-0000-0000-000000000001", + "reset_dag_runs": false, "only_failed": true}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '118' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/clearTaskInstances + response: + 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-30T12:06:40.068769+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-30T12:06:40.068769+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-30T12:06:40.068769+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-30T12:06:40.068769+00:00\",\n + \ \"task_id\": \"set_author_create_workflow_status_to_approval\"\n }\n + \ ]\n}\n" + headers: + Connection: + - close + Content-Length: + - '966' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:00 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 + Content-Length: + - '0' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000001 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:00 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 new file mode 100644 index 00000000..c4643ee4 --- /dev/null +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_workflow_dags.yaml @@ -0,0 +1,257 @@ +interactions: +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000001", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000001"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal: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:07:00.535337+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:07:00.535337+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:07:00.535337+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:07:00.535337+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:00 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 + Content-Type: + - application/json + method: GET + uri: http://host.docker.internal: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:07:00.535337+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:07:00.535337+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:07:00.535337+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:07:00.535337+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:00 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 + Content-Type: + - application/json + method: GET + uri: http://host.docker.internal: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" + headers: + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:07:00 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-Type: + - application/json + method: GET + uri: http://host.docker.internal: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" + headers: + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:07:00 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' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000001 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:00 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 204 + message: NO CONTENT +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000001", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000001"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal: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:07:00.835868+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:07:00.835868+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:07:00.835868+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:07:00.835868+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:00 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 + Content-Length: + - '0' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000001 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:00 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_trigger_airflow_dag.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_trigger_airflow_dag.yaml new file mode 100644 index 00000000..0f0730d3 --- /dev/null +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_trigger_airflow_dag.yaml @@ -0,0 +1,76 @@ +interactions: +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000001", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000001"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal: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:07:01.049218+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:07:01.049218+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:07:01.049218+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:07:01.049218+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:01 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 + Content-Length: + - '0' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000001 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:01 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 204 + message: NO CONTENT +version: 1 diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_accept_author.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_accept_author.yaml new file mode 100644 index 00000000..f13ebe44 --- /dev/null +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_accept_author.yaml @@ -0,0 +1,145 @@ +interactions: +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000000", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000000"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns + response: + body: + string: "{\n \"detail\": \"DAGRun with DAG ID: 'author_create_initialization_dag' + and DAGRun ID: '00000000-0000-0000-0000-000000000000' already exists\",\n + \ \"status\": 409,\n \"title\": \"Conflict\",\n \"type\": \"https://airflow.apache.org/docs/apache-airflow/2.8.3/stable-rest-api-ref.html#section/Errors/AlreadyExists\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '302' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:07:03 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 409 + message: CONFLICT +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000000", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000000", "create_ticket": true}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '142' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal:8080/api/v1/dags/author_create_approved_dag/dagRuns + response: + body: + 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-30T12:07:03.873057+00:00\",\n \"data_interval_start\": \"2024-07-30T12:07:03.873057+00:00\",\n + \ \"end_date\": null,\n \"execution_date\": \"2024-07-30T12:07:03.873057+00:00\",\n + \ \"external_trigger\": true,\n \"last_scheduling_decision\": null,\n \"logical_date\": + \"2024-07-30T12:07:03.873057+00:00\",\n \"note\": null,\n \"run_type\": + \"manual\",\n \"start_date\": null,\n \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '600' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07: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 + Content-Length: + - '0' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_approved_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:03 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 204 + message: NO CONTENT +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:03 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 204 + message: NO CONTENT +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 new file mode 100644 index 00000000..89db2285 --- /dev/null +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_create_author.yaml @@ -0,0 +1,122 @@ +interactions: +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000000", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000000"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal: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:07:04.189966+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:07:04.189966+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:07:04.189966+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:07:04.189966+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:04 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 200 + message: OK +- request: + body: '{"dag_run_id": "6fc3c010-9c71-4b78-a019-b78cb32f4e33", "conf": {"workflow_id": + "6fc3c010-9c71-4b78-a019-b78cb32f4e33", "native_name": "NATIVE_NAME", "alternate_name": + "NAME", "display_name": "FIRST_NAME", "family_name": "LAST_NAME", "given_name": + "GIVEN_NAME"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '261' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns + response: + body: + 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\": + \"6fc3c010-9c71-4b78-a019-b78cb32f4e33\"\n },\n \"dag_id\": \"author_create_initialization_dag\",\n + \ \"dag_run_id\": \"6fc3c010-9c71-4b78-a019-b78cb32f4e33\",\n \"data_interval_end\": + \"2024-07-30T12:07:04.298536+00:00\",\n \"data_interval_start\": \"2024-07-30T12:07:04.298536+00:00\",\n + \ \"end_date\": null,\n \"execution_date\": \"2024-07-30T12:07:04.298536+00:00\",\n + \ \"external_trigger\": true,\n \"last_scheduling_decision\": null,\n \"logical_date\": + \"2024-07-30T12:07:04.298536+00:00\",\n \"note\": null,\n \"run_type\": + \"manual\",\n \"start_date\": null,\n \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '741' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:04 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 + Content-Length: + - '0' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:04 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 204 + message: NO CONTENT +version: 1 diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_reject_author.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_reject_author.yaml new file mode 100644 index 00000000..a53162bb --- /dev/null +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_reject_author.yaml @@ -0,0 +1,150 @@ +interactions: +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000000", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000000"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal: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:07:04.553267+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:07:04.553267+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:07:04.553267+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:07:04.553267+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:04 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 200 + message: OK +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000000", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000000", "create_ticket": true}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '142' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal:8080/api/v1/dags/author_create_rejected_dag/dagRuns + response: + body: + 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-30T12:07:04.624920+00:00\",\n \"data_interval_start\": \"2024-07-30T12:07:04.624920+00:00\",\n + \ \"end_date\": null,\n \"execution_date\": \"2024-07-30T12:07:04.624920+00:00\",\n + \ \"external_trigger\": true,\n \"last_scheduling_decision\": null,\n \"logical_date\": + \"2024-07-30T12:07:04.624920+00:00\",\n \"note\": null,\n \"run_type\": + \"manual\",\n \"start_date\": null,\n \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '600' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:04 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 + Content-Length: + - '0' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_rejected_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:04 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 204 + message: NO CONTENT +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:04 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 204 + message: NO CONTENT +version: 1 diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_a_task.yaml b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_a_task.yaml new file mode 100644 index 00000000..fcec9de7 --- /dev/null +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_a_task.yaml @@ -0,0 +1,257 @@ +interactions: +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000000", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000000"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal: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:07:04.970693+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:07:04.970693+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:07:04.970693+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:07:04.970693+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:04 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 + Content-Type: + - application/json + method: GET + uri: http://host.docker.internal: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:07:04.970693+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:07:04.970693+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:07:04.970693+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:07:04.970693+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:05 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 + Content-Type: + - application/json + method: GET + uri: http://host.docker.internal: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" + headers: + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:07:05 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-Type: + - application/json + method: GET + uri: http://host.docker.internal: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" + headers: + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:07:05 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' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:05 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 204 + message: NO CONTENT +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000000", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000000"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal: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:07:05.281526+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:07:05.281526+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:07:05.281526+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:07:05.281526+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:05 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 + Content-Length: + - '0' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:05 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 204 + message: NO CONTENT +version: 1 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 new file mode 100644 index 00000000..92f78b41 --- /dev/null +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_full_dagrun.yaml @@ -0,0 +1,257 @@ +interactions: +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000000", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000000"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal: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:07:05.601870+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:07:05.601870+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:07:05.601870+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:07:05.601870+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:05 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 + Content-Type: + - application/json + method: GET + uri: http://host.docker.internal: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:07:05.601870+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:07:05.601870+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:07:05.601870+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:07:05.601870+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:05 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 + Content-Type: + - application/json + method: GET + uri: http://host.docker.internal: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" + headers: + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:07:05 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-Type: + - application/json + method: GET + uri: http://host.docker.internal: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" + headers: + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:07:05 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' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:05 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 204 + message: NO CONTENT +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000000", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000000"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal: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:07:05.910319+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:07:05.910319+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:07:05.910319+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:07:05.910319+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:05 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 + Content-Length: + - '0' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:05 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 204 + message: NO CONTENT +version: 1 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 new file mode 100644 index 00000000..49fb2d98 --- /dev/null +++ b/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_with_params.yaml @@ -0,0 +1,257 @@ +interactions: +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000000", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000000"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal: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:07:06.207423+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:07:06.207423+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:07:06.207423+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:07:06.207423+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:06 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 + Content-Type: + - application/json + method: GET + uri: http://host.docker.internal: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:07:06.207423+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:07:06.207423+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:07:06.207423+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:07:06.207423+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:06 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 + Content-Type: + - application/json + method: GET + uri: http://host.docker.internal: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" + headers: + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:07:06 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-Type: + - application/json + method: GET + uri: http://host.docker.internal: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" + headers: + Connection: + - close + Content-Length: + - '294' + Content-Type: + - application/problem+json + Date: + - Tue, 30 Jul 2024 12:07:06 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' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:06 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 204 + message: NO CONTENT +- request: + body: '{"dag_run_id": "00000000-0000-0000-0000-000000000000", "conf": {"workflow_id": + "00000000-0000-0000-0000-000000000000"}}' + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + Content-Length: + - '119' + Content-Type: + - application/json + method: POST + uri: http://host.docker.internal: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:07:06.513856+00:00\",\n + \ \"data_interval_start\": \"2024-07-30T12:07:06.513856+00:00\",\n \"end_date\": + null,\n \"execution_date\": \"2024-07-30T12:07:06.513856+00:00\",\n \"external_trigger\": + true,\n \"last_scheduling_decision\": null,\n \"logical_date\": \"2024-07-30T12:07:06.513856+00:00\",\n + \ \"note\": null,\n \"run_type\": \"manual\",\n \"start_date\": null,\n + \ \"state\": \"queued\"\n}\n" + headers: + Connection: + - close + Content-Length: + - '579' + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:06 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 + Content-Length: + - '0' + Content-Type: + - application/json + method: DELETE + uri: http://host.docker.internal:8080/api/v1/dags/author_create_initialization_dag/dagRuns/00000000-0000-0000-0000-000000000000 + response: + body: + string: '' + headers: + Connection: + - close + Content-Type: + - application/json + Date: + - Tue, 30 Jul 2024 12:07:06 GMT + Server: + - gunicorn + X-Robots-Tag: + - noindex, nofollow + status: + code: 204 + message: NO CONTENT +version: 1 diff --git a/backoffice/backoffice/workflows/tests/test_views.py b/backoffice/backoffice/workflows/tests/test_views.py index f245e830..1d608c35 100644 --- a/backoffice/backoffice/workflows/tests/test_views.py +++ b/backoffice/backoffice/workflows/tests/test_views.py @@ -1,5 +1,7 @@ from unittest.mock import patch +import dateutil +import dateutil.parser from django.apps import apps from django.contrib.auth import get_user_model from django.contrib.auth.models import Group @@ -10,7 +12,7 @@ from rest_framework.test import APIClient from backoffice.workflows.api.serializers import WorkflowTicketSerializer -from backoffice.workflows.constants import StatusChoices +from backoffice.workflows.constants import StatusChoices, WorkflowType from backoffice.workflows.models import WorkflowTicket User = get_user_model() @@ -308,3 +310,98 @@ def test_reject_author(self, mock_post): ) self.assertEqual(response.status_code, 200) + + +class TestWorkflowSearc2hViewSet(BaseTransactionTestCase): + endpoint = "/api/workflows/search/" + reset_sequences = True + fixtures = ["backoffice/fixtures/groups.json"] + + def setUp(self): + super().setUp() + + Workflow.objects.create( + data={}, + status=StatusChoices.APPROVAL, + core=True, + is_update=False, + worfkflow_type=WorkflowType.AUTHOR_CREATE, + ) + Workflow.objects.create( + data={}, + status=StatusChoices.RUNNING, + core=True, + is_update=False, + worfkflow_type=WorkflowType.AUTHOR_CREATE, + ) + + def test_facets(self): + self.api_client.force_authenticate(user=self.admin) + + response = self.api_client.get(reverse("search:workflow-list")) + + assert "_filter_status" in response.json()["facets"] + assert "_filter_workflow_type" in response.json()["facets"] + + def test_search_status(self): + self.api_client.force_authenticate(user=self.admin) + + url = ( + reverse("search:workflow-list") + f"?search=status:{StatusChoices.RUNNING}" + ) + + response = self.api_client.get(url) + + for item in response.json()["results"]: + print(item["status"]) + assert item["status"] == StatusChoices.RUNNING + + def test_search_workflow_type(self): + self.api_client.force_authenticate(user=self.admin) + + url = ( + reverse("search:workflow-list") + + f"?search=workflow_type:{WorkflowType.HEP_CREATE}" + ) + + response = self.api_client.get(url) + + for item in response.json()["results"]: + print(item["workflow_type"]) + assert item["workflow_type"] == WorkflowType.HEP_CREATE + + def test_filter_status(self): + self.api_client.force_authenticate(user=self.admin) + + url = reverse("search:workflow-list") + f'?status="={StatusChoices.RUNNING}' + + response = self.api_client.get(url) + + for item in response.json()["results"]: + assert item["status"] == StatusChoices.RUNNING + + def test_filter_workflow_type(self): + self.api_client.force_authenticate(user=self.admin) + + url = ( + reverse("search:workflow-list") + + f'?workflow_type="={WorkflowType.AUTHOR_CREATE}' + ) + + response = self.api_client.get(url) + + for item in response.json()["results"]: + assert item["workflow_type"] == WorkflowType.AUTHOR_CREATE + + def test_ordering(self): + self.api_client.force_authenticate(user=self.admin) + + url = reverse("search:workflow-list") + "?ordering=-_updated_at" + response = self.api_client.get(url) + + previous_date = None + for item in response.json()["results"]: + cur_date = dateutil.parser.parse(item["_updated_at"]) + if previous_date is not None: + assert cur_date < previous_date + previous_date = cur_date diff --git a/workflows/logs/scheduler/latest b/workflows/logs/scheduler/latest index 2e2f43b7..0574c17f 120000 --- a/workflows/logs/scheduler/latest +++ b/workflows/logs/scheduler/latest @@ -1 +1 @@ -2024-07-30 \ No newline at end of file +2024-07-31 \ No newline at end of file