Skip to content

Commit

Permalink
Merge branch 'opensearch-project:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Tokesh authored Aug 22, 2024
2 parents 1d051cd + b28c1cf commit 9620b94
Show file tree
Hide file tree
Showing 119 changed files with 1,548 additions and 302 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## Spec Test Coverage Analysis
{{with .test_coverage}}

| Total | Tested |
|-------------------|----------------------------------------------------------|
| {{.paths_count}} | {{.evaluated_paths_count}} ({{.evaluated_paths_pct}} %) |
| Total | Tested |
|------------------------------|---------------------------------------------------------------|
| {{.total_operations_count}} | {{.evaluated_operations_count}} ({{.evaluated_paths_pct}} %) |

{{end}}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added `read_time`, `write_time`, `queue_size` and `io_time_in_millis` to `IoStatDevice` ([#483](https://github.com/opensearch-project/opensearch-api-specification/pull/483))
- Added `total_rejections_breakup` to `ShardIndexingPressureStats` ([#483](https://github.com/opensearch-project/opensearch-api-specification/pull/483))
- Added `cancelled_task_percentage` and `current_cancellation_eligible_tasks_count` to `ShardSearchBackpressureTaskCancellationStats` ([#483](https://github.com/opensearch-project/opensearch-api-specification/pull/483))
- Added detailed test coverage report ([#513](https://github.com/opensearch-project/opensearch-api-specification/pull/513))
- Added 404 responses to `/_alias/{name}` and `/{index}/_alias/{name}` ([#519](https://github.com/opensearch-project/opensearch-api-specification/pull/519))

### Changed

Expand Down Expand Up @@ -122,6 +124,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fixed accuracy of the index stats schemas ([#491](https://github.com/opensearch-project/opensearch-api-specification/pull/491))
- Fixed security spec to add support for 400 and 403s ([#439](https://github.com/opensearch-project/opensearch-api-specification/pull/439))
- Fixed required parameters in `NodeInfo` and `NodeOperatingSystemInfo` ([#483](https://github.com/opensearch-project/opensearch-api-specification/pull/483))
- Fixed query DSL `neural` field `query_image` set `contentEncoding` and `model_id` as optional ([#512](https://github.com/opensearch-project/opensearch-api-specification/pull/512))

### Security

Expand Down
49 changes: 45 additions & 4 deletions TESTING_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
- [Warnings](#warnings)
- [multiple-paths-detected](#multiple-paths-detected)
- [Suppressing Warnings](#suppressing-warnings)
- [Collecting Test Coverage](#collecting-test-coverage)
- [Coverage Summary](#coverage-summary)
- [Coverage Report](#coverage-report)
<!-- TOC -->

# Spec Testing Guide
Expand All @@ -37,6 +40,7 @@ docker compose up -d
Run the tests (use `--opensearch-insecure` for a local cluster running in Docker that does not have a valid SSL certificate):
```bash
export OPENSEARCH_PASSWORD=<<your_password>>
npm run test:spec -- --opensearch-insecure
```
Expand All @@ -50,6 +54,11 @@ Verbose output:
npm run test:spec -- --opensearch-insecure --verbose
```
Want to help with some missing tests? Choose from the remaining paths in the test coverage report:
```bash
npm run test:spec -- --opensearch-insecure --coverage-report
```
### Running Spec Tests with Amazon OpenSearch
Use an Amazon OpenSearch service instance.
Expand Down Expand Up @@ -228,13 +237,16 @@ OpenSearch consists of plugins that may or may not be present in various distrib
description: Returns basic information about the cluster.
```
Similarly, skip tests that are not applicable to a distribution by listing the distributions that support it.
Similarly, skip tests that are not applicable to a distribution by listing the distributions that support or do not support it.
```yaml
description: Test root endpoint.
distributions:
- amazon-managed
- opensearch.org
included:
- amazon-managed
- opensearch.org
excluded:
- amazon-serverless
chapters:
- synopsis: Get server info.
path: /
Expand Down Expand Up @@ -299,7 +311,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 All @@ -315,3 +327,32 @@ The test runner may generate warnings that can be suppressed with `warnings:`. F
parameters:
index: movies
```
## Collecting Test Coverage
### Coverage Summary
The test tool can generate a test coverage summary using `--coverage <path>` with the number of evaluated verb + path combinations, a total number of paths and the % of paths tested.
```json
{
"evaluated_operations_count": 214,
"operations_count": 550,
"evaluated_paths_pct": 38.91
}
```
The report is then used by the [test-spec.yml](.github/workflows/test-spec.yml) workflow, uploaded with every run, combined across various versions of OpenSearch, and reported as a comment on each pull request.
### Coverage Report
The test tool can display detailed and hierarchal test coverage with `--coverage-report`. This is useful to identify untested paths. The report produces the following output with the missing ones.
```
/_alias (4)
GET /_alias
/{name} (3)
GET /_alias/{name}
POST /_alias/{name}
HEAD /_alias/{name}
```
12 changes: 12 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 Expand Up @@ -111,6 +113,16 @@ definitions:
type: string

Distributions:
description: |
The list of distributions that support this API.
type: object
properties:
included:
$ref: '#/definitions/DistributionsList'
excluded:
$ref: '#/definitions/DistributionsList'

DistributionsList:
description: |
The list of distributions that support this API.
type: array
Expand Down
28 changes: 27 additions & 1 deletion spec/namespaces/_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,10 @@ paths:
responses:
'200':
$ref: '#/components/responses/search@200'
'400':
$ref: '#/components/responses/search@400'
'404':
$ref: '#/components/responses/search@404'
post:
operationId: search.1
x-operation-group: search
Expand Down Expand Up @@ -755,6 +759,10 @@ paths:
responses:
'200':
$ref: '#/components/responses/search@200'
'400':
$ref: '#/components/responses/search@400'
'404':
$ref: '#/components/responses/search@404'
/_search/point_in_time:
delete:
operationId: delete_pit.0
Expand Down Expand Up @@ -1724,6 +1732,10 @@ paths:
responses:
'200':
$ref: '#/components/responses/search@200'
'400':
$ref: '#/components/responses/search@400'
'404':
$ref: '#/components/responses/search@404'
post:
operationId: search.3
x-operation-group: search
Expand Down Expand Up @@ -1784,6 +1796,10 @@ paths:
responses:
'200':
$ref: '#/components/responses/search@200'
'400':
$ref: '#/components/responses/search@400'
'404':
$ref: '#/components/responses/search@404'
/{index}/_search/point_in_time:
post:
operationId: create_pit.0
Expand Down Expand Up @@ -3044,6 +3060,16 @@ components:
application/json:
schema:
$ref: '../schemas/_core.search.yaml#/components/schemas/ResponseBody'
search@400:
content:
application/json:
schema:
$ref: '../schemas/query._common.yaml#/components/schemas/ErrorResponse'
search@404:
content:
application/json:
schema:
$ref: '../schemas/query._common.yaml#/components/schemas/ErrorResponse'
search_shards@200:
content:
application/json:
Expand Down Expand Up @@ -6259,4 +6285,4 @@ components:
description: The throttle for this request in sub-requests per second.
schema:
type: number
style: form
style: form
3 changes: 3 additions & 0 deletions spec/namespaces/cat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ paths:
operationId: cat.nodeattrs.0
x-operation-group: cat.nodeattrs
x-version-added: '1.0'
x-distributions-excluded:
- amazon-managed
- amazon-serverless
description: Returns information about custom node attributes.
externalDocs:
url: https://opensearch.org/docs/latest/api-reference/cat/cat-nodeattrs/
Expand Down
33 changes: 33 additions & 0 deletions spec/namespaces/indices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ paths:
responses:
'200':
$ref: '#/components/responses/indices.get_alias@200'
'404':
$ref: '#/components/responses/indices.get_alias@404'
put:
operationId: indices.put_alias.0
x-operation-group: indices.put_alias
Expand Down Expand Up @@ -53,6 +55,8 @@ paths:
responses:
'200':
$ref: '#/components/responses/indices.get_alias@200'
'404':
$ref: '#/components/responses/indices.get_alias@404'
head:
operationId: indices.exists_alias.0
x-operation-group: indices.exists_alias
Expand All @@ -69,6 +73,8 @@ paths:
responses:
'200':
$ref: '#/components/responses/indices.exists_alias@200'
'404':
$ref: '#/components/responses/indices.exists_alias@404'
post:
operationId: indices.put_alias.1
x-operation-group: indices.put_alias
Expand Down Expand Up @@ -189,6 +195,9 @@ paths:
operationId: indices.clear_cache.0
x-operation-group: indices.clear_cache
x-version-added: '1.0'
x-distributions-excluded:
- amazon-managed
- amazon-serverless
description: Clears all or specific caches for one or more indices.
externalDocs:
url: https://opensearch.org/docs/latest/api-reference/index-apis/clear-index-cache/
Expand Down Expand Up @@ -319,6 +328,9 @@ paths:
operationId: indices.forcemerge.0
x-operation-group: indices.forcemerge
x-version-added: '1.0'
x-distributions-excluded:
- amazon-managed
- amazon-serverless
description: Performs the force merge operation on one or more indices.
externalDocs:
url: https://opensearch.org/docs/latest
Expand Down Expand Up @@ -589,6 +601,9 @@ paths:
operationId: indices.segments.0
x-operation-group: indices.segments
x-version-added: '1.0'
x-distributions-excluded:
- amazon-managed
- amazon-serverless
description: Provides low-level information about segments in a Lucene index.
externalDocs:
url: https://opensearch.org/docs/latest
Expand All @@ -605,6 +620,9 @@ paths:
operationId: indices.get_settings.0
x-operation-group: indices.get_settings
x-version-added: '1.0'
x-distributions-excluded:
- amazon-managed
- amazon-serverless
description: Returns settings for one or more indices.
externalDocs:
url: https://opensearch.org/docs/latest/api-reference/index-apis/get-settings/
Expand Down Expand Up @@ -1043,6 +1061,8 @@ paths:
responses:
'200':
$ref: '#/components/responses/indices.get_alias@200'
'404':
$ref: '#/components/responses/indices.get_alias@404'
put:
operationId: indices.put_alias.5
x-operation-group: indices.put_alias
Expand Down Expand Up @@ -1078,6 +1098,8 @@ paths:
responses:
'200':
$ref: '#/components/responses/indices.get_alias@200'
'404':
$ref: '#/components/responses/indices.get_alias@404'
head:
operationId: indices.exists_alias.1
x-operation-group: indices.exists_alias
Expand All @@ -1095,6 +1117,8 @@ paths:
responses:
'200':
$ref: '#/components/responses/indices.exists_alias@200'
'404':
$ref: '#/components/responses/indices.exists_alias@404'
post:
operationId: indices.put_alias.6
x-operation-group: indices.put_alias
Expand Down Expand Up @@ -1564,6 +1588,9 @@ paths:
operationId: indices.segments.1
x-operation-group: indices.segments
x-version-added: '1.0'
x-distributions-excluded:
- amazon-managed
- amazon-serverless
description: Provides low-level information about segments in a Lucene index.
externalDocs:
url: https://opensearch.org/docs/latest
Expand Down Expand Up @@ -2402,6 +2429,9 @@ components:
indices.exists_alias@200:
content:
application/json: {}
indices.exists_alias@404:
content:
application/json: {}
indices.exists_index_template@200:
content:
application/json: {}
Expand Down Expand Up @@ -2440,6 +2470,9 @@ components:
type: object
additionalProperties:
$ref: '../schemas/indices.get_alias.yaml#/components/schemas/IndexAliases'
indices.get_alias@404:
content:
application/json: {}
indices.get_data_stream@200:
content:
application/json:
Expand Down
Loading

0 comments on commit 9620b94

Please sign in to comment.