Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed schema validation for invalid properties in retry configuration. #758

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading