From 56a5a224562d465f77c6e1712a266d1d11ba8a5c Mon Sep 17 00:00:00 2001 From: Andy Wick Date: Sun, 11 Aug 2024 18:42:31 -0400 Subject: [PATCH] Document fielddata.yaml fail, ignore vim swp files (#473) * 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 * fixed FAILED placment Signed-off-by: Andy Wick * switch to only processing .yaml files Signed-off-by: Andy Wick * Remove EXCLUDED_FILES instead only process .yaml Signed-off-by: Andy Wick --------- Signed-off-by: Andy Wick --- .github/workflows/changelog.yml | 2 +- .github/workflows/test-spec.yml | 2 +- TESTING_GUIDE.md | 4 ++++ tools/src/tester/TestRunner.ts | 11 ++++------- .../tester/fixtures/stories/ignore.wrong.extension | 1 + 5 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 tools/tests/tester/fixtures/stories/ignore.wrong.extension diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 23a1e0502..c6994060d 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -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 }} diff --git a/.github/workflows/test-spec.yml b/.github/workflows/test-spec.yml index 72a8d7601..d9ed81aea 100644 --- a/.github/workflows/test-spec.yml +++ b/.github/workflows/test-spec.yml @@ -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 diff --git a/TESTING_GUIDE.md b/TESTING_GUIDE.md index 5c066549e..61f6c2828 100644 --- a/TESTING_GUIDE.md +++ b/TESTING_GUIDE.md @@ -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) @@ -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`). diff --git a/tools/src/tester/TestRunner.ts b/tools/src/tester/TestRunner.ts index fdde53791..0c0f3c4ff 100644 --- a/tools/src/tester/TestRunner.ts +++ b/tools/src/tester/TestRunner.ts @@ -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 @@ -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, @@ -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) })) } } diff --git a/tools/tests/tester/fixtures/stories/ignore.wrong.extension b/tools/tests/tester/fixtures/stories/ignore.wrong.extension new file mode 100644 index 000000000..a649676ae --- /dev/null +++ b/tools/tests/tester/fixtures/stories/ignore.wrong.extension @@ -0,0 +1 @@ +Not a .yaml file, should be ignored