Skip to content

Commit

Permalink
Added support for running tests against Amazon OpenSearch.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Aug 8, 2024
1 parent 41360b7 commit 8cdcb1c
Show file tree
Hide file tree
Showing 10 changed files with 2,374 additions and 99 deletions.
5 changes: 3 additions & 2 deletions .cspell
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ aarch
actiongroup
actiongroups
aggregatable
aoss
APIV
argjson
asciifolding
Expand Down Expand Up @@ -129,6 +130,7 @@ readingform
rebalance
Rebalance
recoverysource
Refn
reindex
Reindex
relo
Expand Down Expand Up @@ -183,5 +185,4 @@ urldecode
vectory
whoamiprotected
wordnet
Yrtsd
Refn
Yrtsd
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- 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))
- Added support for reusing output variables as keys in payload expectations ([#471](https://github.com/opensearch-project/opensearch-api-specification/pull/471))
- Added support for running tests against Amazon OpenSearch ([#476](https://github.com/opensearch-project/opensearch-api-specification/pull/476))

### Changed

Expand Down
30 changes: 24 additions & 6 deletions TESTING_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<!-- TOC -->
- [Spec Testing Guide](#spec-testing-guide)
- [Running Spec Tests Locally](#running-spec-tests-locally)
- [Common Errors](#common-errors)
- [401 Unauthorized](#401-unauthorized)
- [FORBIDDEN/10/cluster create-index blocked (api)](#forbidden10cluster-create-index-blocked-api)
- [Running Spec Tests](#running-spec-tests)
- [Running Spec Tests Locally](#running-spec-tests-locally)
- [Running Spec Tests with Amazon OpenSearch](#running-spec-tests-with-amazon-opensearch)
- [Common Errors](#common-errors)
- [401 Unauthorized](#401-unauthorized)
- [FORBIDDEN/10/cluster create-index blocked (api)](#forbidden10cluster-create-index-blocked-api)
- [Writing Spec Tests](#writing-spec-tests)
- [Simple Test Story](#simple-test-story)
- [Using Output from Previous Chapters](#using-output-from-previous-chapters)
Expand All @@ -18,7 +20,9 @@

We have devised our own test framework to test the spec against an OpenSearch cluster. We're still adding more features to the framework as the needs arise, and this document will be updated accordingly. This test framework has also been integrated into the repo's CI/CD pipeline. Checkout the [test-spec](.github/workflows/test-spec.yml) workflow for more details.

## Running Spec Tests Locally
## Running Spec Tests

### Running Spec Tests Locally

Set up an OpenSearch cluster with Docker:

Expand All @@ -44,11 +48,25 @@ Verbose output:
npm run test:spec -- --opensearch-insecure --verbose
```
### Running Spec Tests with Amazon OpenSearch
Use an Amazon OpenSearch service instance.
```bash
export AWS_ACCESS_KEY_ID=<<your AWS access key ID>>
export AWS_SECRET_ACCESS_KEY=<<your AWS secret access key>>
export AWS_SESSION_TOKEN=<<optional AWS session token>>
export AWS_REGION=us-west-2
export OPENSEARCH_URL=https://....us-west-2.es.amazonaws.com
npm run test:spec
```
### Common Errors
#### 401 Unauthorized
Remember to set the `OPENSEARCH_PASSWORD` environment variable everytime you start a new shell to run the tests.
Remember to set the `OPENSEARCH_PASSWORD` or `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environment variables every time you start a new shell to run the tests.
#### FORBIDDEN/10/cluster create-index blocked (api)
Expand Down
6 changes: 5 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import pluginTs from '@typescript-eslint/eslint-plugin'
import pluginYml from 'eslint-plugin-yml'
import pluginCspell from '@cspell/eslint-plugin'
import pluginStylistic from '@stylistic/eslint-plugin'
import pluginJest from 'eslint-plugin-jest'

export default [
pluginJs.configs.recommended,
Expand All @@ -28,7 +29,8 @@ export default [
'license-header': pluginLicenseHeader,
'eslint-comments': pluginComments,
'@cspell': pluginCspell,
'@stylistic': pluginStylistic
'@stylistic': pluginStylistic,
'jest': pluginJest
},
rules: {
...pluginJs.configs.recommended.rules,
Expand Down Expand Up @@ -78,6 +80,8 @@ export default [
],
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/unbound-method': 'off',
'jest/unbound-method': 'error',
'array-callback-return': 'off',
'indent': ['error', 2, { 'SwitchCase': 1 }],
'new-cap': 'off',
Expand Down
Loading

0 comments on commit 8cdcb1c

Please sign in to comment.