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

Warn if file path is invalid. #793

Merged
merged 3 commits into from
Jan 20, 2025
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 @@ -53,6 +53,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added `GET /_plugins/_ml/stats/`, `stats/{stat}`, `{nodeId}/stats/`, `{nodeId}/stats/{stat}` ([#794](https://github.com/opensearch-project/opensearch-api-specification/pull/794))
- Added `GET`, `POST /_plugins/_ml/tasks/_search`, `GET /_plugins/_ml/tools`, `tools/{tool_name}` ([#797](https://github.com/opensearch-project/opensearch-api-specification/pull/797))
- Added `POST /_plugins/_ml/agents/{agent_id}/_execute`, `GET /_plugins/_ml/agents/{agent_id}`, `GET`, `POST /_plugins/_ml/agents/_search` ([#798](https://github.com/opensearch-project/opensearch-api-specification/pull/798))
- Added a warning for test file names that don't match the API being tested ([#793](https://github.com/opensearch-project/opensearch-api-specification/pull/793))

### Removed
- Removed unsupported `_common.mapping:SourceField`'s `mode` field and associated `_common.mapping:SourceFieldMode` enum ([#652](https://github.com/opensearch-project/opensearch-api-specification/pull/652))
Expand Down
12 changes: 11 additions & 1 deletion TESTING_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [Waiting for Tasks](#waiting-for-tasks)
- [Warnings](#warnings)
- [multiple-paths-detected](#multiple-paths-detected)
- [invalid-path-detected](#invalid-path-detected)
- [Suppressing Warnings](#suppressing-warnings)
- [Collecting Test Coverage](#collecting-test-coverage)
- [Coverage Summary](#coverage-summary)
Expand Down Expand Up @@ -358,7 +359,7 @@ For example, an ML task returns `CREATED` when created, and `COMPLETED` when it'

#### multiple-paths-detected

The test runner expects all tests in the same file to be variation of the same path in order to keep tests well-organized. Otherwise, a warning will be emitted.
The test runner expects all tests in the same file to be variation of the same path in order to keep tests well-organized. Prerequisites to the API being tested should be moved to `prologues`, and any cleanup to `epilogues`. Otherwise, a warning will be emitted.

```
WARNING Multiple paths detected, please group similar tests together and move paths not being tested to prologues or epilogues.
Expand All @@ -367,6 +368,15 @@ WARNING Multiple paths detected, please group similar tests together and move pa
/{index}
```

#### invalid-path-detected

The test file names are expected to match the one API being tested in that file. Otherwise, a warning will be emitted.

```
PASSED plugins/ml/ml/train_and_predict.yaml (tests/plugins/ml/ml/train_and_predict.yaml)
WARNING Invalid path detected, please move /tests/plugins/ml/ml/train_and_predict.yaml to ml/train_predict.yaml.
```

#### Suppressing Warnings

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.
Expand Down
4 changes: 4 additions & 0 deletions json_schemas/test_story.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,8 @@ definitions:
type: boolean
default: true
description: Enable/disable warnings about multiple paths being tested in the same story.
invalid-path-detected:
type: boolean
default: true
description: Enable/disable warnings about file paths that do not match paths tested in the story.
additionalProperties: false
2 changes: 1 addition & 1 deletion spec/namespaces/ml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ paths:
responses:
'200':
$ref: '#/components/responses/ml.get_stats@200'
/_plugins/_ml/{node_id}/stats/:
/_plugins/_ml/{node_id}/stats:
get:
operationId: ml.get_stats.2
x-operation-group: ml.get_stats
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/analyze/filter/asciifolding.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test /_analyze with a filter.
warnings:
invalid-path-detected: false
version: '>= 2.17'
chapters:
- synopsis: Apply a asciifolding filter.
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/analyze/filter/lowercase.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test /_analyze with a filter.
warnings:
invalid-path-detected: false
chapters:
- synopsis: Apply a lowercase character filter.
path: /_analyze
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/analyze/filter/persian_stem.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test /_analyze with a filter.
warnings:
invalid-path-detected: false
version: '>= 2.17'
chapters:
- synopsis: Apply a persian_stem filter.
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/analyze/filter/porterstem.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test /_analyze with a filter.
warnings:
invalid-path-detected: false
version: '>= 2.17'
chapters:
- synopsis: Apply a porter_stem filter.
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/analyze/filter/stop.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test /_analyze with a filter.
warnings:
invalid-path-detected: false
chapters:
- synopsis: Combine a lowercase translation with a stop filter.
path: /_analyze
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/analyze/filter/uppercase.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test /_analyze with a filter.
warnings:
invalid-path-detected: false
chapters:
- synopsis: Apply an uppercase character filter.
path: /_analyze
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/info.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test root endpoint.
warnings:
invalid-path-detected: false
distributions:
excluded:
- amazon-serverless
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$schema: ../../../../json_schemas/test_story.schema.yaml
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test document multi-search.
epilogues:
Expand Down
1 change: 1 addition & 0 deletions tests/default/_core/reindex/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $schema: ../../../../json_schemas/test_story.schema.yaml

description: Test reindex with a Search pipeline.
warnings:
invalid-path-detected: false
multiple-paths-detected: false
epilogues:
- path: /movies
Expand Down
3 changes: 2 additions & 1 deletion tests/default/_core/scripts/context.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test the _scripts contexts endpoint.

warnings:
invalid-path-detected: false
prologues:
- path: /_scripts/add_ratings
method: DELETE
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/_source.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test search endpoint (_source).
warnings:
invalid-path-detected: false
prologues:
- path: /movies/_doc
method: POST
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/aggregations/avg.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test avg aggregation.
warnings:
invalid-path-detected: false
prologues:
- path: /_bulk
method: POST
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/aggregations/historgram.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test histogram aggregation.
warnings:
invalid-path-detected: false
prologues:
- path: /_bulk
method: POST
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/aggregations/max.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test max aggregation.
warnings:
invalid-path-detected: false
prologues:
- path: /_bulk
method: POST
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/aggregations/min.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test min aggregation.
warnings:
invalid-path-detected: false
prologues:
- path: /_bulk
method: POST
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/aggregations/nested.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test aggregation.
warnings:
invalid-path-detected: false
prologues:
- path: books
method: PUT
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/aggregations/range.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test range aggregation.
warnings:
invalid-path-detected: false
prologues:
- path: /_bulk
method: POST
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/aggregations/sum.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test sum aggregation.
warnings:
invalid-path-detected: false
prologues:
- path: /_bulk
method: POST
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/aggregations/terms.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test terms aggregation.
warnings:
invalid-path-detected: false
prologues:
- path: /movies
method: PUT
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/cancel_after_time_interval.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with cancel_after_time_interval.
warnings:
invalid-path-detected: false
prologues:
- path: /movies/_doc
method: POST
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/knn/on_disk.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with knn query.
warnings:
invalid-path-detected: false
version: '>= 2.17'

prologues:
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/match.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with match query.
warnings:
invalid-path-detected: false
prologues:
- path: /movies/_doc
method: POST
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/multi_match.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with multi_match query.
warnings:
invalid-path-detected: false
prologues:
- path: /movies/_doc
method: POST
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/phase_took.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with phase_took.
warnings:
invalid-path-detected: false
prologues:
- path: /movies/_doc
method: POST
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test the creation of a search pipeline.
warnings:
invalid-path-detected: false
version: '>= 2.9'
epilogues:
- path: /_search/pipeline/empty-pipeline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ $schema: ../../../../../../json_schemas/test_story.schema.yaml

description: |-
Test the creation of a search pipeline with a filter_query request processor.
warnings:
invalid-path-detected: false
version: '>= 2.8'
prologues:
- path: /_bulk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ $schema: ../../../../../../json_schemas/test_story.schema.yaml

description: |-
Test the creation of a search pipeline with a response processor.
warnings:
invalid-path-detected: false
version: '>= 2.8'
prologues:
- path: /movies/_doc/1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ $schema: ../../../../../../json_schemas/test_story.schema.yaml

description: |-
Test the creation of a search pipeline with a response processor.
warnings:
invalid-path-detected: false
version: '>= 2.16'
prologues:
- path: /movies/_doc/1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ $schema: ../../../../../../json_schemas/test_story.schema.yaml

description: |-
Test the creation of a search pipeline with split and sort response processors.
warnings:
invalid-path-detected: false
version: '>= 2.17'
prologues:
- path: /numbers/_doc/1
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/point_in_time.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../json_schemas/test_story.schema.yaml

description: Test point-in-time.
warnings:
invalid-path-detected: false
version: '>= 2.4'
epilogues:
- path: /_search/point_in_time/_all
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$schema: ../../../../json_schemas/test_story.schema.yaml
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test point-in-time.
version: '>= 2.4'
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/query/fuzzy.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with fuzzy query.
warnings:
invalid-path-detected: false
prologues:
- path: /movies
method: PUT
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/query/geo_bounding_box.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with geo_bounding_box query.
warnings:
invalid-path-detected: false
prologues:
- path: /cinemas
method: PUT
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/query/geo_distance.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with geo_distance query.
warnings:
invalid-path-detected: false
prologues:
- path: /cinemas
method: PUT
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/query/geo_shape_point.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with geo_shape query.
warnings:
invalid-path-detected: false
prologues:
- path: /cinemas
method: PUT
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/query/geo_shape_shape.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test search endpoint with geo_shape query.
warnings:
invalid-path-detected: false
prologues:
- path: /cinemas
method: PUT
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/query/script.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../json_schemas/test_story.schema.yaml

description: Test ScriptQuery functionality.
warnings:
invalid-path-detected: false

prologues:
- path: /movies
Expand Down
2 changes: 2 additions & 0 deletions tests/default/_core/search/query/terms/array_terms.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
$schema: ../../../../../../json_schemas/test_story.schema.yaml

description: Comprehensive test suite for TermsQuery, including array of terms.
warnings:
invalid-path-detected: false
version: '>= 1.2'

prologues:
Expand Down
Loading
Loading