Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into update-testingguide-errors
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Wick <andywick@amazon.com>
  • Loading branch information
awick committed Aug 5, 2024
2 parents 6dd4e56 + c0d4a85 commit 1217e36
Show file tree
Hide file tree
Showing 139 changed files with 806 additions and 608 deletions.
3 changes: 2 additions & 1 deletion .cspell
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,5 @@ urldecode
vectory
whoamiprotected
wordnet
Yrtsd
Yrtsd
Refn
6 changes: 3 additions & 3 deletions .github/opensearch-cluster/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ services:
opensearch-cluster:
image: ${OPENSEARCH_DOCKER_HUB_PROJECT:-opensearchproject}/opensearch:${OPENSEARCH_VERSION:-latest}${OPENSEARCH_DOCKER_REF}
ports:
- '9200:9200'
- '9600:9600'
- 9200:9200
- 9600:9600
environment:
- 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!}'
- OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!}
- OPENSEARCH_JAVA_OPTS=${OPENSEARCH_JAVA_OPTS}
- discovery.type=single-node
- path.repo=/tmp/opensearch/repo
Expand Down
24 changes: 20 additions & 4 deletions .github/workflows/test-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ jobs:
strategy:
matrix:
entry:
- {version: 1.3.17, admin_password: admin}
- {version: 2.0.0, admin_password: admin}
- {version: 2.15.0}
- version: 1.3.17
admin_password: admin
- version: 2.0.0
admin_password: admin
- version: 2.15.0
- version: 2.16.0
hub: opensearchstaging
ref: '@sha256:50fbfe3b95c41e92a113ada3e80513ba4524dfc8a25dc6aaeff2bbe1e1145d5f'
ref: '@sha256:bcd7f5d5d30231f24f266064248cc8d3306574948190f7bf93016dff29acf17e'
- version: 3.0.0
hub: opensearchstaging
ref: '@sha256:db1918b2b8f7ef6c22dd6ff54a0640877c3d395a392a53864745024933981e3b'

name: test-opensearch-spec (version=${{ matrix.entry.version }}, hub=${{ matrix.entry.hub || 'opensearchproject' }})
runs-on: ubuntu-latest
Expand Down Expand Up @@ -56,13 +61,24 @@ jobs:
working-directory: .github/opensearch-cluster
run: docker compose up -d

- name: Get Container ID
id: container
run: |
echo "CONTAINER_ID=$(docker ps -aqf "ancestor=opensearchproject/opensearch:${{ matrix.entry.version }}")" >> $GITHUB_OUTPUT
- name: Run Tests
run: |
npm run test:spec -- \
--opensearch-insecure \
--opensearch-version=${{ matrix.entry.version }} \
--coverage coverage/test-spec-coverage-${{ matrix.entry.version }}.json
- name: Get Container Logs
if: failure() && steps.container.outputs.CONTAINER_ID
run: |
echo Dumping logs from ${{ steps.container.outputs.CONTAINER_ID }} ...
docker logs ${{ steps.container.outputs.CONTAINER_ID }}
- name: Upload Test Coverage Results
uses: actions/upload-artifact@v4
with:
Expand Down
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added `plugins` to NodeInfoSettings ([#442](https://github.com/opensearch-project/opensearch-api-specification/pull/442))
- Added test coverage ([#443](https://github.com/opensearch-project/opensearch-api-specification/pull/443))
- Added `--opensearch-version` to `merger` that excludes schema elements per semver ([#428](https://github.com/opensearch-project/opensearch-api-specification/pull/428))
- Added `retry` to `tester` to support asynchronous tasks ([453](https://github.com/opensearch-project/opensearch-api-specification/pull/453))
- Added `retry` to `tester` to support asynchronous tasks ([#453](https://github.com/opensearch-project/opensearch-api-specification/pull/453))
- Added passing OPENSEARCH_JAVA_OPTS into the docker container used for tests ([#454](https://github.com/opensearch-project/opensearch-api-specification/pull/454))
- Added a warning on mulitple paths being tested in the same file ([#452](https://github.com/opensearch-project/opensearch-api-specification/pull/452))
- Added validation of titles and descriptions in info and schema objects ([#463](https://github.com/opensearch-project/opensearch-api-specification/pull/463))
- Added `/_plugins/_query/settings` ([#456](https://github.com/opensearch-project/opensearch-api-specification/pull/456))
- Added `/_plugins/_ppl`, `explain` and `stats` ([#460](https://github.com/opensearch-project/opensearch-api-specification/pull/460))
- Added tests against OpenSearch 3.0 ([#459](https://github.com/opensearch-project/opensearch-api-specification/pull/459))
- Added support for request headers in tests [#461](https://github.com/opensearch-project/opensearch-api-specification/pull/461)
- Added metadata additionalProperties to `ErrorCause` ([#462](https://github.com/opensearch-project/opensearch-api-specification/pull/462))
- Added `creation_date` field to `DanglingIndex` ([#462](https://github.com/opensearch-project/opensearch-api-specification/pull/462))
- Added doc on `cluster create-index blocked` workaround ([#465](https://github.com/opensearch-project/opensearch-api-specification/pull/465))

### Changed

- Replaced Smithy with a native OpenAPI spec ([#189](https://github.com/opensearch-project/opensearch-api-specification/issues/189))
Expand Down
17 changes: 10 additions & 7 deletions TESTING_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ chapters:
- synopsis: Create an index named `books` with mappings and settings.
path: /{index} # The test will fail if "PUT /{index}" operation is not found in the spec.
method: PUT
parameters: # All parameters are validated against their schemas in the spec
parameters: # All parameters are validated against their schemas in the spec.
index: books
request_body: # The request body is validated against the schema of the requestBody in the spec
payload:
request: # The request.
headers: # Optional headers.
user-agent: OpenSearch API Spec/1.0
payload: # The request body is validated against the schema of the requestBody in the spec.
mappings:
properties:
name:
Expand All @@ -109,7 +111,8 @@ chapters:
settings:
number_of_shards: 5
number_of_replicas: 2
response: # The response body is validated against the schema of the corresponding response in the spec
response: # The response.
payload: # Matching response payload. The entire payload is validated against the schema of the corresponding response in the spec.
status: 200 # This is the expected status code of the response. Any other status code will fail the test.
- synopsis: Retrieve the mappings and settings of the `books` index.
Expand All @@ -134,10 +137,10 @@ Consider the following chapters in [ml/model_groups](tests/ml/model_groups.yaml)
id: create_model_group # Only needed if you want to refer to this chapter in another chapter.
path: /_plugins/_ml/model_groups/_register
method: POST
request_body:
request:
payload:
name: "NLP_Group"
description: "Model group for NLP models"
name: NLP_Group
description: Model group for NLP models.
response:
status: 200
output: # Save the model group id for later use.
Expand Down
19 changes: 14 additions & 5 deletions json_schemas/test_story.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ definitions:
type: object
additionalProperties:
$ref: '#/definitions/Parameter'
request_body:
$ref: '#/definitions/RequestBody'
request:
$ref: '#/definitions/Request'
output:
$ref: '#/definitions/Output'
version:
Expand All @@ -94,7 +94,7 @@ definitions:
The values are paths to the values in the response.
The values should be in the form:
- `payload.<payload-path>` for the payload
- `headers.<header-name>` for the headers
- `headers.<header-name>` for the headers.
type: object
additionalProperties:
type: string
Expand All @@ -119,15 +119,18 @@ definitions:
required:
- count

RequestBody:
Request:
type: object
properties:
content_type:
type: string
default: application/json
headers:
type: object
additionalProperties:
$ref: '#/definitions/Header'
payload:
$ref: '#/definitions/Payload'
required: [payload]
additionalProperties: false

ExpectedResponse:
Expand Down Expand Up @@ -163,6 +166,12 @@ definitions:
required: [content_type, payload, status]
additionalProperties: false

Header:
anyOf:
- type: string
- type: number
- type: boolean

Payload:
anyOf:
- type: object
Expand Down
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"scripts": {
"coverage:spec": "ts-node tools/src/coverage/coverage.ts",
"dump-cluster-spec": "ts-node tools/src/dump-cluster-spec/dump-cluster-spec.ts",
"generate-types": "ts-node tools/src/tester/_generate_story_types.ts",
"lint:spec": "ts-node tools/src/linter/lint.ts",
"lint": "eslint . --report-unused-disable-directives",
"lint--fix": "eslint . --fix --report-unused-disable-directives",
Expand All @@ -30,6 +31,7 @@
"@types/lodash": "^4.14.202",
"@types/node": "^20.10.3",
"@types/qs": "^6.9.15",
"@types/titlecase": "^1.1.2",
"@types/tmp": "^0.2.6",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"ajv": "^8.13.0",
Expand All @@ -52,6 +54,7 @@
"lodash": "^4.17.21",
"qs": "^6.12.1",
"smile-js": "^0.7.0",
"titlecase": "^1.1.3",
"tmp": "^0.2.3",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.1",
Expand Down
Loading

0 comments on commit 1217e36

Please sign in to comment.