diff --git a/TESTING_GUIDE.md b/TESTING_GUIDE.md index bda054ab7..898b90be3 100644 --- a/TESTING_GUIDE.md +++ b/TESTING_GUIDE.md @@ -302,7 +302,7 @@ WARNING Multiple paths detected, please group similar tests together and move pa #### Suppressing Warnings -The test runner may generate warnings that can be suppressed with `warnings:`. For example, to suppress the multiple paths detected warning. +The test runner may generate warnings that can be suppressed with `warnings:` at story or chapter level. For example, to suppress the multiple paths detected warning. ```yaml - synopsis: Create an index. diff --git a/json_schemas/test_story.schema.yaml b/json_schemas/test_story.schema.yaml index b41a904ef..3a6370c43 100644 --- a/json_schemas/test_story.schema.yaml +++ b/json_schemas/test_story.schema.yaml @@ -23,6 +23,8 @@ properties: $ref: '#/definitions/Version' distributions: $ref: '#/definitions/Distributions' + warnings: + $ref: '#/definitions/Warnings' required: [chapters,description] additionalProperties: false diff --git a/tests/default/ingest/pipeline/neural_search.yaml b/tests/default/ingest/pipeline/neural_search.yaml index 43d476e64..8168c525e 100644 --- a/tests/default/ingest/pipeline/neural_search.yaml +++ b/tests/default/ingest/pipeline/neural_search.yaml @@ -6,6 +6,8 @@ distributions: excluded: - amazon-managed - amazon-serverless +warnings: + multiple-paths-detected: false prologues: - path: /_cluster/settings method: PUT diff --git a/tools/src/tester/StoryEvaluator.ts b/tools/src/tester/StoryEvaluator.ts index 46371a503..fa1e46918 100644 --- a/tools/src/tester/StoryEvaluator.ts +++ b/tools/src/tester/StoryEvaluator.ts @@ -61,6 +61,7 @@ export default class StoryEvaluator { if (variables_error !== undefined) { return variables_error } + const story_outputs = new StoryOutputs() const { evaluations: prologues, has_errors: prologue_errors } = await this.#evaluate_supplemental_chapters(story.prologues ?? [], dry_run, story_outputs) const chapters = await this.#evaluate_chapters(story.chapters, prologue_errors, dry_run, story_outputs, version, distribution) @@ -76,7 +77,7 @@ export default class StoryEvaluator { result: overall_result(prologues.concat(chapters).concat(epilogues).concat(prologues).map(e => e.overall)), } - const warnings = this.#chapter_warnings(story.chapters) + const warnings = this.#chapter_warnings(story) if (warnings !== undefined) { result.warnings = warnings } @@ -84,17 +85,18 @@ export default class StoryEvaluator { return result } - #chapter_warnings(chapters: Chapter[]): string[] | undefined { + #chapter_warnings(story: Story): string[] | undefined { const result = _.compact([ - this.#warning_if_mismatched_chapter_paths(chapters) + this.#warning_if_mismatched_chapter_paths(story) ]) return result.length > 0 ? result : undefined } - #warning_if_mismatched_chapter_paths(chapters: Chapter[]): string | undefined { - const paths = _.compact(_.map(chapters, (chapter) => { - const multiple_paths_detected = chapter.warnings?.['multiple-paths-detected'] ?? true - if (multiple_paths_detected) return chapter.path + #warning_if_mismatched_chapter_paths(story: Story): string | undefined { + if (story.warnings?.['multiple-paths-detected'] === false) return + const paths = _.compact(_.map(story.chapters, (chapter) => { + if (chapter.warnings?.['multiple-paths-detected'] === false) return + return chapter.path })) const normalized_paths = _.map(paths, (path) => path.replaceAll(/\/\{[^}]+}/g, '').replaceAll('//', '/')) const paths_counts: Record = Object.assign((_.values(_.groupBy(normalized_paths)).map(p => { return { [p[0]] : p.length } }))) diff --git a/tools/src/tester/types/story.types.ts b/tools/src/tester/types/story.types.ts index e1937b112..eabb7660b 100644 --- a/tools/src/tester/types/story.types.ts +++ b/tools/src/tester/types/story.types.ts @@ -103,6 +103,7 @@ export interface Story { chapters: Chapter[]; version?: Version; distributions?: Distributions; + warnings?: Warnings; } /** * This interface was referenced by `Story`'s JSON-Schema diff --git a/tools/tests/tester/fixtures/evals/error/prologue_error.yaml b/tools/tests/tester/fixtures/evals/error/prologue_error.yaml index d91beb82f..c27415bf3 100644 --- a/tools/tests/tester/fixtures/evals/error/prologue_error.yaml +++ b/tools/tests/tester/fixtures/evals/error/prologue_error.yaml @@ -3,11 +3,6 @@ full_path: tools/tests/tester/fixtures/stories/error/prologue_error.yaml result: ERROR description: This story should failed due to missing info in the spec. -warnings: - - | - Multiple paths detected, please group similar tests together and move paths not being tested to prologues or epilogues. - /_cat/health - /_cat/indices prologues: - title: PUT /books overall: diff --git a/tools/tests/tester/fixtures/stories/error/prologue_error.yaml b/tools/tests/tester/fixtures/stories/error/prologue_error.yaml index 8b11deb92..b3fd6b8bc 100644 --- a/tools/tests/tester/fixtures/stories/error/prologue_error.yaml +++ b/tools/tests/tester/fixtures/stories/error/prologue_error.yaml @@ -1,6 +1,8 @@ $schema: ../../../../../../json_schemas/test_story.schema.yaml description: This story should failed due to missing info in the spec. +warnings: + multiple-paths-detected: false prologues: - path: /books method: PUT