Skip to content

Commit

Permalink
Document fielddata.yaml fail, ignore vim swp files (#473)
Browse files Browse the repository at this point in the history
* Document fielddata.yaml fail, ignore vim swp files

* Ignore test files that start with . so vim swp files are ignored
* fielddata.yaml test files if opensearch cluster was stopped with
  docker kill instead of docker stop, document the issue
* upgrade remaining actions/checkout@v3 to v4 to stop warnings

Signed-off-by: Andy Wick <[email protected]>

* fixed FAILED placment

Signed-off-by: Andy Wick <[email protected]>

* switch to only processing .yaml files

Signed-off-by: Andy Wick <[email protected]>

* Remove EXCLUDED_FILES instead only process .yaml

Signed-off-by: Andy Wick <[email protected]>

---------

Signed-off-by: Andy Wick <[email protected]>
  • Loading branch information
awick authored Aug 11, 2024
1 parent d7e6971 commit 56a5a22
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
verify-changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.event.pull_request.head.sha }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
if: github.event_name == 'pull_request'
needs: test-opensearch-spec
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Download Spec Coverage Data
uses: actions/download-artifact@v4
Expand Down
4 changes: 4 additions & 0 deletions TESTING_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [Common Errors](#common-errors)
- [401 Unauthorized](#401-unauthorized)
- [FORBIDDEN/10/cluster create-index blocked (api)](#forbidden10cluster-create-index-blocked-api)
- [FAILED Cat with a json response (from security-analytics).](#failed--cat-with-a-json-response-from-security-analytics)
- [Writing Spec Tests](#writing-spec-tests)
- [Simple Test Story](#simple-test-story)
- [Using Output from Previous Chapters](#using-output-from-previous-chapters)
Expand Down Expand Up @@ -85,6 +86,9 @@ curl -k -X PUT --user "admin:${OPENSEARCH_PASSWORD}" https://localhost:9200/_clu
'
```
#### FAILED Cat with a json response (from security-analytics).
The cluster is not loading plugins correctly, maybe it was stopped using `docker kill` instead of `docker stop`. Recreating the cluster should fix the issue: `docker compose up --force-recreate -d`.
## Writing Spec Tests
The spec tests reside in the [tests/](tests) directory. Tests are organized in suites ([default](tests/default/), etc.), and subsequently in folders that match [namespaces](spec/namespaces). For example, tests for APIs defined in [spec/namespaces/indices.yaml](spec/namespaces/indices.yaml) can be found in [tests/default/indices/index.yaml](tests/default/indices/index.yaml) (for `/{index}`), and [tests/default/indices/doc.yaml](tests/default/indices/doc.yaml) (for `/{index}/_doc`).
Expand Down
11 changes: 4 additions & 7 deletions tools/src/tester/TestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ import { OpenSearchHttpClient } from 'OpenSearchHttpClient'
import * as ansi from './Ansi'
import _ from 'lodash'

const EXCLUDED_FILES = [
'docker-compose.yml'
]

export default class TestRunner {
private readonly _http_client: OpenSearchHttpClient
private readonly _story_validator: StoryValidator
Expand Down Expand Up @@ -69,6 +65,9 @@ export default class TestRunner {
const path = file === '' ? folder : `${folder}/${file}`
const next_prefix = prefix === '' ? file : `${prefix}/${file}`
if (fs.statSync(path).isFile()) {
if (!path.endsWith('.yaml')) {
return []
}
const story: Story = read_yaml(path)
return [{
display_path: next_prefix === '' ? basename(path) : next_prefix,
Expand All @@ -77,9 +76,7 @@ export default class TestRunner {
}]
} else {
return _.compact(fs.readdirSync(path).flatMap(next_file => {
if (!EXCLUDED_FILES.includes(next_file)) {
return this.#collect_story_files(path, next_file, next_prefix)
}
return this.#collect_story_files(path, next_file, next_prefix)
}))
}
}
Expand Down
1 change: 1 addition & 0 deletions tools/tests/tester/fixtures/stories/ignore.wrong.extension
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Not a .yaml file, should be ignored

0 comments on commit 56a5a22

Please sign in to comment.