Skip to content

Commit

Permalink
Fixed schema validation for invalid properties in retry configuration. (
Browse files Browse the repository at this point in the history
#758)

* Fixed schema validation for invalid properties in retry configuration.

Signed-off-by: Nathalie Jonathan <[email protected]>

* Updated link to PR in CHANGELOG.md.

Signed-off-by: Nathalie Jonathan <[email protected]>

* Added a test for the invalid property.

Signed-off-by: Nathalie Jonathan <[email protected]>

---------

Signed-off-by: Nathalie Jonathan <[email protected]>
  • Loading branch information
nathaliellenaa authored Jan 2, 2025
1 parent a3849b4 commit 24872ec
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fixed type in `_msearch/template` ([#735](https://github.com/opensearch-project/opensearch-api-specification/pull/735))
- Fixed indices API schemas ([#750](https://github.com/opensearch-project/opensearch-api-specification/pull/750))
- Fixed cluster API schemas ([#754](https://github.com/opensearch-project/opensearch-api-specification/pull/754))
- Fixed schema validation for invalid properties in `retry` configuration ([#758](https://github.com/opensearch-project/opensearch-api-specification/pull/758))

### Changed
- Changed `tasks._common:TaskInfo` and `tasks._common:TaskGroup` to be composed of a `tasks._common:TaskInfoBase` ([#683](https://github.com/opensearch-project/opensearch-api-specification/pull/683))
Expand Down
22 changes: 11 additions & 11 deletions json_schemas/test_story.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,17 @@ definitions:
Retry:
description: |
Number of times to retry on error.
oneOf:
- type: object
properties:
count:
type: integer
description: Number of retries.
wait:
type: integer
description: Number of milliseconds to wait before retrying.
required:
- count
type: object
properties:
count:
type: integer
description: Number of retries.
wait:
type: integer
description: Number of milliseconds to wait before retrying.
required:
- count
additionalProperties: false

Request:
type: object
Expand Down
7 changes: 7 additions & 0 deletions tools/tests/tester/StoryValidator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ describe('StoryValidator', () => {
"data/chapters/0/synopsis must match pattern \"^\\p{Lu}[\\s\\S]*\\.$|^\\p{Lu}[\\s\\S]*\\. \\[(GET|PUT|POST|DELETE|PATCH|HEAD|OPTIONS)\\]$\"")
})

test('invalid property', () => {
const evaluation = validate('tools/tests/tester/fixtures/invalid_property.yaml')
expect(evaluation?.result).toBe('ERROR')
expect(evaluation?.message).toBe("Invalid Story: " +
"data/prologues/0/retry contains unsupported properties: until")
})

test('valid story', () => {
const evaluation = validate('tools/tests/tester/fixtures/valid_story.yaml')
expect(evaluation).toBeUndefined()
Expand Down
20 changes: 20 additions & 0 deletions tools/tests/tester/fixtures/invalid_property.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: This story has invalid property for retry configuration when validated against test_story.schema.yaml.
prologues:
- path: /{index}
method: GET
retry:
count: 5
wait: 30000
until: # invalid property
- path: payload.state
equal: COMPLETED
epilogues:
- path: /{index}
method: DELETE
status: [200, 404]
chapters:
- synopsis: Delete index.
path: /{index}
method: DELETE

0 comments on commit 24872ec

Please sign in to comment.