From c521adb5f9e3bea88ee1ea775204167c71cfc4ce Mon Sep 17 00:00:00 2001 From: Nathalie Jonathan Date: Tue, 31 Dec 2024 12:00:09 -0800 Subject: [PATCH 1/3] Fixed schema validation for invalid properties in retry configuration. Signed-off-by: Nathalie Jonathan --- CHANGELOG.md | 1 + json_schemas/test_story.schema.yaml | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0a81795e..9a10e063e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 ([#X](https://github.com/opensearch-project/opensearch-api-specification/pull/X)) ### 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)) diff --git a/json_schemas/test_story.schema.yaml b/json_schemas/test_story.schema.yaml index 95751843a..6792caad8 100644 --- a/json_schemas/test_story.schema.yaml +++ b/json_schemas/test_story.schema.yaml @@ -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 From 37318b0f574786759c86e7abfad9e68e73bda4ba Mon Sep 17 00:00:00 2001 From: Nathalie Jonathan Date: Tue, 31 Dec 2024 12:06:55 -0800 Subject: [PATCH 2/3] Updated link to PR in CHANGELOG.md. Signed-off-by: Nathalie Jonathan --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a10e063e..c414983f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,7 +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 ([#X](https://github.com/opensearch-project/opensearch-api-specification/pull/X)) +- 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)) From a52e3fab9be414f0bd6cfba3e9b28f44ab3a01fa Mon Sep 17 00:00:00 2001 From: Nathalie Jonathan Date: Tue, 31 Dec 2024 14:17:55 -0800 Subject: [PATCH 3/3] Added a test for the invalid property. Signed-off-by: Nathalie Jonathan --- tools/tests/tester/StoryValidator.test.ts | 7 +++++++ .../tester/fixtures/invalid_property.yaml | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tools/tests/tester/fixtures/invalid_property.yaml diff --git a/tools/tests/tester/StoryValidator.test.ts b/tools/tests/tester/StoryValidator.test.ts index 2feee0189..aa28fdcc0 100644 --- a/tools/tests/tester/StoryValidator.test.ts +++ b/tools/tests/tester/StoryValidator.test.ts @@ -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() diff --git a/tools/tests/tester/fixtures/invalid_property.yaml b/tools/tests/tester/fixtures/invalid_property.yaml new file mode 100644 index 000000000..ca9e7c14c --- /dev/null +++ b/tools/tests/tester/fixtures/invalid_property.yaml @@ -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 \ No newline at end of file