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

Specify warnings at story level. #511

Merged
merged 1 commit into from
Aug 15, 2024
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
2 changes: 1 addition & 1 deletion TESTING_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions json_schemas/test_story.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ properties:
$ref: '#/definitions/Version'
distributions:
$ref: '#/definitions/Distributions'
warnings:
$ref: '#/definitions/Warnings'
required: [chapters,description]
additionalProperties: false

Expand Down
2 changes: 2 additions & 0 deletions tests/default/ingest/pipeline/neural_search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ distributions:
excluded:
- amazon-managed
- amazon-serverless
warnings:
multiple-paths-detected: false
prologues:
- path: /_cluster/settings
method: PUT
Expand Down
16 changes: 9 additions & 7 deletions tools/src/tester/StoryEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -76,25 +77,26 @@ 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
}

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<string, number> = Object.assign((_.values(_.groupBy(normalized_paths)).map(p => { return { [p[0]] : p.length } })))
Expand Down
1 change: 1 addition & 0 deletions tools/src/tester/types/story.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export interface Story {
chapters: Chapter[];
version?: Version;
distributions?: Distributions;
warnings?: Warnings;
}
/**
* This interface was referenced by `Story`'s JSON-Schema
Expand Down
5 changes: 0 additions & 5 deletions tools/tests/tester/fixtures/evals/error/prologue_error.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading