Skip to content

Commit

Permalink
Flow_framework spec refactor: Added Tests, Param, and Error Types (#574)
Browse files Browse the repository at this point in the history
* refactor:
1. Added missing param for update workflow request body
2. Added test for create workflow with sample test

Signed-off-by: Junwei Dai <[email protected]>

* Update schema to use application/json content type

Signed-off-by: Junwei Dai <[email protected]>

* Update schema to use application/json content type

Signed-off-by: Junwei Dai <[email protected]>

* Update the template link to pass the link check

Signed-off-by: Junwei Dai <[email protected]>

---------

Signed-off-by: Junwei Dai <[email protected]>
Co-authored-by: Junwei Dai <[email protected]>
  • Loading branch information
junweid62 and Junwei Dai authored Sep 17, 2024
1 parent 8fe6a49 commit d4d4fa9
Show file tree
Hide file tree
Showing 8 changed files with 291 additions and 61 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added `xy_shape` query ([#531](https://github.com/opensearch-project/opensearch-api-specification/pull/531))
- Added `/_plugins/_flow_framework/` ,`_search`,`state/_search`,`_provision`,`_deprovision`,`_steps`,`_status`([#508](https://github.com/opensearch-project/opensearch-api-specification/issues/508))
- Added `/_plugins/_ism/policies`, `add`, `remove`, `change_policy`, `explain` ([#568](https://github.com/opensearch-project/opensearch-api-specification/pull/568))
- Added more 4xx errors to `/_plugins/_flow_framework/` and added sample template test ([#833](https://github.com/opensearch-project/flow-framework/issues/833)

### Changed

Expand Down
7 changes: 7 additions & 0 deletions spec/namespaces/flow_framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ components:
- $ref: '../schemas/flow_framework.errors.yaml#/components/schemas/ParameterConflictError'
- $ref: '../schemas/flow_framework.errors.yaml#/components/schemas/MaxWorkflowsLimitError'
- $ref: '../schemas/flow_framework.errors.yaml#/components/schemas/WorkflowSaveError'
- $ref: '../schemas/flow_framework.errors.yaml#/components/schemas/WorkflowParsingError'
- $ref: '../schemas/flow_framework.errors.yaml#/components/schemas/UnsupportedFieldUpdateError'
- $ref: '../schemas/flow_framework.errors.yaml#/components/schemas/InvalidTemplateVersionError'
- $ref: '../schemas/flow_framework.errors.yaml#/components/schemas/TemplateNameRequiredError'
flow_framework.update@400:
description: Bad Request - Multiple possible reasons
content:
Expand All @@ -423,6 +427,9 @@ components:
- $ref: '../schemas/flow_framework.errors.yaml#/components/schemas/ParameterConflictError'
- $ref: '../schemas/flow_framework.errors.yaml#/components/schemas/MaxWorkflowsLimitError'
- $ref: '../schemas/flow_framework.errors.yaml#/components/schemas/WorkflowSaveError'
- $ref: '../schemas/flow_framework.errors.yaml#/components/schemas/InvalidTemplateVersionError'
- $ref: '../schemas/flow_framework.errors.yaml#/components/schemas/UnsupportedFieldUpdateError'
- $ref: '../schemas/flow_framework.errors.yaml#/components/schemas/WorkflowParsingError'
flow_framework.update@201:
content:
application/json:
Expand Down
2 changes: 2 additions & 0 deletions spec/schemas/flow_framework.common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ components:
use_case:
type: string
description: A use case, which can be used with the Search Workflow API to find related workflows.
workflows:
type: object
version:
$ref: '#/components/schemas/version'
minProperties: 1
Expand Down
53 changes: 43 additions & 10 deletions spec/schemas/flow_framework.errors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ components:
application/json:
type: object
properties:
message:
error:
type: string
example: This API is disabled. To enable it, set [flow_framework.enabled] to true.
status:
Expand All @@ -21,7 +21,7 @@ components:
application/json:
type: object
properties:
message:
error:
type: string
example: Only the parameters [param1, param2] are permitted unless the provision parameter is set to true.
status:
Expand All @@ -31,7 +31,7 @@ components:
application/json:
type: object
properties:
message:
error:
type: string
example: You cannot use both the 'provision_workflow' and 'update_workflow_fields' parameters in the same request.
status:
Expand All @@ -41,7 +41,7 @@ components:
application/json:
type: object
properties:
message:
error:
type: string
example: You cannot use the 'reprovision_workflow' parameter to create a new template.
status:
Expand All @@ -51,7 +51,7 @@ components:
application/json:
type: object
properties:
message:
error:
type: string
example: You cannot use the 'reprovision_workflow' and 'use_case' parameters in the same request.
status:
Expand All @@ -61,7 +61,7 @@ components:
application/json:
type: object
properties:
message:
error:
type: string
example: Workflow ID can not be null
status:
Expand Down Expand Up @@ -100,7 +100,7 @@ components:
application/json:
type: object
properties:
message:
error:
type: string
example: Failed to save workflow state
status:
Expand All @@ -110,27 +110,60 @@ components:
application/json:
type: object
properties:
message:
error:
type: string
example: Maximum workflows limit reached 50
code:
type: integer
TemplateNameRequiredError:
type: object
properties:
error:
type: string
description: Error message when the template name is missing.
TemplateNotFoundError:
content:
application/json:
type: object
properties:
message:
error:
type: string
example: Failed to retrieve template (12345) from global context.
code:
type: integer
InvalidTemplateVersionError:
content:
application/json:
type: object
properties:
error:
type: string
description: Error message when the template version is invalid or missing.
example: Unable to parse field [version] in a version object.
UnsupportedFieldUpdateError:
content:
application/json:
type: object
properties:
error:
type: string
description: Error message when trying to update an unsupported field in a template.
example: You can not update the field [fieldName] without updating the whole template.
WorkflowParsingError:
content:
application/json:
type: object
properties:
error:
type: string
description: Error message when workflow parsing fails.
example: Unable to parse field [workflow] in a template object.
WorkflowStepsRetrieveError:
content:
application/json:
type: object
properties:
message:
error:
type: string
example: Failed to retrieve workflow step json.
code:
Expand Down
20 changes: 0 additions & 20 deletions tests/default/flow_framework/deprovision.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,13 @@ epilogues:
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
chapters:
- synopsis: Check the provision status before calling the deprovision API.
path: /_plugins/_flow_framework/workflow/{workflow_id}/_status
method: GET
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
response:
status: 200
payload:
workflow_id: ${create_flow_framework.test_workflow_id}
state: PROVISIONING
- synopsis: Deprovision workflow.
path: /_plugins/_flow_framework/workflow/{workflow_id}/_deprovision
method: POST
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
response:
status: 200
- synopsis: Check the provision status after calling the deprovision API.
path: /_plugins/_flow_framework/workflow/{workflow_id}/_status
method: GET
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
response:
status: 200
payload:
workflow_id: ${create_flow_framework.test_workflow_id}
state: NOT_STARTED
- synopsis: Deprovision workflow using an invalid ID.
path: /_plugins/_flow_framework/workflow/{workflow_id}/_deprovision
method: POST
Expand Down
22 changes: 1 addition & 21 deletions tests/default/flow_framework/provision.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ epilogues:
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
chapters:
- synopsis: Check the status before calling provision API.
path: /_plugins/_flow_framework/workflow/{workflow_id}/_status
method: GET
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
response:
status: 200
payload:
workflow_id: ${create_flow_framework.test_workflow_id}
state: NOT_STARTED
- synopsis: Provision workflow.
path: /_plugins/_flow_framework/workflow/{workflow_id}/_provision
method: POST
Expand All @@ -42,14 +32,4 @@ chapters:
payload:
openai_key: '1234556'
response:
status: 200
- synopsis: Check the provision status after calling provision API.
path: /_plugins/_flow_framework/workflow/{workflow_id}/_status
method: GET
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
response:
status: 200
payload:
workflow_id: ${create_flow_framework.test_workflow_id}
state: PROVISIONING
status: 200
Loading

0 comments on commit d4d4fa9

Please sign in to comment.